@matija2209/payload-plugin-admin-feedback 1.0.3 → 1.1.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 +56 -0
- package/README.md +178 -47
- package/dist/client/index.cjs +841 -2024
- package/dist/client/index.d.cts +35 -85
- package/dist/client/index.d.ts +35 -85
- package/dist/client/index.js +840 -2019
- package/dist/index.cjs +266 -209
- package/dist/index.d.cts +76 -3
- package/dist/index.d.ts +76 -3
- package/dist/index.js +266 -210
- package/package.json +30 -21
- package/dist/routeMatcher-CmCMn_gT.d.cts +0 -54
- package/dist/routeMatcher-CmCMn_gT.d.ts +0 -54
- package/public/payload-admin-plugin-header.png +0 -0
package/dist/client/index.cjs
CHANGED
|
@@ -1,900 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
1
2
|
'use strict';
|
|
2
3
|
|
|
3
|
-
var
|
|
4
|
-
var React2 = require('react');
|
|
4
|
+
var React = require('react');
|
|
5
5
|
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var ui = require('@payloadcms/ui');
|
|
6
7
|
var navigation = require('next/navigation');
|
|
7
8
|
|
|
8
9
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
10
|
|
|
10
|
-
var
|
|
11
|
+
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
11
12
|
|
|
12
|
-
// src/client/FeedbackWidget.tsx
|
|
13
|
-
|
|
14
|
-
// src/client/ui.ts
|
|
15
|
-
var theme = {
|
|
16
|
-
accent: "#5eead4",
|
|
17
|
-
text: "#f8fafc",
|
|
18
|
-
textSoft: "rgba(226, 232, 240, 0.78)",
|
|
19
|
-
textMuted: "rgba(148, 163, 184, 0.78)",
|
|
20
|
-
dangerSoft: "rgba(248, 113, 113, 0.18)",
|
|
21
|
-
border: "rgba(148, 163, 184, 0.18)",
|
|
22
|
-
borderStrong: "rgba(148, 163, 184, 0.28)",
|
|
23
|
-
panel: "linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(6, 13, 24, 0.96) 100%)",
|
|
24
|
-
card: "linear-gradient(180deg, rgba(30, 41, 59, 0.54) 0%, rgba(15, 23, 42, 0.7) 100%)",
|
|
25
|
-
inset: "rgba(15, 23, 42, 0.82)",
|
|
26
|
-
shadow: "0 28px 70px rgba(2, 8, 23, 0.48)",
|
|
27
|
-
subtleShadow: "0 18px 40px rgba(2, 8, 23, 0.24)"
|
|
28
|
-
};
|
|
29
|
-
var floatingLauncherStyle = {
|
|
30
|
-
position: "fixed",
|
|
31
|
-
right: "20px",
|
|
32
|
-
bottom: "20px",
|
|
33
|
-
zIndex: 9999,
|
|
34
|
-
display: "inline-flex",
|
|
35
|
-
alignItems: "center",
|
|
36
|
-
gap: "8px",
|
|
37
|
-
borderRadius: "999px",
|
|
38
|
-
border: `1px solid ${theme.borderStrong}`,
|
|
39
|
-
background: "linear-gradient(135deg, rgba(45, 212, 191, 0.96) 0%, rgba(15, 118, 110, 0.96) 100%)",
|
|
40
|
-
color: "#03131f",
|
|
41
|
-
padding: "10px 14px",
|
|
42
|
-
fontWeight: 700,
|
|
43
|
-
fontSize: "13px",
|
|
44
|
-
letterSpacing: "-0.01em",
|
|
45
|
-
cursor: "pointer",
|
|
46
|
-
boxShadow: "0 24px 55px rgba(15, 118, 110, 0.34)"
|
|
47
|
-
};
|
|
48
|
-
var panelStyle = {
|
|
49
|
-
position: "fixed",
|
|
50
|
-
right: "12px",
|
|
51
|
-
bottom: "calc(12px + env(safe-area-inset-bottom, 0px))",
|
|
52
|
-
width: "min(396px, calc(100vw - 24px))",
|
|
53
|
-
maxHeight: "min(780px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)))",
|
|
54
|
-
height: "min(780px, calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)))",
|
|
55
|
-
overflow: "hidden",
|
|
56
|
-
display: "flex",
|
|
57
|
-
flexDirection: "column",
|
|
58
|
-
overscrollBehavior: "contain",
|
|
59
|
-
background: theme.panel,
|
|
60
|
-
color: theme.text,
|
|
61
|
-
borderRadius: "22px",
|
|
62
|
-
border: `1px solid ${theme.border}`,
|
|
63
|
-
zIndex: 9999,
|
|
64
|
-
boxShadow: theme.shadow,
|
|
65
|
-
backdropFilter: "blur(18px)"
|
|
66
|
-
};
|
|
67
|
-
var panelHeaderStyle = {
|
|
68
|
-
padding: "14px 14px 12px",
|
|
69
|
-
borderBottom: `1px solid ${theme.border}`,
|
|
70
|
-
background: "radial-gradient(circle at top right, rgba(45, 212, 191, 0.14), transparent 38%), transparent"
|
|
71
|
-
};
|
|
72
|
-
var surfaceCardStyle = {
|
|
73
|
-
background: theme.card,
|
|
74
|
-
border: `1px solid ${theme.border}`,
|
|
75
|
-
borderRadius: "16px",
|
|
76
|
-
boxShadow: theme.subtleShadow
|
|
77
|
-
};
|
|
78
|
-
var innerCardStyle = {
|
|
79
|
-
background: theme.inset,
|
|
80
|
-
border: `1px solid ${theme.border}`,
|
|
81
|
-
borderRadius: "14px"
|
|
82
|
-
};
|
|
83
|
-
var fieldStyle = {
|
|
84
|
-
width: "100%",
|
|
85
|
-
borderRadius: "14px",
|
|
86
|
-
border: `1px solid ${theme.border}`,
|
|
87
|
-
background: "rgba(15, 23, 42, 0.86)",
|
|
88
|
-
color: theme.text,
|
|
89
|
-
padding: "12px 14px",
|
|
90
|
-
fontSize: "13px",
|
|
91
|
-
lineHeight: 1.5,
|
|
92
|
-
outline: "none",
|
|
93
|
-
boxSizing: "border-box",
|
|
94
|
-
boxShadow: "inset 0 1px 0 rgba(255,255,255,0.03)"
|
|
95
|
-
};
|
|
96
|
-
var metaTextStyle = {
|
|
97
|
-
margin: 0,
|
|
98
|
-
fontSize: "12px",
|
|
99
|
-
lineHeight: 1.5,
|
|
100
|
-
color: theme.textMuted
|
|
101
|
-
};
|
|
102
|
-
var sectionLabelStyle = {
|
|
103
|
-
margin: 0,
|
|
104
|
-
fontSize: "11px",
|
|
105
|
-
fontWeight: 700,
|
|
106
|
-
letterSpacing: "0.08em",
|
|
107
|
-
textTransform: "uppercase",
|
|
108
|
-
color: theme.textMuted
|
|
109
|
-
};
|
|
110
|
-
var statusTextStyle = {
|
|
111
|
-
margin: 0,
|
|
112
|
-
fontSize: "12px",
|
|
113
|
-
lineHeight: 1.5,
|
|
114
|
-
color: theme.textSoft
|
|
115
|
-
};
|
|
116
|
-
function buttonStyle(variant, options = {}) {
|
|
117
|
-
const { active = false, disabled = false, iconOnly = false, compact = false, justify = "center" } = options;
|
|
118
|
-
const base = {
|
|
119
|
-
display: "inline-flex",
|
|
120
|
-
alignItems: "center",
|
|
121
|
-
justifyContent: justify,
|
|
122
|
-
gap: "8px",
|
|
123
|
-
minHeight: compact ? "32px" : "38px",
|
|
124
|
-
padding: iconOnly ? compact ? "7px" : "9px" : compact ? "7px 11px" : "9px 13px",
|
|
125
|
-
borderRadius: iconOnly ? "12px" : "14px",
|
|
126
|
-
border: `1px solid ${theme.border}`,
|
|
127
|
-
color: theme.text,
|
|
128
|
-
cursor: disabled ? "not-allowed" : "pointer",
|
|
129
|
-
fontSize: compact ? "12px" : "13px",
|
|
130
|
-
fontWeight: 600,
|
|
131
|
-
letterSpacing: "-0.01em",
|
|
132
|
-
transition: "transform 0.18s ease, opacity 0.18s ease, border-color 0.18s ease",
|
|
133
|
-
opacity: disabled ? 0.45 : 1,
|
|
134
|
-
boxSizing: "border-box"
|
|
135
|
-
};
|
|
136
|
-
const variants = {
|
|
137
|
-
primary: {
|
|
138
|
-
background: "linear-gradient(135deg, rgba(94, 234, 212, 0.98) 0%, rgba(20, 184, 166, 0.98) 100%)",
|
|
139
|
-
borderColor: "rgba(153, 246, 228, 0.38)",
|
|
140
|
-
color: "#04111c",
|
|
141
|
-
boxShadow: "0 18px 35px rgba(20, 184, 166, 0.22)"
|
|
142
|
-
},
|
|
143
|
-
secondary: {
|
|
144
|
-
background: active ? "rgba(94, 234, 212, 0.14)" : theme.card,
|
|
145
|
-
borderColor: active ? "rgba(94, 234, 212, 0.34)" : theme.border,
|
|
146
|
-
color: active ? "#d1fae5" : theme.text
|
|
147
|
-
},
|
|
148
|
-
ghost: {
|
|
149
|
-
background: active ? "rgba(94, 234, 212, 0.12)" : "transparent",
|
|
150
|
-
borderColor: active ? "rgba(94, 234, 212, 0.28)" : "transparent",
|
|
151
|
-
color: active ? theme.text : theme.textSoft
|
|
152
|
-
},
|
|
153
|
-
danger: {
|
|
154
|
-
background: active ? "rgba(248, 113, 113, 0.18)" : theme.dangerSoft,
|
|
155
|
-
borderColor: "rgba(248, 113, 113, 0.28)",
|
|
156
|
-
color: "#fecaca"
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
return { ...base, ...variants[variant] };
|
|
160
|
-
}
|
|
161
|
-
function pillStyle(variant) {
|
|
162
|
-
const variants = {
|
|
163
|
-
neutral: {
|
|
164
|
-
background: "rgba(148, 163, 184, 0.16)",
|
|
165
|
-
color: theme.textSoft,
|
|
166
|
-
border: `1px solid ${theme.border}`
|
|
167
|
-
},
|
|
168
|
-
success: {
|
|
169
|
-
background: "rgba(34, 197, 94, 0.16)",
|
|
170
|
-
color: "#86efac",
|
|
171
|
-
border: "1px solid rgba(34, 197, 94, 0.24)"
|
|
172
|
-
},
|
|
173
|
-
warning: {
|
|
174
|
-
background: "rgba(234, 179, 8, 0.18)",
|
|
175
|
-
color: "#fde68a",
|
|
176
|
-
border: "1px solid rgba(234, 179, 8, 0.24)"
|
|
177
|
-
},
|
|
178
|
-
muted: {
|
|
179
|
-
background: "rgba(148, 163, 184, 0.16)",
|
|
180
|
-
color: "#cbd5e1",
|
|
181
|
-
border: `1px solid ${theme.border}`
|
|
182
|
-
},
|
|
183
|
-
danger: {
|
|
184
|
-
background: theme.dangerSoft,
|
|
185
|
-
color: "#fecaca",
|
|
186
|
-
border: "1px solid rgba(248, 113, 113, 0.24)"
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
return {
|
|
190
|
-
display: "inline-flex",
|
|
191
|
-
alignItems: "center",
|
|
192
|
-
gap: "6px",
|
|
193
|
-
borderRadius: "999px",
|
|
194
|
-
padding: "5px 10px",
|
|
195
|
-
fontSize: "11px",
|
|
196
|
-
fontWeight: 700,
|
|
197
|
-
letterSpacing: "0.01em",
|
|
198
|
-
...variants[variant]
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
var formatDate = (iso) => {
|
|
202
|
-
try {
|
|
203
|
-
return new Date(iso).toLocaleString("en-US", {
|
|
204
|
-
month: "short",
|
|
205
|
-
day: "numeric",
|
|
206
|
-
year: "numeric",
|
|
207
|
-
hour: "2-digit",
|
|
208
|
-
minute: "2-digit"
|
|
209
|
-
});
|
|
210
|
-
} catch {
|
|
211
|
-
return iso;
|
|
212
|
-
}
|
|
213
|
-
};
|
|
214
|
-
var getScreenshotInfo = (feedback) => {
|
|
215
|
-
if (!feedback.screenshot || typeof feedback.screenshot !== "object") return null;
|
|
216
|
-
const screenshot = feedback.screenshot;
|
|
217
|
-
if (screenshot.url) return { id: screenshot.id, url: screenshot.url };
|
|
218
|
-
if (screenshot.filename) return { id: screenshot.id, url: screenshot.filename };
|
|
219
|
-
return null;
|
|
220
|
-
};
|
|
221
|
-
var getCreatorId = (feedback) => {
|
|
222
|
-
if (!feedback.createdBy) return null;
|
|
223
|
-
if (typeof feedback.createdBy === "object") return feedback.createdBy.id;
|
|
224
|
-
return feedback.createdBy;
|
|
225
|
-
};
|
|
226
|
-
var canvasToFile = async (canvas, fileName = `feedback-${Date.now()}.png`) => {
|
|
227
|
-
const blob = await new Promise((resolve) => {
|
|
228
|
-
canvas.toBlob((nextBlob) => resolve(nextBlob), "image/png");
|
|
229
|
-
});
|
|
230
|
-
if (!blob) throw new Error("Failed to prepare screenshot.");
|
|
231
|
-
return new File([blob], fileName.replace(/\.[a-z0-9]+$/i, "") + ".png", { type: "image/png" });
|
|
232
|
-
};
|
|
233
|
-
var captureScreenshotFile = async () => {
|
|
234
|
-
if (!navigator.mediaDevices?.getDisplayMedia) {
|
|
235
|
-
throw new Error("Browser does not support screen capture.");
|
|
236
|
-
}
|
|
237
|
-
const stream = await navigator.mediaDevices.getDisplayMedia({
|
|
238
|
-
video: { displaySurface: "browser" },
|
|
239
|
-
audio: false,
|
|
240
|
-
preferCurrentTab: true
|
|
241
|
-
});
|
|
242
|
-
const track = stream.getVideoTracks()[0];
|
|
243
|
-
if (!track) {
|
|
244
|
-
stream.getTracks().forEach((nextTrack) => nextTrack.stop());
|
|
245
|
-
throw new Error("Screen capture failed.");
|
|
246
|
-
}
|
|
247
|
-
const video = document.createElement("video");
|
|
248
|
-
try {
|
|
249
|
-
video.srcObject = stream;
|
|
250
|
-
video.muted = true;
|
|
251
|
-
video.playsInline = true;
|
|
252
|
-
await video.play();
|
|
253
|
-
await new Promise((resolve) => {
|
|
254
|
-
if ("requestVideoFrameCallback" in video) {
|
|
255
|
-
video.requestVideoFrameCallback(() => resolve());
|
|
256
|
-
} else {
|
|
257
|
-
requestAnimationFrame(() => resolve());
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
const width = video.videoWidth || window.innerWidth;
|
|
261
|
-
const height = video.videoHeight || window.innerHeight;
|
|
262
|
-
if (!width || !height) throw new Error("Screen capture failed.");
|
|
263
|
-
const canvas = document.createElement("canvas");
|
|
264
|
-
canvas.width = width;
|
|
265
|
-
canvas.height = height;
|
|
266
|
-
const context = canvas.getContext("2d");
|
|
267
|
-
if (!context) throw new Error("Browser does not support canvas context.");
|
|
268
|
-
context.drawImage(video, 0, 0, width, height);
|
|
269
|
-
return canvasToFile(canvas);
|
|
270
|
-
} finally {
|
|
271
|
-
video.pause();
|
|
272
|
-
video.srcObject = null;
|
|
273
|
-
stream.getTracks().forEach((nextTrack) => nextTrack.stop());
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
function FeedbackDetail({
|
|
277
|
-
feedback,
|
|
278
|
-
currentUserId,
|
|
279
|
-
capturePolicy: _capturePolicy,
|
|
280
|
-
onBack,
|
|
281
|
-
onUpdate,
|
|
282
|
-
onDelete,
|
|
283
|
-
onUpload,
|
|
284
|
-
onDeleteScreenshot
|
|
285
|
-
}) {
|
|
286
|
-
const [editing, setEditing] = React2__default.default.useState(false);
|
|
287
|
-
const [message, setMessage] = React2__default.default.useState(feedback.message);
|
|
288
|
-
const [screenshotId, setScreenshotId] = React2__default.default.useState(getScreenshotInfo(feedback)?.id ?? null);
|
|
289
|
-
const [screenshotUrl, setScreenshotUrl] = React2__default.default.useState(getScreenshotInfo(feedback)?.url ?? null);
|
|
290
|
-
const [uploading, setUploading] = React2__default.default.useState(false);
|
|
291
|
-
const [removing, setRemoving] = React2__default.default.useState(false);
|
|
292
|
-
const [saving, setSaving] = React2__default.default.useState(false);
|
|
293
|
-
const [deleting, setDeleting] = React2__default.default.useState(false);
|
|
294
|
-
const [error, setError] = React2__default.default.useState(null);
|
|
295
|
-
const isOwner = getCreatorId(feedback) === currentUserId;
|
|
296
|
-
const screenshot = getScreenshotInfo(feedback);
|
|
297
|
-
const currentScreenshotId = screenshotId ?? screenshot?.id ?? null;
|
|
298
|
-
const uploadFile = async (file) => {
|
|
299
|
-
setUploading(true);
|
|
300
|
-
setError(null);
|
|
301
|
-
try {
|
|
302
|
-
const formData = new FormData();
|
|
303
|
-
formData.append("file", file);
|
|
304
|
-
formData.append("alt", file.name);
|
|
305
|
-
const result = await onUpload(formData);
|
|
306
|
-
if (!result.success) {
|
|
307
|
-
setError(result.error);
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
setScreenshotId(result.mediaId);
|
|
311
|
-
setScreenshotUrl(URL.createObjectURL(file));
|
|
312
|
-
return result.mediaId;
|
|
313
|
-
} catch (nextError) {
|
|
314
|
-
setError(nextError instanceof Error ? nextError.message : "Upload failed.");
|
|
315
|
-
return null;
|
|
316
|
-
} finally {
|
|
317
|
-
setUploading(false);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
const handleRemoveScreenshot = async () => {
|
|
321
|
-
if (!currentScreenshotId) return;
|
|
322
|
-
setRemoving(true);
|
|
323
|
-
setError(null);
|
|
324
|
-
try {
|
|
325
|
-
const result = await onDeleteScreenshot(currentScreenshotId);
|
|
326
|
-
if (!result.success) {
|
|
327
|
-
setError(result.error);
|
|
328
|
-
return;
|
|
329
|
-
}
|
|
330
|
-
setScreenshotId(null);
|
|
331
|
-
setScreenshotUrl(null);
|
|
332
|
-
} catch (nextError) {
|
|
333
|
-
setError(nextError instanceof Error ? nextError.message : "Failed to remove screenshot.");
|
|
334
|
-
} finally {
|
|
335
|
-
setRemoving(false);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
const handleCapture = async () => {
|
|
339
|
-
try {
|
|
340
|
-
const file = await captureScreenshotFile();
|
|
341
|
-
await uploadFile(file);
|
|
342
|
-
} catch (nextError) {
|
|
343
|
-
setError(nextError instanceof Error ? nextError.message : "Screen capture failed.");
|
|
344
|
-
}
|
|
345
|
-
};
|
|
346
|
-
const handleFileUpload = async (event) => {
|
|
347
|
-
const file = event.target.files?.[0];
|
|
348
|
-
if (file) await uploadFile(file);
|
|
349
|
-
event.target.value = "";
|
|
350
|
-
};
|
|
351
|
-
React2__default.default.useEffect(() => {
|
|
352
|
-
if (!editing) return;
|
|
353
|
-
const onPaste = async (event) => {
|
|
354
|
-
const file = Array.from(event.clipboardData?.items || []).find((item) => item.type.startsWith("image/"))?.getAsFile();
|
|
355
|
-
if (file) {
|
|
356
|
-
event.preventDefault();
|
|
357
|
-
await uploadFile(file);
|
|
358
|
-
}
|
|
359
|
-
};
|
|
360
|
-
window.addEventListener("paste", onPaste);
|
|
361
|
-
return () => window.removeEventListener("paste", onPaste);
|
|
362
|
-
}, [editing]);
|
|
363
|
-
const handleSave = async () => {
|
|
364
|
-
if (!message.trim()) {
|
|
365
|
-
setError("Message cannot be empty.");
|
|
366
|
-
return;
|
|
367
|
-
}
|
|
368
|
-
setSaving(true);
|
|
369
|
-
setError(null);
|
|
370
|
-
try {
|
|
371
|
-
const updateData = {};
|
|
372
|
-
if (message.trim() !== feedback.message) {
|
|
373
|
-
updateData.message = message.trim();
|
|
374
|
-
}
|
|
375
|
-
if ((screenshotId ?? null) !== (feedback.screenshot && typeof feedback.screenshot === "object" ? feedback.screenshot.id : feedback.screenshot)) {
|
|
376
|
-
updateData.screenshotId = screenshotId ?? null;
|
|
377
|
-
}
|
|
378
|
-
const success = await onUpdate(feedback.id, updateData);
|
|
379
|
-
if (success) {
|
|
380
|
-
setEditing(false);
|
|
381
|
-
} else {
|
|
382
|
-
setError("Failed to save changes.");
|
|
383
|
-
}
|
|
384
|
-
} catch (nextError) {
|
|
385
|
-
setError(nextError instanceof Error ? nextError.message : "Save failed.");
|
|
386
|
-
} finally {
|
|
387
|
-
setSaving(false);
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
const handleDelete = async () => {
|
|
391
|
-
if (!window.confirm("Delete this feedback? This cannot be undone.")) {
|
|
392
|
-
return;
|
|
393
|
-
}
|
|
394
|
-
setDeleting(true);
|
|
395
|
-
setError(null);
|
|
396
|
-
try {
|
|
397
|
-
const success = await onDelete(feedback.id);
|
|
398
|
-
if (!success) {
|
|
399
|
-
setError("Failed to delete feedback.");
|
|
400
|
-
}
|
|
401
|
-
} catch (nextError) {
|
|
402
|
-
setError(nextError instanceof Error ? nextError.message : "Delete failed.");
|
|
403
|
-
} finally {
|
|
404
|
-
setDeleting(false);
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: "12px" }, children: [
|
|
408
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px" }, children: [
|
|
409
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: onBack, style: buttonStyle("ghost", { compact: true }), children: [
|
|
410
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ArrowLeft, { size: 15 }),
|
|
411
|
-
"Back"
|
|
412
|
-
] }),
|
|
413
|
-
isOwner && !editing ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", justifyContent: "flex-end" }, children: [
|
|
414
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
415
|
-
"button",
|
|
416
|
-
{
|
|
417
|
-
type: "button",
|
|
418
|
-
onClick: () => {
|
|
419
|
-
setEditing(true);
|
|
420
|
-
setError(null);
|
|
421
|
-
},
|
|
422
|
-
style: buttonStyle("secondary", { compact: true }),
|
|
423
|
-
children: [
|
|
424
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.PencilLine, { size: 15 }),
|
|
425
|
-
"Edit"
|
|
426
|
-
]
|
|
427
|
-
}
|
|
428
|
-
),
|
|
429
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
430
|
-
"button",
|
|
431
|
-
{
|
|
432
|
-
type: "button",
|
|
433
|
-
onClick: handleDelete,
|
|
434
|
-
disabled: deleting,
|
|
435
|
-
style: buttonStyle("danger", { compact: true, disabled: deleting }),
|
|
436
|
-
children: [
|
|
437
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 15 }),
|
|
438
|
-
deleting ? "Deleting..." : "Delete"
|
|
439
|
-
]
|
|
440
|
-
}
|
|
441
|
-
)
|
|
442
|
-
] }) : null
|
|
443
|
-
] }),
|
|
444
|
-
editing ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
445
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "16px" }, children: [
|
|
446
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...sectionLabelStyle, marginBottom: "10px" }, children: "Message" }),
|
|
447
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
448
|
-
"textarea",
|
|
449
|
-
{
|
|
450
|
-
value: message,
|
|
451
|
-
onChange: (event) => setMessage(event.target.value),
|
|
452
|
-
rows: 6,
|
|
453
|
-
style: { ...fieldStyle, resize: "vertical", minHeight: "140px" },
|
|
454
|
-
placeholder: "Describe what changed or what still needs attention..."
|
|
455
|
-
}
|
|
456
|
-
)
|
|
457
|
-
] }),
|
|
458
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "16px" }, children: [
|
|
459
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", gap: "8px", marginBottom: "12px" }, children: [
|
|
460
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
461
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Screenshot" }),
|
|
462
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...metaTextStyle, marginTop: "4px" }, children: "Paste an image, capture the current tab, or upload a replacement." })
|
|
463
|
-
] }),
|
|
464
|
-
screenshotId ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: pillStyle("neutral"), children: [
|
|
465
|
-
"Media #",
|
|
466
|
-
screenshotId
|
|
467
|
-
] }) : null
|
|
468
|
-
] }),
|
|
469
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: screenshotUrl ? (
|
|
470
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
471
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
472
|
-
"img",
|
|
473
|
-
{
|
|
474
|
-
src: screenshotUrl,
|
|
475
|
-
alt: "Screenshot",
|
|
476
|
-
style: { width: "100%", height: "auto", display: "block", maxHeight: "280px", objectFit: "cover" }
|
|
477
|
-
}
|
|
478
|
-
)
|
|
479
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
480
|
-
"div",
|
|
481
|
-
{
|
|
482
|
-
style: {
|
|
483
|
-
minHeight: "180px",
|
|
484
|
-
display: "grid",
|
|
485
|
-
placeItems: "center",
|
|
486
|
-
color: theme.textMuted,
|
|
487
|
-
background: "rgba(15, 23, 42, 0.72)"
|
|
488
|
-
},
|
|
489
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
|
|
490
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ImageIcon, { size: 24, style: { marginBottom: "8px" } }),
|
|
491
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: metaTextStyle, children: "No screenshot attached." })
|
|
492
|
-
] })
|
|
493
|
-
}
|
|
494
|
-
) }),
|
|
495
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap", marginTop: "12px" }, children: [
|
|
496
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
497
|
-
"button",
|
|
498
|
-
{
|
|
499
|
-
type: "button",
|
|
500
|
-
onClick: handleCapture,
|
|
501
|
-
disabled: uploading,
|
|
502
|
-
"aria-label": uploading ? "Capturing screen" : "Capture screen",
|
|
503
|
-
title: uploading ? "Capturing screen" : "Capture screen",
|
|
504
|
-
style: buttonStyle("secondary", { compact: true, disabled: uploading, iconOnly: true }),
|
|
505
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Camera, { size: 15 })
|
|
506
|
-
}
|
|
507
|
-
),
|
|
508
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
509
|
-
"label",
|
|
510
|
-
{
|
|
511
|
-
"aria-label": "Upload image",
|
|
512
|
-
title: "Upload image",
|
|
513
|
-
style: buttonStyle("secondary", { compact: true, iconOnly: true }),
|
|
514
|
-
children: [
|
|
515
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 15 }),
|
|
516
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "file", accept: "image/png,image/jpeg,image/webp", onChange: handleFileUpload, hidden: true })
|
|
517
|
-
]
|
|
518
|
-
}
|
|
519
|
-
),
|
|
520
|
-
currentScreenshotId && screenshotUrl ? /* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: handleRemoveScreenshot, disabled: removing, style: buttonStyle("danger", { compact: true, disabled: removing }), children: [
|
|
521
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 15 }),
|
|
522
|
-
removing ? "Removing..." : "Remove"
|
|
523
|
-
] }) : null
|
|
524
|
-
] })
|
|
525
|
-
] }),
|
|
526
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...statusTextStyle, color: "#fecaca" }, children: error }) }) : null,
|
|
527
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "flex-end", gap: "8px", flexWrap: "wrap" }, children: [
|
|
528
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
529
|
-
"button",
|
|
530
|
-
{
|
|
531
|
-
type: "button",
|
|
532
|
-
onClick: () => {
|
|
533
|
-
setEditing(false);
|
|
534
|
-
setMessage(feedback.message);
|
|
535
|
-
setScreenshotId(screenshot?.id ?? null);
|
|
536
|
-
setScreenshotUrl(screenshot?.url ?? null);
|
|
537
|
-
setError(null);
|
|
538
|
-
},
|
|
539
|
-
style: buttonStyle("ghost"),
|
|
540
|
-
children: [
|
|
541
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { size: 15 }),
|
|
542
|
-
"Cancel"
|
|
543
|
-
]
|
|
544
|
-
}
|
|
545
|
-
),
|
|
546
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: handleSave, disabled: saving, style: buttonStyle("primary", { disabled: saving }), children: [
|
|
547
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Save, { size: 15 }),
|
|
548
|
-
saving ? "Saving..." : "Save changes"
|
|
549
|
-
] })
|
|
550
|
-
] })
|
|
551
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
552
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...surfaceCardStyle, padding: "18px" }, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "15px", lineHeight: 1.7, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: feedback.message }) }),
|
|
553
|
-
screenshot ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "12px" }, children: [
|
|
554
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: "8px", marginBottom: "10px" }, children: [
|
|
555
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Screenshot" }),
|
|
556
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
557
|
-
"button",
|
|
558
|
-
{
|
|
559
|
-
type: "button",
|
|
560
|
-
onClick: () => window.open(screenshot.url, "_blank"),
|
|
561
|
-
style: buttonStyle("ghost", { compact: true }),
|
|
562
|
-
children: [
|
|
563
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ExternalLink, { size: 14 }),
|
|
564
|
-
"Open full size"
|
|
565
|
-
]
|
|
566
|
-
}
|
|
567
|
-
)
|
|
568
|
-
] }),
|
|
569
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
570
|
-
"img",
|
|
571
|
-
{
|
|
572
|
-
src: screenshot.url,
|
|
573
|
-
alt: "Feedback screenshot",
|
|
574
|
-
style: { width: "100%", height: "auto", display: "block", cursor: "pointer" },
|
|
575
|
-
onClick: () => window.open(screenshot.url, "_blank")
|
|
576
|
-
}
|
|
577
|
-
) })
|
|
578
|
-
] }) : null,
|
|
579
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "16px", display: "grid", gap: "12px" }, children: [
|
|
580
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
581
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Page" }),
|
|
582
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "6px" }, children: [
|
|
583
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { size: 15, color: theme.textMuted }),
|
|
584
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...metaTextStyle, wordBreak: "break-all" }, children: feedback.pagePath })
|
|
585
|
-
] })
|
|
586
|
-
] }),
|
|
587
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
588
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Created" }),
|
|
589
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", marginTop: "6px" }, children: [
|
|
590
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CalendarClock, { size: 15, color: theme.textMuted }),
|
|
591
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: metaTextStyle, children: formatDate(feedback.createdAt) })
|
|
592
|
-
] })
|
|
593
|
-
] })
|
|
594
|
-
] }),
|
|
595
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...statusTextStyle, color: "#fecaca" }, children: error }) }) : null
|
|
596
|
-
] })
|
|
597
|
-
] });
|
|
598
|
-
}
|
|
599
|
-
var STATUS_VARIANTS = {
|
|
600
|
-
new: "success",
|
|
601
|
-
triaged: "warning",
|
|
602
|
-
resolved: "muted"
|
|
603
|
-
};
|
|
604
|
-
var STATUS_LABELS = {
|
|
605
|
-
new: "New",
|
|
606
|
-
triaged: "Triaged",
|
|
607
|
-
resolved: "Resolved"
|
|
608
|
-
};
|
|
609
|
-
var formatRelativeTime = (iso) => {
|
|
610
|
-
const now = Date.now();
|
|
611
|
-
const then = new Date(iso).getTime();
|
|
612
|
-
const diff = now - then;
|
|
613
|
-
const minutes = Math.floor(diff / 6e4);
|
|
614
|
-
if (minutes < 1) return "Just now";
|
|
615
|
-
if (minutes < 60) return `${minutes}m ago`;
|
|
616
|
-
const hours = Math.floor(minutes / 60);
|
|
617
|
-
if (hours < 24) return `${hours}h ago`;
|
|
618
|
-
const days = Math.floor(hours / 24);
|
|
619
|
-
if (days < 7) return `${days}d ago`;
|
|
620
|
-
const weeks = Math.floor(days / 7);
|
|
621
|
-
if (weeks < 5) return `${weeks}w ago`;
|
|
622
|
-
return new Date(iso).toLocaleDateString();
|
|
623
|
-
};
|
|
624
|
-
var getScreenshotThumb = (item) => {
|
|
625
|
-
if (!item.screenshot || typeof item.screenshot !== "object") return null;
|
|
626
|
-
return item.screenshot.url || null;
|
|
627
|
-
};
|
|
628
|
-
var getCreatorId2 = (createdBy) => {
|
|
629
|
-
if (!createdBy) return null;
|
|
630
|
-
if (typeof createdBy === "object") return createdBy.id;
|
|
631
|
-
return createdBy;
|
|
632
|
-
};
|
|
633
|
-
function FeedbackHistory({
|
|
634
|
-
feedbacks,
|
|
635
|
-
totalPages,
|
|
636
|
-
currentPage,
|
|
637
|
-
loading,
|
|
638
|
-
error,
|
|
639
|
-
currentUserId,
|
|
640
|
-
onSelectFeedback,
|
|
641
|
-
onPageChange,
|
|
642
|
-
onRefetch
|
|
643
|
-
}) {
|
|
644
|
-
if (loading) {
|
|
645
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "grid", gap: "10px" }, children: [1, 2, 3].map((item) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
646
|
-
"div",
|
|
647
|
-
{
|
|
648
|
-
style: {
|
|
649
|
-
...surfaceCardStyle,
|
|
650
|
-
padding: "14px"
|
|
651
|
-
},
|
|
652
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "12px", alignItems: "center" }, children: [
|
|
653
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
654
|
-
"div",
|
|
655
|
-
{
|
|
656
|
-
style: {
|
|
657
|
-
width: "52px",
|
|
658
|
-
height: "52px",
|
|
659
|
-
borderRadius: "14px",
|
|
660
|
-
background: "rgba(148, 163, 184, 0.14)",
|
|
661
|
-
flexShrink: 0
|
|
662
|
-
}
|
|
663
|
-
}
|
|
664
|
-
),
|
|
665
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1 }, children: [
|
|
666
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
667
|
-
"div",
|
|
668
|
-
{
|
|
669
|
-
style: {
|
|
670
|
-
height: "14px",
|
|
671
|
-
width: "72%",
|
|
672
|
-
borderRadius: "999px",
|
|
673
|
-
background: "rgba(148, 163, 184, 0.18)",
|
|
674
|
-
marginBottom: "10px"
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
),
|
|
678
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
679
|
-
"div",
|
|
680
|
-
{
|
|
681
|
-
style: {
|
|
682
|
-
height: "10px",
|
|
683
|
-
width: "48%",
|
|
684
|
-
borderRadius: "999px",
|
|
685
|
-
background: "rgba(148, 163, 184, 0.12)"
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
)
|
|
689
|
-
] })
|
|
690
|
-
] })
|
|
691
|
-
},
|
|
692
|
-
item
|
|
693
|
-
)) });
|
|
694
|
-
}
|
|
695
|
-
if (error) {
|
|
696
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
697
|
-
"div",
|
|
698
|
-
{
|
|
699
|
-
style: {
|
|
700
|
-
...surfaceCardStyle,
|
|
701
|
-
padding: "18px",
|
|
702
|
-
textAlign: "center"
|
|
703
|
-
},
|
|
704
|
-
children: [
|
|
705
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...statusTextStyle, color: "#fecaca", marginBottom: "12px" }, children: error }),
|
|
706
|
-
/* @__PURE__ */ jsxRuntime.jsxs("button", { type: "button", onClick: onRefetch, style: buttonStyle("secondary"), children: [
|
|
707
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.RefreshCw, { size: 15 }),
|
|
708
|
-
"Retry"
|
|
709
|
-
] })
|
|
710
|
-
]
|
|
711
|
-
}
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
if (feedbacks.length === 0) {
|
|
715
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
716
|
-
"div",
|
|
717
|
-
{
|
|
718
|
-
style: {
|
|
719
|
-
...surfaceCardStyle,
|
|
720
|
-
padding: "26px 18px",
|
|
721
|
-
textAlign: "center"
|
|
722
|
-
},
|
|
723
|
-
children: [
|
|
724
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
-
"div",
|
|
726
|
-
{
|
|
727
|
-
style: {
|
|
728
|
-
width: "44px",
|
|
729
|
-
height: "44px",
|
|
730
|
-
borderRadius: "14px",
|
|
731
|
-
margin: "0 auto 12px",
|
|
732
|
-
display: "grid",
|
|
733
|
-
placeItems: "center",
|
|
734
|
-
background: "rgba(94, 234, 212, 0.12)",
|
|
735
|
-
color: theme.accent
|
|
736
|
-
},
|
|
737
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquareText, { size: 20 })
|
|
738
|
-
}
|
|
739
|
-
),
|
|
740
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 4px", fontSize: "14px", fontWeight: 600 }, children: "No feedback yet" }),
|
|
741
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: metaTextStyle, children: "New reports will appear here with screenshots, status, and page context." })
|
|
742
|
-
]
|
|
743
|
-
}
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "grid", gap: "10px" }, children: [
|
|
747
|
-
feedbacks.map((item) => {
|
|
748
|
-
const thumb = getScreenshotThumb(item);
|
|
749
|
-
const preview = item.message.length > 110 ? `${item.message.slice(0, 110)}...` : item.message;
|
|
750
|
-
const isMine = currentUserId !== null && getCreatorId2(item.createdBy) === currentUserId;
|
|
751
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
752
|
-
"button",
|
|
753
|
-
{
|
|
754
|
-
type: "button",
|
|
755
|
-
onClick: () => onSelectFeedback(item.id),
|
|
756
|
-
style: {
|
|
757
|
-
...surfaceCardStyle,
|
|
758
|
-
display: "flex",
|
|
759
|
-
width: "100%",
|
|
760
|
-
gap: "12px",
|
|
761
|
-
padding: "14px",
|
|
762
|
-
color: theme.text,
|
|
763
|
-
textAlign: "left",
|
|
764
|
-
cursor: "pointer"
|
|
765
|
-
},
|
|
766
|
-
children: [
|
|
767
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
768
|
-
"div",
|
|
769
|
-
{
|
|
770
|
-
style: {
|
|
771
|
-
...innerCardStyle,
|
|
772
|
-
width: "56px",
|
|
773
|
-
height: "56px",
|
|
774
|
-
overflow: "hidden",
|
|
775
|
-
flexShrink: 0,
|
|
776
|
-
display: "grid",
|
|
777
|
-
placeItems: "center",
|
|
778
|
-
color: theme.textMuted
|
|
779
|
-
},
|
|
780
|
-
children: thumb ? (
|
|
781
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
782
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
783
|
-
"img",
|
|
784
|
-
{
|
|
785
|
-
src: thumb,
|
|
786
|
-
alt: "",
|
|
787
|
-
style: {
|
|
788
|
-
width: "100%",
|
|
789
|
-
height: "100%",
|
|
790
|
-
objectFit: "cover",
|
|
791
|
-
display: "block"
|
|
792
|
-
}
|
|
793
|
-
}
|
|
794
|
-
)
|
|
795
|
-
) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ImageIcon, { size: 18 })
|
|
796
|
-
}
|
|
797
|
-
),
|
|
798
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
799
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
800
|
-
"div",
|
|
801
|
-
{
|
|
802
|
-
style: {
|
|
803
|
-
display: "flex",
|
|
804
|
-
alignItems: "flex-start",
|
|
805
|
-
gap: "8px",
|
|
806
|
-
justifyContent: "space-between",
|
|
807
|
-
marginBottom: "8px"
|
|
808
|
-
},
|
|
809
|
-
children: [
|
|
810
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
811
|
-
"p",
|
|
812
|
-
{
|
|
813
|
-
style: {
|
|
814
|
-
margin: 0,
|
|
815
|
-
fontSize: "14px",
|
|
816
|
-
lineHeight: 1.5,
|
|
817
|
-
color: theme.text,
|
|
818
|
-
overflow: "hidden",
|
|
819
|
-
display: "-webkit-box",
|
|
820
|
-
WebkitBoxOrient: "vertical",
|
|
821
|
-
WebkitLineClamp: 2
|
|
822
|
-
},
|
|
823
|
-
children: preview
|
|
824
|
-
}
|
|
825
|
-
),
|
|
826
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle(STATUS_VARIANTS[item.status] || "success"), children: STATUS_LABELS[item.status] || "New" })
|
|
827
|
-
]
|
|
828
|
-
}
|
|
829
|
-
),
|
|
830
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
|
|
831
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: pillStyle("neutral"), children: [
|
|
832
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Clock3, { size: 12 }),
|
|
833
|
-
formatRelativeTime(item.createdAt)
|
|
834
|
-
] }),
|
|
835
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: pillStyle("neutral"), children: [
|
|
836
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { size: 12 }),
|
|
837
|
-
item.pagePath
|
|
838
|
-
] }),
|
|
839
|
-
isMine ? /* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle("success"), children: "Mine" }) : null
|
|
840
|
-
] })
|
|
841
|
-
] })
|
|
842
|
-
]
|
|
843
|
-
},
|
|
844
|
-
item.id
|
|
845
|
-
);
|
|
846
|
-
}),
|
|
847
|
-
totalPages > 1 ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
848
|
-
"div",
|
|
849
|
-
{
|
|
850
|
-
style: {
|
|
851
|
-
...surfaceCardStyle,
|
|
852
|
-
padding: "12px",
|
|
853
|
-
display: "flex",
|
|
854
|
-
alignItems: "center",
|
|
855
|
-
justifyContent: "space-between",
|
|
856
|
-
gap: "10px"
|
|
857
|
-
},
|
|
858
|
-
children: [
|
|
859
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
860
|
-
"button",
|
|
861
|
-
{
|
|
862
|
-
type: "button",
|
|
863
|
-
disabled: currentPage <= 1,
|
|
864
|
-
onClick: () => onPageChange(currentPage - 1),
|
|
865
|
-
style: buttonStyle("secondary", { compact: true, disabled: currentPage <= 1 }),
|
|
866
|
-
children: [
|
|
867
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronLeft, { size: 15 }),
|
|
868
|
-
"Previous"
|
|
869
|
-
]
|
|
870
|
-
}
|
|
871
|
-
),
|
|
872
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { textAlign: "center" }, children: [
|
|
873
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Page" }),
|
|
874
|
-
/* @__PURE__ */ jsxRuntime.jsxs("p", { style: { ...metaTextStyle, marginTop: "2px" }, children: [
|
|
875
|
-
currentPage,
|
|
876
|
-
" of ",
|
|
877
|
-
totalPages
|
|
878
|
-
] })
|
|
879
|
-
] }),
|
|
880
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
881
|
-
"button",
|
|
882
|
-
{
|
|
883
|
-
type: "button",
|
|
884
|
-
disabled: currentPage >= totalPages,
|
|
885
|
-
onClick: () => onPageChange(currentPage + 1),
|
|
886
|
-
style: buttonStyle("secondary", { compact: true, disabled: currentPage >= totalPages }),
|
|
887
|
-
children: [
|
|
888
|
-
"Next",
|
|
889
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronRight, { size: 15 })
|
|
890
|
-
]
|
|
891
|
-
}
|
|
892
|
-
)
|
|
893
|
-
]
|
|
894
|
-
}
|
|
895
|
-
) : null
|
|
896
|
-
] });
|
|
897
|
-
}
|
|
898
13
|
var DEFAULT_COLORS = ["#ef4444", "#f97316", "#eab308", "#22c55e", "#06b6d4", "#3b82f6", "#a855f7"];
|
|
899
14
|
var DEFAULT_HISTORY = {
|
|
900
15
|
operations: [],
|
|
@@ -904,21 +19,17 @@ var DEFAULT_HISTORY = {
|
|
|
904
19
|
var createOperationId = () => `annotation-${Date.now()}-${Math.random().toString(36).slice(2, 9)}`;
|
|
905
20
|
var getCssSelector = (element) => {
|
|
906
21
|
if (element.id) {
|
|
907
|
-
return `#${
|
|
22
|
+
return `#${element.id}`;
|
|
908
23
|
}
|
|
909
24
|
const parts = [];
|
|
910
25
|
let current = element;
|
|
911
26
|
while (current && current.nodeType === Node.ELEMENT_NODE && current !== document.body) {
|
|
912
|
-
|
|
913
|
-
if (tag === "body" || tag === "html") {
|
|
914
|
-
break;
|
|
915
|
-
}
|
|
916
|
-
let part = tag;
|
|
27
|
+
let part = current.tagName.toLowerCase();
|
|
917
28
|
const className = current.className;
|
|
918
29
|
if (typeof className === "string") {
|
|
919
30
|
const firstClass = className.split(" ").map((value) => value.trim()).filter(Boolean)[0];
|
|
920
31
|
if (firstClass) {
|
|
921
|
-
part += `.${
|
|
32
|
+
part += `.${firstClass}`;
|
|
922
33
|
}
|
|
923
34
|
}
|
|
924
35
|
const parent = current.parentElement;
|
|
@@ -965,7 +76,7 @@ var createEditorImage = async (file) => {
|
|
|
965
76
|
width: element.naturalWidth || element.width
|
|
966
77
|
};
|
|
967
78
|
};
|
|
968
|
-
var
|
|
79
|
+
var canvasToFile = async (canvas, fileName = `feedback-${Date.now()}.png`) => {
|
|
969
80
|
const blob = await new Promise((resolve) => {
|
|
970
81
|
canvas.toBlob((nextBlob) => resolve(nextBlob), "image/png");
|
|
971
82
|
});
|
|
@@ -985,7 +96,7 @@ var waitForRenderedVideoFrame = async (video) => {
|
|
|
985
96
|
window.requestAnimationFrame(() => resolve());
|
|
986
97
|
});
|
|
987
98
|
};
|
|
988
|
-
var
|
|
99
|
+
var captureScreenshotFile = async (capturePolicy) => {
|
|
989
100
|
if (!navigator.mediaDevices?.getDisplayMedia) {
|
|
990
101
|
throw new Error("Browser does not support screen capture.");
|
|
991
102
|
}
|
|
@@ -1034,7 +145,7 @@ var captureScreenshotFile2 = async (capturePolicy) => {
|
|
|
1034
145
|
}
|
|
1035
146
|
context.drawImage(video, 0, 0, width, height);
|
|
1036
147
|
return {
|
|
1037
|
-
file: await
|
|
148
|
+
file: await canvasToFile(canvas),
|
|
1038
149
|
surface
|
|
1039
150
|
};
|
|
1040
151
|
} finally {
|
|
@@ -1137,6 +248,87 @@ var drawOperation = (context, operation) => {
|
|
|
1137
248
|
}
|
|
1138
249
|
};
|
|
1139
250
|
var isShapeMeaningful = (start, end) => Math.abs(end.x - start.x) > 3 || Math.abs(end.y - start.y) > 3;
|
|
251
|
+
function ChatIcon() {
|
|
252
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "22", height: "22", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }) });
|
|
253
|
+
}
|
|
254
|
+
function XIcon({ size = 18 }) {
|
|
255
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: size, height: size, viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
256
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
|
|
257
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
|
|
258
|
+
] });
|
|
259
|
+
}
|
|
260
|
+
function CameraIcon() {
|
|
261
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
262
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M23 19a2 2 0 0 1-2 2H3a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h4l2-3h6l2 3h4a2 2 0 0 1 2 2z" }),
|
|
263
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "12", cy: "13", r: "4" })
|
|
264
|
+
] });
|
|
265
|
+
}
|
|
266
|
+
function CursorIcon() {
|
|
267
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 4l7.07 17 2.51-7.39L21 11.07z" }) });
|
|
268
|
+
}
|
|
269
|
+
function UploadIcon() {
|
|
270
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
271
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "16 16 12 12 8 16" }),
|
|
272
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
|
|
273
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20.39 18.39A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.3" })
|
|
274
|
+
] });
|
|
275
|
+
}
|
|
276
|
+
function SendIcon() {
|
|
277
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
278
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
|
|
279
|
+
/* @__PURE__ */ jsxRuntime.jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
280
|
+
] });
|
|
281
|
+
}
|
|
282
|
+
function CheckCircleIcon() {
|
|
283
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
284
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M22 11.08V12a10 10 0 1 1-5.93-9.14" }),
|
|
285
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "22 4 12 14.01 9 11.01" })
|
|
286
|
+
] });
|
|
287
|
+
}
|
|
288
|
+
function PenIcon() {
|
|
289
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
290
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M12 19l7-7 3 3-7 7-3-3z" }),
|
|
291
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M18 13l-1.5-7.5L2 2l3.5 14.5L13 18l5-5z" }),
|
|
292
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M2 2l7.586 7.586" }),
|
|
293
|
+
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "2" })
|
|
294
|
+
] });
|
|
295
|
+
}
|
|
296
|
+
function RectIcon() {
|
|
297
|
+
return /* @__PURE__ */ jsxRuntime.jsx("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsxRuntime.jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "2", ry: "2" }) });
|
|
298
|
+
}
|
|
299
|
+
function ArrowIcon() {
|
|
300
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
301
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "5", y1: "19", x2: "19", y2: "5" }),
|
|
302
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "13 5 19 5 19 11" })
|
|
303
|
+
] });
|
|
304
|
+
}
|
|
305
|
+
function TextIcon() {
|
|
306
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
307
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "4 7 4 4 20 4 20 7" }),
|
|
308
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "9", y1: "20", x2: "15", y2: "20" }),
|
|
309
|
+
/* @__PURE__ */ jsxRuntime.jsx("line", { x1: "12", y1: "4", x2: "12", y2: "20" })
|
|
310
|
+
] });
|
|
311
|
+
}
|
|
312
|
+
function UndoIcon() {
|
|
313
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
314
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "9 14 4 9 9 4" }),
|
|
315
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M20 20v-7a4 4 0 0 0-4-4H4" })
|
|
316
|
+
] });
|
|
317
|
+
}
|
|
318
|
+
function RedoIcon() {
|
|
319
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
320
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "15 14 20 9 15 4" }),
|
|
321
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M4 20v-7a4 4 0 0 1 4-4h12" })
|
|
322
|
+
] });
|
|
323
|
+
}
|
|
324
|
+
function TrashIcon() {
|
|
325
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
326
|
+
/* @__PURE__ */ jsxRuntime.jsx("polyline", { points: "3 6 5 6 21 6" }),
|
|
327
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M19 6l-1 14H6L5 6" }),
|
|
328
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M10 11v6M14 11v6" }),
|
|
329
|
+
/* @__PURE__ */ jsxRuntime.jsx("path", { d: "M9 6V4h6v2" })
|
|
330
|
+
] });
|
|
331
|
+
}
|
|
1140
332
|
function FeedbackWidget({
|
|
1141
333
|
title = "Admin feedback",
|
|
1142
334
|
submitLabel = "Send",
|
|
@@ -1147,42 +339,57 @@ function FeedbackWidget({
|
|
|
1147
339
|
capturePolicy = "current-tab-first",
|
|
1148
340
|
onSubmit,
|
|
1149
341
|
onUpload,
|
|
1150
|
-
onDeleteScreenshot
|
|
1151
|
-
onDeleteFeedback,
|
|
1152
|
-
showHistory,
|
|
1153
|
-
currentUserId,
|
|
1154
|
-
onUpdateFeedback,
|
|
1155
|
-
history
|
|
342
|
+
onDeleteScreenshot
|
|
1156
343
|
}) {
|
|
1157
|
-
const [open, setOpen] =
|
|
1158
|
-
const [
|
|
1159
|
-
const [
|
|
1160
|
-
const [
|
|
1161
|
-
const [
|
|
1162
|
-
const [
|
|
1163
|
-
const [
|
|
1164
|
-
const [
|
|
1165
|
-
const [
|
|
1166
|
-
const [
|
|
1167
|
-
const [
|
|
1168
|
-
const [
|
|
1169
|
-
const [
|
|
1170
|
-
const [
|
|
1171
|
-
const [
|
|
1172
|
-
const [
|
|
1173
|
-
const [
|
|
1174
|
-
const [
|
|
1175
|
-
const [
|
|
1176
|
-
const [
|
|
1177
|
-
const [
|
|
1178
|
-
const
|
|
1179
|
-
const
|
|
1180
|
-
const
|
|
1181
|
-
const
|
|
1182
|
-
|
|
344
|
+
const [open, setOpen] = React__default.default.useState(false);
|
|
345
|
+
const [message, setMessage] = React__default.default.useState("");
|
|
346
|
+
const [captureMode, setCaptureMode] = React__default.default.useState(false);
|
|
347
|
+
const [captureData, setCaptureData] = React__default.default.useState(null);
|
|
348
|
+
const [screenshotId, setScreenshotId] = React__default.default.useState(null);
|
|
349
|
+
const [screenshotPreviewUrl, setScreenshotPreviewUrl] = React__default.default.useState(null);
|
|
350
|
+
const [uploading, setUploading] = React__default.default.useState(false);
|
|
351
|
+
const [deletingScreenshot, setDeletingScreenshot] = React__default.default.useState(false);
|
|
352
|
+
const [submitting, setSubmitting] = React__default.default.useState(false);
|
|
353
|
+
const [submitted, setSubmitted] = React__default.default.useState(false);
|
|
354
|
+
const [currentPath, setCurrentPath] = React__default.default.useState("");
|
|
355
|
+
const [capturingScreen, setCapturingScreen] = React__default.default.useState(false);
|
|
356
|
+
const [error, setError] = React__default.default.useState(null);
|
|
357
|
+
const [notice, setNotice] = React__default.default.useState(null);
|
|
358
|
+
const [annotating, setAnnotating] = React__default.default.useState(false);
|
|
359
|
+
const [editorImage, setEditorImage] = React__default.default.useState(null);
|
|
360
|
+
const [editorHistory, setEditorHistory] = React__default.default.useState(DEFAULT_HISTORY);
|
|
361
|
+
const [draftOperation, setDraftOperation] = React__default.default.useState(null);
|
|
362
|
+
const [annotationTool, setAnnotationTool] = React__default.default.useState("pen");
|
|
363
|
+
const [annotationColor, setAnnotationColor] = React__default.default.useState(DEFAULT_COLORS[0]);
|
|
364
|
+
const [annotationSize, setAnnotationSize] = React__default.default.useState(4);
|
|
365
|
+
const [textCursor, setTextCursor] = React__default.default.useState(null);
|
|
366
|
+
const [inlineText, setInlineText] = React__default.default.useState("");
|
|
367
|
+
const hoverTargetRef = React__default.default.useRef(null);
|
|
368
|
+
const annotationCanvasRef = React__default.default.useRef(null);
|
|
369
|
+
const annotationScrollRef = React__default.default.useRef(null);
|
|
370
|
+
const textInputRef = React__default.default.useRef(null);
|
|
371
|
+
const pointerIdRef = React__default.default.useRef(null);
|
|
372
|
+
const draftOperationRef = React__default.default.useRef(null);
|
|
373
|
+
const inlineTextRef = React__default.default.useRef("");
|
|
374
|
+
const textCursorRef = React__default.default.useRef(null);
|
|
375
|
+
const annotationColorRef = React__default.default.useRef(DEFAULT_COLORS[0]);
|
|
376
|
+
const annotationSizeRef = React__default.default.useRef(4);
|
|
377
|
+
React__default.default.useEffect(() => {
|
|
1183
378
|
draftOperationRef.current = draftOperation;
|
|
1184
379
|
}, [draftOperation]);
|
|
1185
|
-
|
|
380
|
+
React__default.default.useEffect(() => {
|
|
381
|
+
inlineTextRef.current = inlineText;
|
|
382
|
+
}, [inlineText]);
|
|
383
|
+
React__default.default.useEffect(() => {
|
|
384
|
+
textCursorRef.current = textCursor;
|
|
385
|
+
}, [textCursor]);
|
|
386
|
+
React__default.default.useEffect(() => {
|
|
387
|
+
annotationColorRef.current = annotationColor;
|
|
388
|
+
}, [annotationColor]);
|
|
389
|
+
React__default.default.useEffect(() => {
|
|
390
|
+
annotationSizeRef.current = annotationSize;
|
|
391
|
+
}, [annotationSize]);
|
|
392
|
+
React__default.default.useEffect(() => {
|
|
1186
393
|
if (!captureMode) {
|
|
1187
394
|
return;
|
|
1188
395
|
}
|
|
@@ -1225,7 +432,7 @@ function FeedbackWidget({
|
|
|
1225
432
|
document.removeEventListener("click", onClick, true);
|
|
1226
433
|
};
|
|
1227
434
|
}, [captureMode]);
|
|
1228
|
-
|
|
435
|
+
React__default.default.useEffect(() => {
|
|
1229
436
|
if (!annotating) {
|
|
1230
437
|
return;
|
|
1231
438
|
}
|
|
@@ -1235,7 +442,7 @@ function FeedbackWidget({
|
|
|
1235
442
|
document.body.style.overflow = previousOverflow;
|
|
1236
443
|
};
|
|
1237
444
|
}, [annotating]);
|
|
1238
|
-
|
|
445
|
+
React__default.default.useEffect(() => {
|
|
1239
446
|
if (!annotating || !editorImage || !annotationCanvasRef.current) {
|
|
1240
447
|
return;
|
|
1241
448
|
}
|
|
@@ -1256,7 +463,18 @@ function FeedbackWidget({
|
|
|
1256
463
|
drawOperation(context, draftOperation);
|
|
1257
464
|
}
|
|
1258
465
|
}, [annotating, draftOperation, editorHistory.operations, editorImage]);
|
|
1259
|
-
|
|
466
|
+
React__default.default.useEffect(() => {
|
|
467
|
+
setCurrentPath(window.location.pathname);
|
|
468
|
+
}, []);
|
|
469
|
+
React__default.default.useEffect(() => {
|
|
470
|
+
if (!submitted) return;
|
|
471
|
+
const timer = setTimeout(() => {
|
|
472
|
+
setOpen(false);
|
|
473
|
+
setSubmitted(false);
|
|
474
|
+
}, 2500);
|
|
475
|
+
return () => clearTimeout(timer);
|
|
476
|
+
}, [submitted]);
|
|
477
|
+
const validateImageFile = React__default.default.useCallback(
|
|
1260
478
|
(file) => {
|
|
1261
479
|
if (!screenshotAllowedMimeTypes.includes(file.type)) {
|
|
1262
480
|
return `Supported image types: ${screenshotAllowedMimeTypes.join(", ")}`;
|
|
@@ -1268,7 +486,7 @@ function FeedbackWidget({
|
|
|
1268
486
|
},
|
|
1269
487
|
[screenshotAllowedMimeTypes, screenshotMaxFileSizeBytes]
|
|
1270
488
|
);
|
|
1271
|
-
const uploadImageFile =
|
|
489
|
+
const uploadImageFile = React__default.default.useCallback(
|
|
1272
490
|
async (file) => {
|
|
1273
491
|
if (!onUpload) {
|
|
1274
492
|
return false;
|
|
@@ -1293,14 +511,16 @@ function FeedbackWidget({
|
|
|
1293
511
|
},
|
|
1294
512
|
[onUpload]
|
|
1295
513
|
);
|
|
1296
|
-
const closeAnnotationEditor =
|
|
514
|
+
const closeAnnotationEditor = React__default.default.useCallback(() => {
|
|
1297
515
|
setAnnotating(false);
|
|
1298
516
|
setEditorImage(null);
|
|
1299
517
|
setEditorHistory(DEFAULT_HISTORY);
|
|
1300
518
|
setDraftOperation(null);
|
|
519
|
+
setTextCursor(null);
|
|
520
|
+
setInlineText("");
|
|
1301
521
|
draftOperationRef.current = null;
|
|
1302
522
|
}, []);
|
|
1303
|
-
const handleStartAnnotation =
|
|
523
|
+
const handleStartAnnotation = React__default.default.useCallback(
|
|
1304
524
|
async (file) => {
|
|
1305
525
|
const validationError = validateImageFile(file);
|
|
1306
526
|
if (validationError) {
|
|
@@ -1312,6 +532,8 @@ function FeedbackWidget({
|
|
|
1312
532
|
setEditorImage(nextImage);
|
|
1313
533
|
setEditorHistory(DEFAULT_HISTORY);
|
|
1314
534
|
setDraftOperation(null);
|
|
535
|
+
setTextCursor(null);
|
|
536
|
+
setInlineText("");
|
|
1315
537
|
draftOperationRef.current = null;
|
|
1316
538
|
setAnnotating(true);
|
|
1317
539
|
setError(null);
|
|
@@ -1321,7 +543,7 @@ function FeedbackWidget({
|
|
|
1321
543
|
},
|
|
1322
544
|
[validateImageFile]
|
|
1323
545
|
);
|
|
1324
|
-
|
|
546
|
+
React__default.default.useEffect(() => {
|
|
1325
547
|
if (!open || !allowScreenshotUpload) {
|
|
1326
548
|
return;
|
|
1327
549
|
}
|
|
@@ -1336,51 +558,37 @@ function FeedbackWidget({
|
|
|
1336
558
|
window.addEventListener("paste", onPaste);
|
|
1337
559
|
return () => window.removeEventListener("paste", onPaste);
|
|
1338
560
|
}, [allowScreenshotUpload, handleStartAnnotation, open]);
|
|
1339
|
-
const
|
|
1340
|
-
async (id) => {
|
|
1341
|
-
const found = history?.feedbacks.find((f) => f.id === id);
|
|
1342
|
-
if (found) {
|
|
1343
|
-
setSelectedFeedback(found);
|
|
1344
|
-
setView("detail");
|
|
1345
|
-
return;
|
|
1346
|
-
}
|
|
1347
|
-
try {
|
|
1348
|
-
const res = await fetch(`/api/admin-feedback/${id}?depth=2`, { credentials: "include" });
|
|
1349
|
-
if (res.ok) {
|
|
1350
|
-
const data = await res.json();
|
|
1351
|
-
setSelectedFeedback(data);
|
|
1352
|
-
setView("detail");
|
|
1353
|
-
}
|
|
1354
|
-
} catch {
|
|
1355
|
-
}
|
|
1356
|
-
},
|
|
1357
|
-
[history?.feedbacks]
|
|
1358
|
-
);
|
|
1359
|
-
React2__default.default.useEffect(() => {
|
|
1360
|
-
const handler = (e) => {
|
|
1361
|
-
const detail = e.detail;
|
|
1362
|
-
if (detail?.feedbackId) {
|
|
1363
|
-
setOpen(true);
|
|
1364
|
-
handleSelectFeedback(detail.feedbackId);
|
|
1365
|
-
}
|
|
1366
|
-
};
|
|
1367
|
-
window.addEventListener("feedback:show-detail", handler);
|
|
1368
|
-
return () => window.removeEventListener("feedback:show-detail", handler);
|
|
1369
|
-
}, [handleSelectFeedback]);
|
|
1370
|
-
const commitOperations = React2__default.default.useCallback((nextOperations) => {
|
|
561
|
+
const commitOperations = React__default.default.useCallback((nextOperations) => {
|
|
1371
562
|
setEditorHistory((current) => ({
|
|
1372
563
|
operations: nextOperations,
|
|
1373
564
|
redoStack: [],
|
|
1374
565
|
undoStack: [...current.undoStack, current.operations]
|
|
1375
566
|
}));
|
|
1376
567
|
}, []);
|
|
1377
|
-
const appendOperation =
|
|
568
|
+
const appendOperation = React__default.default.useCallback((operation) => {
|
|
1378
569
|
setEditorHistory((current) => ({
|
|
1379
570
|
operations: [...current.operations, operation],
|
|
1380
571
|
redoStack: [],
|
|
1381
572
|
undoStack: [...current.undoStack, current.operations]
|
|
1382
573
|
}));
|
|
1383
574
|
}, []);
|
|
575
|
+
const commitTextInput = React__default.default.useCallback(() => {
|
|
576
|
+
const text = inlineTextRef.current.trim();
|
|
577
|
+
const cursor = textCursorRef.current;
|
|
578
|
+
if (text && cursor) {
|
|
579
|
+
const operation = {
|
|
580
|
+
id: createOperationId(),
|
|
581
|
+
type: "text",
|
|
582
|
+
style: { color: annotationColorRef.current, size: annotationSizeRef.current },
|
|
583
|
+
point: cursor.canvasPoint,
|
|
584
|
+
text
|
|
585
|
+
};
|
|
586
|
+
appendOperation(operation);
|
|
587
|
+
}
|
|
588
|
+
textCursorRef.current = null;
|
|
589
|
+
setTextCursor(null);
|
|
590
|
+
setInlineText("");
|
|
591
|
+
}, [appendOperation]);
|
|
1384
592
|
const handleUpload = async (event) => {
|
|
1385
593
|
const file = event.target.files?.[0];
|
|
1386
594
|
if (file) {
|
|
@@ -1391,7 +599,9 @@ function FeedbackWidget({
|
|
|
1391
599
|
const handleCaptureScreenshot = async () => {
|
|
1392
600
|
try {
|
|
1393
601
|
setError(null);
|
|
1394
|
-
|
|
602
|
+
setCapturingScreen(true);
|
|
603
|
+
await new Promise((resolve) => setTimeout(resolve, 120));
|
|
604
|
+
const { file, surface } = await captureScreenshotFile(capturePolicy);
|
|
1395
605
|
if (capturePolicy === "current-tab-first") {
|
|
1396
606
|
if (surface === "browser") {
|
|
1397
607
|
setNotice("Captured the current tab.");
|
|
@@ -1408,6 +618,8 @@ function FeedbackWidget({
|
|
|
1408
618
|
await handleStartAnnotation(file);
|
|
1409
619
|
} catch (nextError) {
|
|
1410
620
|
setError(nextError instanceof Error ? nextError.message : "Screen capture failed.");
|
|
621
|
+
} finally {
|
|
622
|
+
setCapturingScreen(false);
|
|
1411
623
|
}
|
|
1412
624
|
};
|
|
1413
625
|
const handleUndo = () => {
|
|
@@ -1442,42 +654,31 @@ function FeedbackWidget({
|
|
|
1442
654
|
}
|
|
1443
655
|
commitOperations([]);
|
|
1444
656
|
};
|
|
1445
|
-
const handleRevertLastAnnotation = () => {
|
|
1446
|
-
setDraftOperation(null);
|
|
1447
|
-
draftOperationRef.current = null;
|
|
1448
|
-
pointerIdRef.current = null;
|
|
1449
|
-
setEditorHistory((current) => {
|
|
1450
|
-
if (current.operations.length === 0) {
|
|
1451
|
-
return current;
|
|
1452
|
-
}
|
|
1453
|
-
return {
|
|
1454
|
-
operations: current.operations.slice(0, -1),
|
|
1455
|
-
redoStack: [],
|
|
1456
|
-
undoStack: [...current.undoStack, current.operations]
|
|
1457
|
-
};
|
|
1458
|
-
});
|
|
1459
|
-
};
|
|
1460
657
|
const handleCanvasPointerDown = (event) => {
|
|
1461
658
|
if (!annotationCanvasRef.current) {
|
|
1462
659
|
return;
|
|
1463
660
|
}
|
|
1464
661
|
setError(null);
|
|
1465
662
|
const canvas = annotationCanvasRef.current;
|
|
1466
|
-
const
|
|
663
|
+
const canvasPoint = getCanvasPoint(event, canvas);
|
|
1467
664
|
if (annotationTool === "text") {
|
|
1468
|
-
const
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
665
|
+
const existingText = inlineTextRef.current.trim();
|
|
666
|
+
const existingCursor = textCursorRef.current;
|
|
667
|
+
if (existingText && existingCursor) {
|
|
668
|
+
appendOperation({
|
|
669
|
+
id: createOperationId(),
|
|
670
|
+
type: "text",
|
|
671
|
+
style: { color: annotationColorRef.current, size: annotationSizeRef.current },
|
|
672
|
+
point: existingCursor.canvasPoint,
|
|
673
|
+
text: existingText
|
|
674
|
+
});
|
|
1472
675
|
}
|
|
1473
|
-
const
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
};
|
|
1480
|
-
appendOperation(operation);
|
|
676
|
+
const domX = event.clientX;
|
|
677
|
+
const domY = event.clientY;
|
|
678
|
+
inlineTextRef.current = "";
|
|
679
|
+
textCursorRef.current = { domX, domY, canvasPoint };
|
|
680
|
+
setInlineText("");
|
|
681
|
+
setTextCursor({ domX, domY, canvasPoint });
|
|
1481
682
|
return;
|
|
1482
683
|
}
|
|
1483
684
|
event.preventDefault();
|
|
@@ -1488,19 +689,19 @@ function FeedbackWidget({
|
|
|
1488
689
|
id: createOperationId(),
|
|
1489
690
|
type: "pen",
|
|
1490
691
|
style,
|
|
1491
|
-
points: [
|
|
692
|
+
points: [canvasPoint]
|
|
1492
693
|
} : annotationTool === "rectangle" ? {
|
|
1493
694
|
id: createOperationId(),
|
|
1494
695
|
type: "rectangle",
|
|
1495
696
|
style,
|
|
1496
|
-
start:
|
|
1497
|
-
end:
|
|
697
|
+
start: canvasPoint,
|
|
698
|
+
end: canvasPoint
|
|
1498
699
|
} : {
|
|
1499
700
|
id: createOperationId(),
|
|
1500
701
|
type: "arrow",
|
|
1501
702
|
style,
|
|
1502
|
-
start:
|
|
1503
|
-
end:
|
|
703
|
+
start: canvasPoint,
|
|
704
|
+
end: canvasPoint
|
|
1504
705
|
};
|
|
1505
706
|
draftOperationRef.current = nextDraft;
|
|
1506
707
|
setDraftOperation(nextDraft);
|
|
@@ -1563,7 +764,7 @@ function FeedbackWidget({
|
|
|
1563
764
|
}
|
|
1564
765
|
try {
|
|
1565
766
|
const previewUrl = annotationCanvasRef.current.toDataURL("image/png");
|
|
1566
|
-
const file = await
|
|
767
|
+
const file = await canvasToFile(annotationCanvasRef.current, editorImage.fileName);
|
|
1567
768
|
const uploaded = await uploadImageFile(file);
|
|
1568
769
|
if (uploaded) {
|
|
1569
770
|
setScreenshotPreviewUrl(previewUrl);
|
|
@@ -1607,7 +808,7 @@ function FeedbackWidget({
|
|
|
1607
808
|
setError(null);
|
|
1608
809
|
const result = await onSubmit({
|
|
1609
810
|
message: message.trim(),
|
|
1610
|
-
pagePath:
|
|
811
|
+
pagePath: currentPath,
|
|
1611
812
|
selector: captureData?.selector,
|
|
1612
813
|
selectedText: captureData?.selectedText,
|
|
1613
814
|
screenshotId,
|
|
@@ -1627,92 +828,235 @@ function FeedbackWidget({
|
|
|
1627
828
|
setScreenshotId(null);
|
|
1628
829
|
setScreenshotPreviewUrl(null);
|
|
1629
830
|
setNotice(null);
|
|
1630
|
-
|
|
1631
|
-
setOpen(false);
|
|
831
|
+
setSubmitted(true);
|
|
1632
832
|
};
|
|
1633
833
|
const currentHasUndo = editorHistory.undoStack.length > 0;
|
|
1634
834
|
const currentHasRedo = editorHistory.redoStack.length > 0;
|
|
1635
835
|
const hasAnnotations = editorHistory.operations.length > 0;
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
836
|
+
const toolBtn = (tool, icon, label) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
837
|
+
"button",
|
|
838
|
+
{
|
|
839
|
+
type: "button",
|
|
840
|
+
title: label,
|
|
841
|
+
onClick: () => setAnnotationTool(tool),
|
|
842
|
+
style: {
|
|
843
|
+
display: "flex",
|
|
844
|
+
alignItems: "center",
|
|
845
|
+
gap: "5px",
|
|
846
|
+
borderRadius: "6px",
|
|
847
|
+
border: annotationTool === tool ? "1px solid #4ade80" : "1px solid #334155",
|
|
848
|
+
background: annotationTool === tool ? "rgba(74,222,128,0.12)" : "#0f172a",
|
|
849
|
+
color: annotationTool === tool ? "#4ade80" : "#94a3b8",
|
|
850
|
+
padding: "5px 9px",
|
|
851
|
+
cursor: "pointer",
|
|
852
|
+
fontSize: "12px",
|
|
853
|
+
fontWeight: 500
|
|
854
|
+
},
|
|
855
|
+
children: [
|
|
856
|
+
icon,
|
|
857
|
+
label
|
|
858
|
+
]
|
|
859
|
+
},
|
|
860
|
+
tool
|
|
861
|
+
);
|
|
862
|
+
const iconBtn = (onClick, icon, label, disabled = false) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
863
|
+
"button",
|
|
864
|
+
{
|
|
865
|
+
type: "button",
|
|
866
|
+
title: label,
|
|
867
|
+
onClick,
|
|
868
|
+
disabled,
|
|
869
|
+
style: {
|
|
870
|
+
display: "flex",
|
|
871
|
+
alignItems: "center",
|
|
872
|
+
gap: "4px",
|
|
873
|
+
borderRadius: "6px",
|
|
874
|
+
border: "1px solid #334155",
|
|
875
|
+
background: "#0f172a",
|
|
876
|
+
color: disabled ? "#475569" : "#94a3b8",
|
|
877
|
+
padding: "5px 9px",
|
|
878
|
+
cursor: disabled ? "not-allowed" : "pointer",
|
|
879
|
+
fontSize: "12px"
|
|
880
|
+
},
|
|
881
|
+
children: [
|
|
882
|
+
icon,
|
|
883
|
+
label
|
|
884
|
+
]
|
|
885
|
+
}
|
|
886
|
+
);
|
|
1644
887
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1645
|
-
/* @__PURE__ */ jsxRuntime.
|
|
888
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
889
|
+
@keyframes afb-spin-in {
|
|
890
|
+
from { transform: rotate(-90deg) scale(0.7); opacity: 0; }
|
|
891
|
+
to { transform: rotate(0deg) scale(1); opacity: 1; }
|
|
892
|
+
}
|
|
893
|
+
.afb-icon-enter {
|
|
894
|
+
animation: afb-spin-in 0.18s ease forwards;
|
|
895
|
+
}
|
|
896
|
+
` }),
|
|
897
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1646
898
|
"button",
|
|
1647
899
|
{
|
|
1648
900
|
type: "button",
|
|
1649
901
|
onClick: () => {
|
|
1650
|
-
|
|
1651
|
-
|
|
902
|
+
if (submitted) return;
|
|
903
|
+
setOpen((v) => !v);
|
|
1652
904
|
},
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
"
|
|
1657
|
-
|
|
905
|
+
title: open ? "Close feedback" : "Send feedback",
|
|
906
|
+
style: {
|
|
907
|
+
position: "fixed",
|
|
908
|
+
right: "20px",
|
|
909
|
+
bottom: "20px",
|
|
910
|
+
zIndex: 9999,
|
|
911
|
+
width: "48px",
|
|
912
|
+
height: "48px",
|
|
913
|
+
borderRadius: "50%",
|
|
914
|
+
backgroundColor: open ? "#374151" : "#15803d",
|
|
915
|
+
color: "#ffffff",
|
|
916
|
+
border: "none",
|
|
917
|
+
display: "flex",
|
|
918
|
+
alignItems: "center",
|
|
919
|
+
justifyContent: "center",
|
|
920
|
+
cursor: "pointer",
|
|
921
|
+
boxShadow: "0 4px 14px rgba(0,0,0,0.4)",
|
|
922
|
+
transition: "background-color 0.2s ease, transform 0.15s ease",
|
|
923
|
+
visibility: capturingScreen ? "hidden" : "visible"
|
|
924
|
+
},
|
|
925
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "afb-icon-enter", children: open ? /* @__PURE__ */ jsxRuntime.jsx(XIcon, { size: 20 }) : /* @__PURE__ */ jsxRuntime.jsx(ChatIcon, {}) }, open ? "x" : "chat")
|
|
1658
926
|
}
|
|
1659
927
|
),
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
928
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
929
|
+
"div",
|
|
930
|
+
{
|
|
931
|
+
style: {
|
|
932
|
+
position: "fixed",
|
|
933
|
+
right: "20px",
|
|
934
|
+
bottom: "80px",
|
|
935
|
+
width: "360px",
|
|
936
|
+
background: "#0f172a",
|
|
937
|
+
color: "#f1f5f9",
|
|
938
|
+
borderRadius: "14px",
|
|
939
|
+
border: "1px solid #1e293b",
|
|
940
|
+
padding: "0",
|
|
941
|
+
zIndex: 9999,
|
|
942
|
+
boxShadow: "0 16px 48px rgba(0,0,0,0.55)",
|
|
943
|
+
display: "flex",
|
|
944
|
+
flexDirection: "column",
|
|
945
|
+
maxHeight: "calc(100vh - 110px)",
|
|
946
|
+
opacity: open ? 1 : 0,
|
|
947
|
+
transform: open ? "scale(1) translateY(0)" : "scale(0.92) translateY(8px)",
|
|
948
|
+
pointerEvents: open ? "auto" : "none",
|
|
949
|
+
transformOrigin: "bottom right",
|
|
950
|
+
transition: "opacity 0.18s ease, transform 0.18s ease",
|
|
951
|
+
visibility: capturingScreen ? "hidden" : "visible",
|
|
952
|
+
overflow: "hidden"
|
|
953
|
+
},
|
|
954
|
+
children: submitted ? (
|
|
955
|
+
/* ── Success screen ── */
|
|
956
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
957
|
+
"div",
|
|
958
|
+
{
|
|
959
|
+
style: {
|
|
960
|
+
display: "flex",
|
|
961
|
+
flexDirection: "column",
|
|
962
|
+
alignItems: "center",
|
|
963
|
+
justifyContent: "center",
|
|
964
|
+
gap: "12px",
|
|
965
|
+
padding: "40px 24px",
|
|
966
|
+
textAlign: "center",
|
|
967
|
+
color: "#4ade80"
|
|
968
|
+
},
|
|
969
|
+
children: [
|
|
970
|
+
/* @__PURE__ */ jsxRuntime.jsx(CheckCircleIcon, {}),
|
|
971
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
972
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "0 0 4px", fontSize: "16px", fontWeight: 600, color: "#f1f5f9" }, children: "Feedback sent!" }),
|
|
973
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "13px", color: "#94a3b8" }, children: "Thank you \u2014 we'll take a look." })
|
|
974
|
+
] })
|
|
975
|
+
]
|
|
976
|
+
}
|
|
977
|
+
)
|
|
978
|
+
) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
979
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
980
|
+
"div",
|
|
981
|
+
{
|
|
982
|
+
style: {
|
|
983
|
+
display: "flex",
|
|
984
|
+
alignItems: "center",
|
|
985
|
+
justifyContent: "space-between",
|
|
986
|
+
padding: "12px 14px 10px",
|
|
987
|
+
borderBottom: "1px solid #1e293b"
|
|
988
|
+
},
|
|
989
|
+
children: [
|
|
990
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
991
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "14px", fontWeight: 600, color: "#f1f5f9" }, children: title }),
|
|
992
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "2px 0 0", fontSize: "11px", color: "#64748b" }, children: currentPath })
|
|
993
|
+
] }),
|
|
994
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
995
|
+
"button",
|
|
996
|
+
{
|
|
997
|
+
type: "button",
|
|
998
|
+
onClick: () => setOpen(false),
|
|
999
|
+
title: "Close",
|
|
1000
|
+
style: {
|
|
1001
|
+
background: "none",
|
|
1002
|
+
border: "none",
|
|
1003
|
+
color: "#64748b",
|
|
1004
|
+
cursor: "pointer",
|
|
1005
|
+
padding: "4px",
|
|
1006
|
+
display: "flex",
|
|
1007
|
+
alignItems: "center",
|
|
1008
|
+
borderRadius: "6px"
|
|
1009
|
+
},
|
|
1010
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(XIcon, { size: 16 })
|
|
1011
|
+
}
|
|
1012
|
+
)
|
|
1013
|
+
]
|
|
1014
|
+
}
|
|
1015
|
+
),
|
|
1016
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { padding: "12px 14px", display: "flex", flexDirection: "column", gap: "10px", overflowY: "auto", minHeight: 0 }, children: [
|
|
1017
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1018
|
+
"textarea",
|
|
1019
|
+
{
|
|
1020
|
+
value: message,
|
|
1021
|
+
onChange: (event) => setMessage(event.target.value),
|
|
1022
|
+
rows: 5,
|
|
1023
|
+
placeholder: "Describe the issue or share your thoughts\u2026",
|
|
1024
|
+
style: {
|
|
1025
|
+
width: "100%",
|
|
1026
|
+
borderRadius: "8px",
|
|
1027
|
+
border: "1px solid #1e293b",
|
|
1028
|
+
background: "#1e293b",
|
|
1029
|
+
color: "#f1f5f9",
|
|
1030
|
+
padding: "10px",
|
|
1031
|
+
resize: "vertical",
|
|
1032
|
+
fontSize: "13px",
|
|
1033
|
+
lineHeight: "1.5",
|
|
1034
|
+
outline: "none",
|
|
1035
|
+
boxSizing: "border-box"
|
|
1692
1036
|
}
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
),
|
|
1697
|
-
showHistory ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1698
|
-
"div",
|
|
1699
|
-
{
|
|
1700
|
-
style: {
|
|
1701
|
-
...surfaceCardStyle,
|
|
1702
|
-
padding: "5px",
|
|
1703
|
-
display: "flex",
|
|
1704
|
-
gap: "6px"
|
|
1705
|
-
},
|
|
1706
|
-
children: [
|
|
1037
|
+
}
|
|
1038
|
+
),
|
|
1039
|
+
allowScreenshotUpload && onUpload ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" }, children: [
|
|
1707
1040
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1708
1041
|
"button",
|
|
1709
1042
|
{
|
|
1710
1043
|
type: "button",
|
|
1711
|
-
onClick:
|
|
1712
|
-
style: {
|
|
1044
|
+
onClick: handleCaptureScreenshot,
|
|
1045
|
+
style: {
|
|
1046
|
+
display: "flex",
|
|
1047
|
+
alignItems: "center",
|
|
1048
|
+
gap: "5px",
|
|
1049
|
+
borderRadius: "7px",
|
|
1050
|
+
border: "1px solid #1e293b",
|
|
1051
|
+
background: "#1e293b",
|
|
1052
|
+
color: "#94a3b8",
|
|
1053
|
+
padding: "5px 9px",
|
|
1054
|
+
cursor: "pointer",
|
|
1055
|
+
fontSize: "12px"
|
|
1056
|
+
},
|
|
1713
1057
|
children: [
|
|
1714
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1715
|
-
"
|
|
1058
|
+
/* @__PURE__ */ jsxRuntime.jsx(CameraIcon, {}),
|
|
1059
|
+
"Capture screen"
|
|
1716
1060
|
]
|
|
1717
1061
|
}
|
|
1718
1062
|
),
|
|
@@ -1720,311 +1064,186 @@ function FeedbackWidget({
|
|
|
1720
1064
|
"button",
|
|
1721
1065
|
{
|
|
1722
1066
|
type: "button",
|
|
1723
|
-
onClick: () =>
|
|
1724
|
-
style: {
|
|
1725
|
-
...buttonStyle("secondary", {
|
|
1726
|
-
active: view === "history" || view === "detail",
|
|
1727
|
-
compact: true
|
|
1728
|
-
}),
|
|
1729
|
-
flex: 1
|
|
1730
|
-
},
|
|
1731
|
-
children: [
|
|
1732
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.History, { size: 15 }),
|
|
1733
|
-
"History"
|
|
1734
|
-
]
|
|
1735
|
-
}
|
|
1736
|
-
)
|
|
1737
|
-
]
|
|
1738
|
-
}
|
|
1739
|
-
) : null
|
|
1740
|
-
] }),
|
|
1741
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1742
|
-
"div",
|
|
1743
|
-
{
|
|
1744
|
-
style: {
|
|
1745
|
-
padding: "14px",
|
|
1746
|
-
display: "grid",
|
|
1747
|
-
gap: "10px",
|
|
1748
|
-
flex: 1,
|
|
1749
|
-
minHeight: 0,
|
|
1750
|
-
overflowY: "auto",
|
|
1751
|
-
overflowX: "hidden"
|
|
1752
|
-
},
|
|
1753
|
-
children: view === "form" ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1754
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "14px" }, children: [
|
|
1755
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1756
|
-
"div",
|
|
1757
|
-
{
|
|
1067
|
+
onClick: () => setCaptureMode((v) => !v),
|
|
1758
1068
|
style: {
|
|
1759
1069
|
display: "flex",
|
|
1760
|
-
alignItems: "
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1070
|
+
alignItems: "center",
|
|
1071
|
+
gap: "5px",
|
|
1072
|
+
borderRadius: "7px",
|
|
1073
|
+
border: captureMode ? "1px solid #4ade80" : "1px solid #1e293b",
|
|
1074
|
+
background: captureMode ? "rgba(74,222,128,0.08)" : "#1e293b",
|
|
1075
|
+
color: captureMode ? "#4ade80" : "#94a3b8",
|
|
1076
|
+
padding: "5px 9px",
|
|
1077
|
+
cursor: "pointer",
|
|
1078
|
+
fontSize: "12px"
|
|
1765
1079
|
},
|
|
1766
1080
|
children: [
|
|
1767
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1768
|
-
|
|
1769
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: "4px 0 0", fontSize: "13px", lineHeight: 1.5, color: theme.textSoft }, children: "Describe the issue, attach context, and send it with the current page path." })
|
|
1770
|
-
] }),
|
|
1771
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: { ...pillStyle("neutral"), maxWidth: "100%", overflow: "hidden" }, children: [
|
|
1772
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MapPin, { size: 12 }),
|
|
1773
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1774
|
-
"span",
|
|
1775
|
-
{
|
|
1776
|
-
style: {
|
|
1777
|
-
overflow: "hidden",
|
|
1778
|
-
textOverflow: "ellipsis",
|
|
1779
|
-
whiteSpace: "nowrap",
|
|
1780
|
-
display: "inline-block"
|
|
1781
|
-
},
|
|
1782
|
-
children: currentPath
|
|
1783
|
-
}
|
|
1784
|
-
)
|
|
1785
|
-
] })
|
|
1081
|
+
/* @__PURE__ */ jsxRuntime.jsx(CursorIcon, {}),
|
|
1082
|
+
captureMode ? "Click an element\u2026" : "Capture element"
|
|
1786
1083
|
]
|
|
1787
1084
|
}
|
|
1788
1085
|
),
|
|
1789
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1790
|
-
"textarea",
|
|
1791
|
-
{
|
|
1792
|
-
value: message,
|
|
1793
|
-
onChange: (event) => setMessage(event.target.value),
|
|
1794
|
-
rows: 5,
|
|
1795
|
-
placeholder: "Describe the issue, the expected behavior, and what you were doing...",
|
|
1796
|
-
style: { ...fieldStyle, resize: "vertical", minHeight: "116px" }
|
|
1797
|
-
}
|
|
1798
|
-
)
|
|
1799
|
-
] }),
|
|
1800
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "14px" }, children: [
|
|
1801
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { marginBottom: "10px" }, children: [
|
|
1802
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: sectionLabelStyle, children: "Context and attachments" }),
|
|
1803
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...metaTextStyle, marginTop: "4px" }, children: "Paste an image with Ctrl/Cmd+V or attach a screenshot from the current tab." })
|
|
1804
|
-
] }),
|
|
1805
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: [
|
|
1806
|
-
canManageScreenshots ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1807
|
-
"button",
|
|
1808
|
-
{
|
|
1809
|
-
type: "button",
|
|
1810
|
-
onClick: handleCaptureScreenshot,
|
|
1811
|
-
"aria-label": "Capture screen",
|
|
1812
|
-
title: "Capture screen",
|
|
1813
|
-
style: buttonStyle("secondary", { compact: true, iconOnly: true }),
|
|
1814
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Camera, { size: 15 })
|
|
1815
|
-
}
|
|
1816
|
-
) : null,
|
|
1817
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1818
|
-
"button",
|
|
1819
|
-
{
|
|
1820
|
-
type: "button",
|
|
1821
|
-
onClick: () => setCaptureMode((value) => !value),
|
|
1822
|
-
"aria-label": captureMode ? "Capture element: click target" : "Capture element",
|
|
1823
|
-
title: captureMode ? "Capture element: click target" : "Capture element",
|
|
1824
|
-
style: buttonStyle("secondary", { compact: true, active: captureMode, iconOnly: true }),
|
|
1825
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.MousePointerClick, { size: 15 })
|
|
1826
|
-
}
|
|
1827
|
-
),
|
|
1828
|
-
canManageScreenshots ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1829
|
-
"label",
|
|
1830
|
-
{
|
|
1831
|
-
"aria-label": uploading ? "Uploading image" : uploadLabel,
|
|
1832
|
-
title: uploading ? "Uploading image" : uploadLabel,
|
|
1833
|
-
style: buttonStyle("secondary", { compact: true, iconOnly: true }),
|
|
1834
|
-
children: [
|
|
1835
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Upload, { size: 15 }),
|
|
1836
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1837
|
-
"input",
|
|
1838
|
-
{
|
|
1839
|
-
type: "file",
|
|
1840
|
-
accept: screenshotAllowedMimeTypes.join(","),
|
|
1841
|
-
onChange: handleUpload,
|
|
1842
|
-
hidden: true
|
|
1843
|
-
}
|
|
1844
|
-
)
|
|
1845
|
-
]
|
|
1846
|
-
}
|
|
1847
|
-
) : null
|
|
1848
|
-
] })
|
|
1849
|
-
] }),
|
|
1850
|
-
captureMode || captureData ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1851
|
-
"div",
|
|
1852
|
-
{
|
|
1853
|
-
style: {
|
|
1854
|
-
...surfaceCardStyle,
|
|
1855
|
-
padding: "12px 14px",
|
|
1856
|
-
borderColor: captureMode ? "rgba(94, 234, 212, 0.3)" : theme.border
|
|
1857
|
-
},
|
|
1858
|
-
children: [
|
|
1859
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap" }, children: [
|
|
1860
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { style: pillStyle(captureMode ? "success" : "neutral"), title: captureData?.selector || void 0, children: [
|
|
1861
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MousePointerClick, { size: 12 }),
|
|
1862
|
-
captureMode ? "Element capture active" : "Element captured"
|
|
1863
|
-
] }),
|
|
1864
|
-
captureData?.selectedText ? /* @__PURE__ */ jsxRuntime.jsxs("span", { style: pillStyle("neutral"), title: captureData.selectedText, children: [
|
|
1865
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.MessageSquare, { size: 12 }),
|
|
1866
|
-
"Text preview"
|
|
1867
|
-
] }) : null
|
|
1868
|
-
] }),
|
|
1869
|
-
!captureData ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...metaTextStyle, marginTop: "8px" }, children: "Click any visible element to attach its selector." }) : null
|
|
1870
|
-
]
|
|
1871
|
-
}
|
|
1872
|
-
) : null,
|
|
1873
|
-
screenshotId ? /* @__PURE__ */ jsxRuntime.jsxs("div", { style: { ...surfaceCardStyle, padding: "10px" }, children: [
|
|
1874
1086
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1875
|
-
"
|
|
1087
|
+
"label",
|
|
1876
1088
|
{
|
|
1877
1089
|
style: {
|
|
1878
1090
|
display: "flex",
|
|
1879
1091
|
alignItems: "center",
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1092
|
+
gap: "5px",
|
|
1093
|
+
borderRadius: "7px",
|
|
1094
|
+
border: "1px solid #1e293b",
|
|
1095
|
+
background: "#1e293b",
|
|
1096
|
+
color: "#94a3b8",
|
|
1097
|
+
padding: "5px 9px",
|
|
1098
|
+
cursor: "pointer",
|
|
1099
|
+
fontSize: "12px"
|
|
1883
1100
|
},
|
|
1884
1101
|
children: [
|
|
1885
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
children: [
|
|
1898
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Trash2, { size: 15 }),
|
|
1899
|
-
deletingScreenshot ? "Removing..." : "Remove"
|
|
1900
|
-
]
|
|
1901
|
-
}
|
|
1902
|
-
)
|
|
1903
|
-
]
|
|
1904
|
-
}
|
|
1905
|
-
),
|
|
1906
|
-
screenshotPreviewUrl ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...innerCardStyle, overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1907
|
-
"img",
|
|
1908
|
-
{
|
|
1909
|
-
src: screenshotPreviewUrl,
|
|
1910
|
-
alt: "Annotated screenshot preview",
|
|
1911
|
-
style: { width: "100%", height: "auto", display: "block", maxHeight: "180px", objectFit: "cover" }
|
|
1912
|
-
}
|
|
1913
|
-
) }) : null
|
|
1914
|
-
] }) : null,
|
|
1915
|
-
notice ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(94, 234, 212, 0.28)" }, children: /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { ...metaTextStyle, color: "#ccfbf1" }, children: [
|
|
1916
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.CheckCircle2, { size: 14, style: { verticalAlign: "text-bottom", marginRight: "6px" } }),
|
|
1917
|
-
notice
|
|
1918
|
-
] }) }) : null,
|
|
1919
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { ...surfaceCardStyle, padding: "12px 14px", borderColor: "rgba(248, 113, 113, 0.24)" }, children: /* @__PURE__ */ jsxRuntime.jsx("p", { style: { ...metaTextStyle, color: "#fecaca" }, children: error }) }) : null
|
|
1920
|
-
] }) : view === "history" && history ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1921
|
-
FeedbackHistory,
|
|
1922
|
-
{
|
|
1923
|
-
feedbacks: history.feedbacks,
|
|
1924
|
-
totalPages: history.totalPages,
|
|
1925
|
-
currentPage: history.currentPage,
|
|
1926
|
-
loading: history.loading,
|
|
1927
|
-
error: history.error,
|
|
1928
|
-
currentUserId: currentUserId ?? null,
|
|
1929
|
-
onSelectFeedback: (id) => handleSelectFeedback(id),
|
|
1930
|
-
onPageChange: history.onPageChange,
|
|
1931
|
-
onRefetch: history.refetch
|
|
1932
|
-
}
|
|
1933
|
-
) : view === "detail" && selectedFeedback && onUpload && onDeleteScreenshot ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1934
|
-
FeedbackDetail,
|
|
1935
|
-
{
|
|
1936
|
-
feedback: selectedFeedback,
|
|
1937
|
-
currentUserId: currentUserId ?? null,
|
|
1938
|
-
capturePolicy,
|
|
1939
|
-
onBack: () => setView("history"),
|
|
1940
|
-
onUpdate: async (id, data) => {
|
|
1941
|
-
if (!onUpdateFeedback) return false;
|
|
1942
|
-
const result = await onUpdateFeedback(id, data);
|
|
1943
|
-
if (result && history) {
|
|
1944
|
-
history.refetch();
|
|
1945
|
-
setSelectedFeedback((prev) => {
|
|
1946
|
-
if (!prev) return prev;
|
|
1947
|
-
return {
|
|
1948
|
-
...prev,
|
|
1949
|
-
message: data.message ?? prev.message,
|
|
1950
|
-
screenshot: data.screenshotId !== void 0 ? data.screenshotId ? { id: data.screenshotId, url: void 0 } : null : prev.screenshot
|
|
1951
|
-
};
|
|
1952
|
-
});
|
|
1953
|
-
}
|
|
1954
|
-
return result;
|
|
1955
|
-
},
|
|
1956
|
-
onDelete: async (id) => {
|
|
1957
|
-
if (!onDeleteFeedback) return false;
|
|
1958
|
-
const result = await onDeleteFeedback(id);
|
|
1959
|
-
if (result.success) {
|
|
1960
|
-
setSelectedFeedback(null);
|
|
1961
|
-
setView("history");
|
|
1962
|
-
history?.refetch();
|
|
1963
|
-
return true;
|
|
1102
|
+
/* @__PURE__ */ jsxRuntime.jsx(UploadIcon, {}),
|
|
1103
|
+
uploading ? "Uploading\u2026" : uploadLabel,
|
|
1104
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1105
|
+
"input",
|
|
1106
|
+
{
|
|
1107
|
+
type: "file",
|
|
1108
|
+
accept: screenshotAllowedMimeTypes.join(","),
|
|
1109
|
+
onChange: handleUpload,
|
|
1110
|
+
hidden: true
|
|
1111
|
+
}
|
|
1112
|
+
)
|
|
1113
|
+
]
|
|
1964
1114
|
}
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
},
|
|
1968
|
-
onUpload,
|
|
1969
|
-
onDeleteScreenshot
|
|
1970
|
-
}
|
|
1971
|
-
) : null
|
|
1972
|
-
}
|
|
1973
|
-
),
|
|
1974
|
-
view === "form" ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1975
|
-
"div",
|
|
1976
|
-
{
|
|
1977
|
-
style: {
|
|
1978
|
-
display: "flex",
|
|
1979
|
-
justifyContent: "space-between",
|
|
1980
|
-
alignItems: "stretch",
|
|
1981
|
-
gap: "8px",
|
|
1982
|
-
flexWrap: "wrap",
|
|
1983
|
-
flexShrink: 0,
|
|
1984
|
-
padding: "12px 14px",
|
|
1985
|
-
paddingBottom: "calc(12px + env(safe-area-inset-bottom, 0px))",
|
|
1986
|
-
borderTop: `1px solid ${theme.border}`,
|
|
1987
|
-
background: "linear-gradient(180deg, rgba(8, 15, 30, 0.94) 0%, rgba(15, 23, 42, 0.96) 100%)"
|
|
1988
|
-
},
|
|
1989
|
-
children: [
|
|
1990
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1115
|
+
)
|
|
1116
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "6px", flexWrap: "wrap" }, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1991
1117
|
"button",
|
|
1992
1118
|
{
|
|
1993
1119
|
type: "button",
|
|
1994
|
-
onClick: () =>
|
|
1995
|
-
setOpen(false);
|
|
1996
|
-
setView("form");
|
|
1997
|
-
},
|
|
1120
|
+
onClick: () => setCaptureMode((v) => !v),
|
|
1998
1121
|
style: {
|
|
1999
|
-
|
|
2000
|
-
|
|
1122
|
+
display: "flex",
|
|
1123
|
+
alignItems: "center",
|
|
1124
|
+
gap: "5px",
|
|
1125
|
+
borderRadius: "7px",
|
|
1126
|
+
border: captureMode ? "1px solid #4ade80" : "1px solid #1e293b",
|
|
1127
|
+
background: captureMode ? "rgba(74,222,128,0.08)" : "#1e293b",
|
|
1128
|
+
color: captureMode ? "#4ade80" : "#94a3b8",
|
|
1129
|
+
padding: "5px 9px",
|
|
1130
|
+
cursor: "pointer",
|
|
1131
|
+
fontSize: "12px"
|
|
2001
1132
|
},
|
|
2002
1133
|
children: [
|
|
2003
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2004
|
-
"
|
|
1134
|
+
/* @__PURE__ */ jsxRuntime.jsx(CursorIcon, {}),
|
|
1135
|
+
captureMode ? "Click an element\u2026" : "Capture element"
|
|
2005
1136
|
]
|
|
2006
1137
|
}
|
|
2007
|
-
),
|
|
2008
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2009
|
-
|
|
1138
|
+
) }),
|
|
1139
|
+
allowScreenshotUpload && onUpload ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "11px", color: "#475569" }, children: "Paste an image with Ctrl/Cmd+V or capture the current tab first." }) : null,
|
|
1140
|
+
captureData ? /* @__PURE__ */ jsxRuntime.jsxs("p", { style: { margin: 0, fontSize: "11px", color: "#64748b", overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
|
|
1141
|
+
"Element: ",
|
|
1142
|
+
/* @__PURE__ */ jsxRuntime.jsx("code", { style: { color: "#94a3b8" }, children: captureData.selector })
|
|
1143
|
+
] }) : null,
|
|
1144
|
+
screenshotId ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1145
|
+
"div",
|
|
2010
1146
|
{
|
|
2011
|
-
type: "button",
|
|
2012
|
-
onClick: handleSubmit,
|
|
2013
|
-
disabled: submitting,
|
|
2014
1147
|
style: {
|
|
2015
|
-
|
|
2016
|
-
|
|
1148
|
+
borderRadius: "10px",
|
|
1149
|
+
border: "1px solid #1e293b",
|
|
1150
|
+
background: "#0a0f1e",
|
|
1151
|
+
padding: "8px"
|
|
2017
1152
|
},
|
|
2018
1153
|
children: [
|
|
2019
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2020
|
-
|
|
1154
|
+
screenshotPreviewUrl ? /* @__PURE__ */ jsxRuntime.jsx("div", { style: { marginBottom: "8px", borderRadius: "6px", overflow: "hidden" }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1155
|
+
"img",
|
|
1156
|
+
{
|
|
1157
|
+
src: screenshotPreviewUrl,
|
|
1158
|
+
alt: "Annotated screenshot preview",
|
|
1159
|
+
style: { width: "100%", height: "auto", display: "block" }
|
|
1160
|
+
}
|
|
1161
|
+
) }) : null,
|
|
1162
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1163
|
+
"div",
|
|
1164
|
+
{
|
|
1165
|
+
style: {
|
|
1166
|
+
display: "flex",
|
|
1167
|
+
justifyContent: "space-between",
|
|
1168
|
+
alignItems: "center"
|
|
1169
|
+
},
|
|
1170
|
+
children: [
|
|
1171
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "11px", color: "#64748b" }, children: "Screenshot attached" }),
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1173
|
+
"button",
|
|
1174
|
+
{
|
|
1175
|
+
type: "button",
|
|
1176
|
+
onClick: handleRemoveScreenshot,
|
|
1177
|
+
disabled: deletingScreenshot,
|
|
1178
|
+
style: {
|
|
1179
|
+
display: "flex",
|
|
1180
|
+
alignItems: "center",
|
|
1181
|
+
gap: "4px",
|
|
1182
|
+
borderRadius: "6px",
|
|
1183
|
+
border: "1px solid #7f1d1d",
|
|
1184
|
+
background: "#450a0a",
|
|
1185
|
+
color: "#fca5a5",
|
|
1186
|
+
padding: "3px 8px",
|
|
1187
|
+
cursor: deletingScreenshot ? "wait" : "pointer",
|
|
1188
|
+
opacity: deletingScreenshot ? 0.7 : 1,
|
|
1189
|
+
fontSize: "11px"
|
|
1190
|
+
},
|
|
1191
|
+
children: [
|
|
1192
|
+
/* @__PURE__ */ jsxRuntime.jsx(TrashIcon, {}),
|
|
1193
|
+
deletingScreenshot ? "Removing\u2026" : "Remove"
|
|
1194
|
+
]
|
|
1195
|
+
}
|
|
1196
|
+
)
|
|
1197
|
+
]
|
|
1198
|
+
}
|
|
1199
|
+
)
|
|
2021
1200
|
]
|
|
2022
1201
|
}
|
|
2023
|
-
)
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
1202
|
+
) : null,
|
|
1203
|
+
notice ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, color: "#93c5fd", fontSize: "12px" }, children: notice }) : null,
|
|
1204
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, color: "#fca5a5", fontSize: "12px" }, children: error }) : null
|
|
1205
|
+
] }),
|
|
1206
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1207
|
+
"div",
|
|
1208
|
+
{
|
|
1209
|
+
style: {
|
|
1210
|
+
display: "flex",
|
|
1211
|
+
justifyContent: "flex-end",
|
|
1212
|
+
padding: "10px 14px 14px",
|
|
1213
|
+
borderTop: "1px solid #1e293b"
|
|
1214
|
+
},
|
|
1215
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1216
|
+
"button",
|
|
1217
|
+
{
|
|
1218
|
+
type: "button",
|
|
1219
|
+
onClick: handleSubmit,
|
|
1220
|
+
disabled: submitting,
|
|
1221
|
+
style: {
|
|
1222
|
+
display: "flex",
|
|
1223
|
+
alignItems: "center",
|
|
1224
|
+
gap: "7px",
|
|
1225
|
+
borderRadius: "8px",
|
|
1226
|
+
border: "none",
|
|
1227
|
+
background: "#15803d",
|
|
1228
|
+
color: "#f1f5f9",
|
|
1229
|
+
padding: "8px 16px",
|
|
1230
|
+
cursor: submitting ? "wait" : "pointer",
|
|
1231
|
+
fontWeight: 600,
|
|
1232
|
+
fontSize: "13px",
|
|
1233
|
+
opacity: submitting ? 0.75 : 1,
|
|
1234
|
+
transition: "opacity 0.15s ease"
|
|
1235
|
+
},
|
|
1236
|
+
children: [
|
|
1237
|
+
/* @__PURE__ */ jsxRuntime.jsx(SendIcon, {}),
|
|
1238
|
+
submitting ? "Sending\u2026" : submitLabel
|
|
1239
|
+
]
|
|
1240
|
+
}
|
|
1241
|
+
)
|
|
1242
|
+
}
|
|
1243
|
+
)
|
|
1244
|
+
] })
|
|
1245
|
+
}
|
|
1246
|
+
),
|
|
2028
1247
|
annotating && editorImage ? /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2029
1248
|
"div",
|
|
2030
1249
|
{
|
|
@@ -2032,8 +1251,8 @@ function FeedbackWidget({
|
|
|
2032
1251
|
position: "fixed",
|
|
2033
1252
|
inset: "0",
|
|
2034
1253
|
zIndex: 1e4,
|
|
2035
|
-
background: "rgba(
|
|
2036
|
-
color:
|
|
1254
|
+
background: "rgba(3, 7, 18, 0.96)",
|
|
1255
|
+
color: "#f8fafc",
|
|
2037
1256
|
display: "flex",
|
|
2038
1257
|
flexDirection: "column"
|
|
2039
1258
|
},
|
|
@@ -2044,42 +1263,24 @@ function FeedbackWidget({
|
|
|
2044
1263
|
style: {
|
|
2045
1264
|
display: "flex",
|
|
2046
1265
|
flexWrap: "wrap",
|
|
2047
|
-
gap: "
|
|
2048
|
-
alignItems: "
|
|
1266
|
+
gap: "10px",
|
|
1267
|
+
alignItems: "center",
|
|
2049
1268
|
justifyContent: "space-between",
|
|
2050
|
-
padding: "16px
|
|
2051
|
-
borderBottom:
|
|
2052
|
-
background: "
|
|
1269
|
+
padding: "10px 16px",
|
|
1270
|
+
borderBottom: "1px solid rgba(148, 163, 184, 0.15)",
|
|
1271
|
+
background: "rgba(15, 23, 42, 0.97)"
|
|
2053
1272
|
},
|
|
2054
1273
|
children: [
|
|
2055
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "
|
|
2056
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2057
|
-
|
|
2058
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Sparkles, { size: 12 }),
|
|
2059
|
-
"Annotate screenshot"
|
|
2060
|
-
] }),
|
|
2061
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { style: pillStyle("neutral"), children: editorImage.fileName })
|
|
2062
|
-
] }),
|
|
2063
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: annotationTools.map(({ tool, label, icon: Icon }) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2064
|
-
"button",
|
|
2065
|
-
{
|
|
2066
|
-
type: "button",
|
|
2067
|
-
onClick: () => setAnnotationTool(tool),
|
|
2068
|
-
"aria-label": label,
|
|
2069
|
-
style: buttonStyle("secondary", {
|
|
2070
|
-
compact: true,
|
|
2071
|
-
active: annotationTool === tool
|
|
2072
|
-
}),
|
|
2073
|
-
children: [
|
|
2074
|
-
/* @__PURE__ */ jsxRuntime.jsx(Icon, { size: 15 }),
|
|
2075
|
-
label
|
|
2076
|
-
]
|
|
2077
|
-
},
|
|
2078
|
-
tool
|
|
2079
|
-
)) })
|
|
1274
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
|
|
1275
|
+
/* @__PURE__ */ jsxRuntime.jsx("strong", { style: { fontSize: "14px", color: "#f1f5f9" }, children: "Annotate screenshot" }),
|
|
1276
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { style: { fontSize: "11px", color: "#475569" }, children: editorImage.fileName })
|
|
2080
1277
|
] }),
|
|
2081
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "
|
|
2082
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1278
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", flexWrap: "wrap", gap: "6px", alignItems: "center" }, children: [
|
|
1279
|
+
toolBtn("pen", /* @__PURE__ */ jsxRuntime.jsx(PenIcon, {}), "Pen"),
|
|
1280
|
+
toolBtn("rectangle", /* @__PURE__ */ jsxRuntime.jsx(RectIcon, {}), "Rect"),
|
|
1281
|
+
toolBtn("arrow", /* @__PURE__ */ jsxRuntime.jsx(ArrowIcon, {}), "Arrow"),
|
|
1282
|
+
toolBtn("text", /* @__PURE__ */ jsxRuntime.jsx(TextIcon, {}), "Text"),
|
|
1283
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "4px", alignItems: "center" }, children: [
|
|
2083
1284
|
DEFAULT_COLORS.map((color) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2084
1285
|
"button",
|
|
2085
1286
|
{
|
|
@@ -2087,12 +1288,13 @@ function FeedbackWidget({
|
|
|
2087
1288
|
onClick: () => setAnnotationColor(color),
|
|
2088
1289
|
"aria-label": `Select ${color} color`,
|
|
2089
1290
|
style: {
|
|
2090
|
-
width: "
|
|
2091
|
-
height: "
|
|
2092
|
-
borderRadius: "
|
|
2093
|
-
border: annotationColor === color ? "2px solid #f8fafc" :
|
|
1291
|
+
width: "20px",
|
|
1292
|
+
height: "20px",
|
|
1293
|
+
borderRadius: "50%",
|
|
1294
|
+
border: annotationColor === color ? "2px solid #f8fafc" : "1px solid #334155",
|
|
2094
1295
|
background: color,
|
|
2095
|
-
cursor: "pointer"
|
|
1296
|
+
cursor: "pointer",
|
|
1297
|
+
flexShrink: 0
|
|
2096
1298
|
}
|
|
2097
1299
|
},
|
|
2098
1300
|
color
|
|
@@ -2102,15 +1304,15 @@ function FeedbackWidget({
|
|
|
2102
1304
|
{
|
|
2103
1305
|
type: "color",
|
|
2104
1306
|
value: annotationColor,
|
|
2105
|
-
onChange: (
|
|
2106
|
-
"aria-label": "
|
|
2107
|
-
|
|
1307
|
+
onChange: (e) => setAnnotationColor(e.target.value),
|
|
1308
|
+
"aria-label": "Custom color",
|
|
1309
|
+
title: "Custom color",
|
|
1310
|
+
style: { width: "28px", height: "28px", border: "none", background: "transparent", cursor: "pointer" }
|
|
2108
1311
|
}
|
|
2109
1312
|
)
|
|
2110
1313
|
] }),
|
|
2111
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: { display: "flex", alignItems: "center", gap: "
|
|
2112
|
-
"Size
|
|
2113
|
-
annotationSize,
|
|
1314
|
+
/* @__PURE__ */ jsxRuntime.jsxs("label", { style: { display: "flex", alignItems: "center", gap: "6px", fontSize: "11px", color: "#64748b" }, children: [
|
|
1315
|
+
"Size",
|
|
2114
1316
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2115
1317
|
"input",
|
|
2116
1318
|
{
|
|
@@ -2118,115 +1320,97 @@ function FeedbackWidget({
|
|
|
2118
1320
|
min: 1,
|
|
2119
1321
|
max: 18,
|
|
2120
1322
|
value: annotationSize,
|
|
2121
|
-
onChange: (
|
|
2122
|
-
"aria-label": "
|
|
1323
|
+
onChange: (e) => setAnnotationSize(Number(e.target.value)),
|
|
1324
|
+
"aria-label": "Stroke size",
|
|
1325
|
+
style: { width: "72px" }
|
|
2123
1326
|
}
|
|
2124
1327
|
)
|
|
2125
1328
|
] }),
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
type: "text",
|
|
2130
|
-
value: annotationText,
|
|
2131
|
-
onChange: (event) => setAnnotationText(event.target.value),
|
|
2132
|
-
placeholder: "Text to place",
|
|
2133
|
-
"aria-label": "Annotation text",
|
|
2134
|
-
style: {
|
|
2135
|
-
...fieldStyle,
|
|
2136
|
-
minWidth: "220px",
|
|
2137
|
-
padding: "10px 12px"
|
|
2138
|
-
}
|
|
2139
|
-
}
|
|
2140
|
-
) : null,
|
|
2141
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px", flexWrap: "wrap" }, children: [
|
|
2142
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2143
|
-
"button",
|
|
2144
|
-
{
|
|
2145
|
-
type: "button",
|
|
2146
|
-
onClick: handleUndo,
|
|
2147
|
-
disabled: !currentHasUndo,
|
|
2148
|
-
style: buttonStyle("secondary", { compact: true, disabled: !currentHasUndo }),
|
|
2149
|
-
children: [
|
|
2150
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Undo2, { size: 15 }),
|
|
2151
|
-
"Undo"
|
|
2152
|
-
]
|
|
2153
|
-
}
|
|
2154
|
-
),
|
|
2155
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2156
|
-
"button",
|
|
2157
|
-
{
|
|
2158
|
-
type: "button",
|
|
2159
|
-
onClick: handleRedo,
|
|
2160
|
-
disabled: !currentHasRedo,
|
|
2161
|
-
style: buttonStyle("secondary", { compact: true, disabled: !currentHasRedo }),
|
|
2162
|
-
children: [
|
|
2163
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Redo2, { size: 15 }),
|
|
2164
|
-
"Redo"
|
|
2165
|
-
]
|
|
2166
|
-
}
|
|
2167
|
-
),
|
|
2168
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2169
|
-
"button",
|
|
2170
|
-
{
|
|
2171
|
-
type: "button",
|
|
2172
|
-
onClick: handleClearAnnotations,
|
|
2173
|
-
disabled: !hasAnnotations,
|
|
2174
|
-
style: buttonStyle("secondary", { compact: true, disabled: !hasAnnotations }),
|
|
2175
|
-
children: [
|
|
2176
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Eraser, { size: 15 }),
|
|
2177
|
-
"Clear"
|
|
2178
|
-
]
|
|
2179
|
-
}
|
|
2180
|
-
),
|
|
2181
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2182
|
-
"button",
|
|
2183
|
-
{
|
|
2184
|
-
type: "button",
|
|
2185
|
-
onClick: handleRevertLastAnnotation,
|
|
2186
|
-
disabled: !hasAnnotations,
|
|
2187
|
-
style: buttonStyle("secondary", { compact: true, disabled: !hasAnnotations }),
|
|
2188
|
-
children: [
|
|
2189
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: 15 }),
|
|
2190
|
-
"Revert last"
|
|
2191
|
-
]
|
|
2192
|
-
}
|
|
2193
|
-
)
|
|
2194
|
-
] })
|
|
1329
|
+
iconBtn(handleUndo, /* @__PURE__ */ jsxRuntime.jsx(UndoIcon, {}), "Undo", !currentHasUndo),
|
|
1330
|
+
iconBtn(handleRedo, /* @__PURE__ */ jsxRuntime.jsx(RedoIcon, {}), "Redo", !currentHasRedo),
|
|
1331
|
+
iconBtn(handleClearAnnotations, /* @__PURE__ */ jsxRuntime.jsx(TrashIcon, {}), "Clear", !hasAnnotations)
|
|
2195
1332
|
] })
|
|
2196
1333
|
]
|
|
2197
1334
|
}
|
|
2198
1335
|
),
|
|
2199
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1336
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2200
1337
|
"div",
|
|
2201
1338
|
{
|
|
1339
|
+
ref: annotationScrollRef,
|
|
2202
1340
|
style: {
|
|
2203
1341
|
flex: 1,
|
|
2204
1342
|
overflow: "auto",
|
|
2205
|
-
padding: "
|
|
1343
|
+
padding: "16px",
|
|
2206
1344
|
display: "flex",
|
|
2207
|
-
alignItems: "
|
|
2208
|
-
justifyContent: "center"
|
|
1345
|
+
alignItems: "flex-start",
|
|
1346
|
+
justifyContent: "center",
|
|
1347
|
+
position: "relative"
|
|
2209
1348
|
},
|
|
2210
|
-
children:
|
|
2211
|
-
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
1349
|
+
children: [
|
|
1350
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1351
|
+
"canvas",
|
|
1352
|
+
{
|
|
1353
|
+
ref: annotationCanvasRef,
|
|
1354
|
+
onPointerDown: handleCanvasPointerDown,
|
|
1355
|
+
onPointerMove: handleCanvasPointerMove,
|
|
1356
|
+
onPointerUp: handleCanvasPointerUp,
|
|
1357
|
+
onPointerCancel: handleCanvasPointerCancel,
|
|
1358
|
+
style: {
|
|
1359
|
+
width: "min(100%, 1400px)",
|
|
1360
|
+
height: "auto",
|
|
1361
|
+
display: "block",
|
|
1362
|
+
borderRadius: "12px",
|
|
1363
|
+
background: "#ffffff",
|
|
1364
|
+
boxShadow: "0 24px 80px rgba(15, 23, 42, 0.6)",
|
|
1365
|
+
touchAction: "none",
|
|
1366
|
+
cursor: annotationTool === "text" ? "text" : "crosshair"
|
|
1367
|
+
}
|
|
2227
1368
|
}
|
|
2228
|
-
|
|
2229
|
-
|
|
1369
|
+
),
|
|
1370
|
+
textCursor ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1371
|
+
"input",
|
|
1372
|
+
{
|
|
1373
|
+
autoFocus: true,
|
|
1374
|
+
ref: textInputRef,
|
|
1375
|
+
type: "text",
|
|
1376
|
+
value: inlineText,
|
|
1377
|
+
onChange: (e) => {
|
|
1378
|
+
inlineTextRef.current = e.target.value;
|
|
1379
|
+
setInlineText(e.target.value);
|
|
1380
|
+
},
|
|
1381
|
+
onKeyDown: (e) => {
|
|
1382
|
+
if (e.key === "Enter") {
|
|
1383
|
+
e.preventDefault();
|
|
1384
|
+
commitTextInput();
|
|
1385
|
+
}
|
|
1386
|
+
if (e.key === "Escape") {
|
|
1387
|
+
textCursorRef.current = null;
|
|
1388
|
+
setTextCursor(null);
|
|
1389
|
+
setInlineText("");
|
|
1390
|
+
inlineTextRef.current = "";
|
|
1391
|
+
}
|
|
1392
|
+
},
|
|
1393
|
+
placeholder: "Type \u2192 Enter to place",
|
|
1394
|
+
style: {
|
|
1395
|
+
position: "fixed",
|
|
1396
|
+
left: textCursor.domX,
|
|
1397
|
+
top: textCursor.domY,
|
|
1398
|
+
minWidth: "180px",
|
|
1399
|
+
background: "rgba(15, 23, 42, 0.92)",
|
|
1400
|
+
color: annotationColor,
|
|
1401
|
+
border: "1px dashed rgba(255,255,255,0.6)",
|
|
1402
|
+
borderRadius: "4px",
|
|
1403
|
+
padding: "4px 8px",
|
|
1404
|
+
fontSize: `${Math.max(14, annotationSize * 4)}px`,
|
|
1405
|
+
fontWeight: 600,
|
|
1406
|
+
outline: "none",
|
|
1407
|
+
zIndex: 10002,
|
|
1408
|
+
backdropFilter: "blur(6px)",
|
|
1409
|
+
boxShadow: "0 2px 12px rgba(0,0,0,0.4)"
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
) : null
|
|
1413
|
+
]
|
|
2230
1414
|
}
|
|
2231
1415
|
),
|
|
2232
1416
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
@@ -2238,27 +1422,53 @@ function FeedbackWidget({
|
|
|
2238
1422
|
alignItems: "center",
|
|
2239
1423
|
gap: "12px",
|
|
2240
1424
|
flexWrap: "wrap",
|
|
2241
|
-
padding: "16px
|
|
2242
|
-
borderTop:
|
|
2243
|
-
background: "
|
|
1425
|
+
padding: "10px 16px",
|
|
1426
|
+
borderTop: "1px solid rgba(148, 163, 184, 0.15)",
|
|
1427
|
+
background: "rgba(15, 23, 42, 0.97)"
|
|
2244
1428
|
},
|
|
2245
1429
|
children: [
|
|
2246
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { style: {
|
|
2247
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px"
|
|
2248
|
-
/* @__PURE__ */ jsxRuntime.
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
1430
|
+
annotationTool === "text" ? /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: "Click on the image to place text at that position." }) : /* @__PURE__ */ jsxRuntime.jsx("p", { style: { margin: 0, fontSize: "12px", color: "#64748b" }, children: "Draw on the image, then save when done." }),
|
|
1431
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { style: { display: "flex", gap: "8px" }, children: [
|
|
1432
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1433
|
+
"button",
|
|
1434
|
+
{
|
|
1435
|
+
type: "button",
|
|
1436
|
+
onClick: closeAnnotationEditor,
|
|
1437
|
+
style: {
|
|
1438
|
+
borderRadius: "8px",
|
|
1439
|
+
border: "1px solid #334155",
|
|
1440
|
+
background: "#0f172a",
|
|
1441
|
+
color: "#94a3b8",
|
|
1442
|
+
padding: "7px 14px",
|
|
1443
|
+
cursor: "pointer",
|
|
1444
|
+
fontSize: "13px"
|
|
1445
|
+
},
|
|
1446
|
+
children: "Cancel"
|
|
1447
|
+
}
|
|
1448
|
+
),
|
|
2252
1449
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2253
1450
|
"button",
|
|
2254
1451
|
{
|
|
2255
1452
|
type: "button",
|
|
2256
1453
|
onClick: handleApplyAnnotation,
|
|
2257
1454
|
disabled: uploading,
|
|
2258
|
-
style:
|
|
1455
|
+
style: {
|
|
1456
|
+
display: "flex",
|
|
1457
|
+
alignItems: "center",
|
|
1458
|
+
gap: "6px",
|
|
1459
|
+
borderRadius: "8px",
|
|
1460
|
+
border: "none",
|
|
1461
|
+
background: "#15803d",
|
|
1462
|
+
color: "#f1f5f9",
|
|
1463
|
+
padding: "7px 14px",
|
|
1464
|
+
cursor: uploading ? "wait" : "pointer",
|
|
1465
|
+
opacity: uploading ? 0.8 : 1,
|
|
1466
|
+
fontWeight: 600,
|
|
1467
|
+
fontSize: "13px"
|
|
1468
|
+
},
|
|
2259
1469
|
children: [
|
|
2260
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2261
|
-
uploading ? "Uploading
|
|
1470
|
+
/* @__PURE__ */ jsxRuntime.jsx(SendIcon, {}),
|
|
1471
|
+
uploading ? "Uploading\u2026" : "Save screenshot"
|
|
2262
1472
|
]
|
|
2263
1473
|
}
|
|
2264
1474
|
)
|
|
@@ -2271,439 +1481,125 @@ function FeedbackWidget({
|
|
|
2271
1481
|
) : null
|
|
2272
1482
|
] });
|
|
2273
1483
|
}
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
setLoading(true);
|
|
2288
|
-
setError(null);
|
|
2289
|
-
try {
|
|
2290
|
-
const url = new URL("/api/admin-feedback", window.location.origin);
|
|
2291
|
-
url.searchParams.set("depth", "2");
|
|
2292
|
-
url.searchParams.set("sort", "-createdAt");
|
|
2293
|
-
url.searchParams.set("limit", String(limit));
|
|
2294
|
-
url.searchParams.set("page", String(page));
|
|
2295
|
-
if (pagePath) {
|
|
2296
|
-
url.searchParams.set("where[pagePath][equals]", pagePath);
|
|
2297
|
-
}
|
|
2298
|
-
const response = await fetch(url.toString(), {
|
|
2299
|
-
credentials: "include"
|
|
2300
|
-
});
|
|
2301
|
-
if (!response.ok) {
|
|
2302
|
-
if (response.status === 401 || response.status === 403) {
|
|
2303
|
-
if (!cancelled) {
|
|
2304
|
-
setFeedbacks([]);
|
|
2305
|
-
setTotalPages(0);
|
|
2306
|
-
setLoading(false);
|
|
2307
|
-
}
|
|
2308
|
-
return;
|
|
2309
|
-
}
|
|
2310
|
-
throw new Error(`Failed to fetch feedback (${response.status})`);
|
|
2311
|
-
}
|
|
2312
|
-
const data = await response.json();
|
|
2313
|
-
if (!cancelled) {
|
|
2314
|
-
setFeedbacks(data.docs);
|
|
2315
|
-
setTotalPages(data.totalPages);
|
|
2316
|
-
setLoading(false);
|
|
2317
|
-
}
|
|
2318
|
-
} catch (err) {
|
|
2319
|
-
if (!cancelled) {
|
|
2320
|
-
setError(err instanceof Error ? err.message : "Failed to load feedback.");
|
|
2321
|
-
setLoading(false);
|
|
2322
|
-
}
|
|
2323
|
-
}
|
|
2324
|
-
};
|
|
2325
|
-
fetchFeedbacks();
|
|
2326
|
-
return () => {
|
|
2327
|
-
cancelled = true;
|
|
2328
|
-
};
|
|
2329
|
-
}, [pagePath, page, limit, fetchKey]);
|
|
1484
|
+
|
|
1485
|
+
// src/client/api.ts
|
|
1486
|
+
var readJson = async (response) => {
|
|
1487
|
+
try {
|
|
1488
|
+
return await response.json();
|
|
1489
|
+
} catch {
|
|
1490
|
+
return { success: false, error: `Request failed (${response.status}).` };
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
var errorOf = (body, fallback) => typeof body.error === "string" && body.error ? body.error : fallback;
|
|
1494
|
+
var createFeedbackApi = (apiBase = "/api") => {
|
|
1495
|
+
const base = `${apiBase.replace(/\/+$/, "")}/admin-feedback`;
|
|
1496
|
+
const deleteTokens = /* @__PURE__ */ new Map();
|
|
2330
1497
|
return {
|
|
2331
|
-
|
|
2332
|
-
|
|
2333
|
-
|
|
2334
|
-
loading,
|
|
2335
|
-
error,
|
|
2336
|
-
refetch
|
|
2337
|
-
};
|
|
2338
|
-
}
|
|
2339
|
-
function useCurrentUser() {
|
|
2340
|
-
const [userId, setUserId] = React2__default.default.useState(null);
|
|
2341
|
-
const [loading, setLoading] = React2__default.default.useState(true);
|
|
2342
|
-
React2__default.default.useEffect(() => {
|
|
2343
|
-
let cancelled = false;
|
|
2344
|
-
const fetchUser = async () => {
|
|
2345
|
-
try {
|
|
2346
|
-
const response = await fetch("/api/users/me", {
|
|
2347
|
-
credentials: "include"
|
|
2348
|
-
});
|
|
2349
|
-
if (!response.ok) {
|
|
2350
|
-
if (!cancelled) {
|
|
2351
|
-
setUserId(null);
|
|
2352
|
-
setLoading(false);
|
|
2353
|
-
}
|
|
2354
|
-
return;
|
|
2355
|
-
}
|
|
2356
|
-
const data = await response.json();
|
|
2357
|
-
if (!cancelled) {
|
|
2358
|
-
setUserId(data.user?.id ?? data.id ?? null);
|
|
2359
|
-
setLoading(false);
|
|
2360
|
-
}
|
|
2361
|
-
} catch {
|
|
2362
|
-
if (!cancelled) {
|
|
2363
|
-
setUserId(null);
|
|
2364
|
-
setLoading(false);
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
};
|
|
2368
|
-
fetchUser();
|
|
2369
|
-
return () => {
|
|
2370
|
-
cancelled = true;
|
|
2371
|
-
};
|
|
2372
|
-
}, []);
|
|
2373
|
-
return { userId, loading };
|
|
2374
|
-
}
|
|
2375
|
-
function AdminFeedbackWidget() {
|
|
2376
|
-
const { userId, loading: userLoading } = useCurrentUser();
|
|
2377
|
-
const [page, setPage] = React2__default.default.useState(1);
|
|
2378
|
-
const query = useFeedbackQuery({ page });
|
|
2379
|
-
const handleUpdateFeedback = React2__default.default.useCallback(
|
|
2380
|
-
async (id, data) => {
|
|
2381
|
-
const response = await fetch(`/api/admin-feedback/update/${id}`, {
|
|
2382
|
-
method: "PATCH",
|
|
1498
|
+
submit: async (payload) => {
|
|
1499
|
+
const response = await fetch(`${base}/submit`, {
|
|
1500
|
+
method: "POST",
|
|
2383
1501
|
credentials: "include",
|
|
2384
1502
|
headers: { "content-type": "application/json" },
|
|
2385
|
-
body: JSON.stringify(
|
|
1503
|
+
body: JSON.stringify(payload)
|
|
2386
1504
|
});
|
|
2387
|
-
const
|
|
2388
|
-
if (!
|
|
2389
|
-
return false;
|
|
1505
|
+
const body = await readJson(response);
|
|
1506
|
+
if (!response.ok || body.success !== true) {
|
|
1507
|
+
return { success: false, error: errorOf(body, "Submit failed.") };
|
|
2390
1508
|
}
|
|
2391
|
-
|
|
1509
|
+
deleteTokens.clear();
|
|
1510
|
+
return { success: true };
|
|
2392
1511
|
},
|
|
2393
|
-
|
|
2394
|
-
|
|
1512
|
+
upload: async (formData) => {
|
|
1513
|
+
const response = await fetch(`${base}/upload`, {
|
|
1514
|
+
method: "POST",
|
|
1515
|
+
credentials: "include",
|
|
1516
|
+
body: formData
|
|
1517
|
+
});
|
|
1518
|
+
const body = await readJson(response);
|
|
1519
|
+
if (!response.ok || body.success !== true || typeof body.mediaId !== "number") {
|
|
1520
|
+
return { success: false, error: errorOf(body, "Upload failed.") };
|
|
1521
|
+
}
|
|
1522
|
+
if (typeof body.deleteToken === "string") {
|
|
1523
|
+
deleteTokens.set(body.mediaId, body.deleteToken);
|
|
1524
|
+
}
|
|
1525
|
+
return { success: true, mediaId: body.mediaId };
|
|
1526
|
+
},
|
|
1527
|
+
deleteScreenshot: async (mediaId) => {
|
|
1528
|
+
const token = deleteTokens.get(mediaId);
|
|
1529
|
+
if (!token) {
|
|
1530
|
+
return { success: false, error: "This screenshot can no longer be removed." };
|
|
1531
|
+
}
|
|
1532
|
+
const response = await fetch(`${base}/upload/${mediaId}`, {
|
|
1533
|
+
method: "DELETE",
|
|
1534
|
+
credentials: "include",
|
|
1535
|
+
headers: { "x-feedback-delete-token": token }
|
|
1536
|
+
});
|
|
1537
|
+
const body = await readJson(response);
|
|
1538
|
+
if (!response.ok || body.success !== true) {
|
|
1539
|
+
return { success: false, error: errorOf(body, "Delete failed.") };
|
|
1540
|
+
}
|
|
1541
|
+
deleteTokens.delete(mediaId);
|
|
1542
|
+
return { success: true };
|
|
1543
|
+
}
|
|
1544
|
+
};
|
|
1545
|
+
};
|
|
1546
|
+
function AdminFeedbackWidget({
|
|
1547
|
+
title = "Admin feedback",
|
|
1548
|
+
submitLabel = "Send",
|
|
1549
|
+
uploadLabel = "Upload image",
|
|
1550
|
+
allowScreenshotUpload = true,
|
|
1551
|
+
screenshotMaxFileSizeBytes,
|
|
1552
|
+
screenshotAllowedMimeTypes,
|
|
1553
|
+
capturePolicy,
|
|
1554
|
+
apiRoute = "/api"
|
|
1555
|
+
}) {
|
|
1556
|
+
const api = React__default.default.useMemo(() => createFeedbackApi(apiRoute), [apiRoute]);
|
|
2395
1557
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2396
1558
|
FeedbackWidget,
|
|
2397
1559
|
{
|
|
2398
|
-
title
|
|
2399
|
-
submitLabel
|
|
2400
|
-
uploadLabel
|
|
2401
|
-
allowScreenshotUpload
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
currentPage: query.currentPage,
|
|
2409
|
-
loading: query.loading,
|
|
2410
|
-
error: query.error,
|
|
2411
|
-
refetch: query.refetch,
|
|
2412
|
-
onPageChange: setPage
|
|
2413
|
-
},
|
|
2414
|
-
onSubmit: async (payload) => {
|
|
2415
|
-
const response = await fetch("/api/admin-feedback/submit", {
|
|
2416
|
-
method: "POST",
|
|
2417
|
-
credentials: "include",
|
|
2418
|
-
headers: { "content-type": "application/json" },
|
|
2419
|
-
body: JSON.stringify(payload)
|
|
2420
|
-
});
|
|
2421
|
-
const result = await response.json();
|
|
2422
|
-
if (!result.success) {
|
|
2423
|
-
return { success: false, error: result.error || "Submit failed." };
|
|
2424
|
-
}
|
|
2425
|
-
query.refetch();
|
|
2426
|
-
return { success: true };
|
|
2427
|
-
},
|
|
2428
|
-
onDeleteFeedback: async (id) => {
|
|
2429
|
-
const response = await fetch(`/api/admin-feedback/delete/${id}`, {
|
|
2430
|
-
method: "DELETE",
|
|
2431
|
-
credentials: "include"
|
|
2432
|
-
});
|
|
2433
|
-
const result = await response.json();
|
|
2434
|
-
if (!result.success) {
|
|
2435
|
-
return { success: false, error: result.error || "Delete failed." };
|
|
2436
|
-
}
|
|
2437
|
-
query.refetch();
|
|
2438
|
-
return { success: true };
|
|
2439
|
-
},
|
|
2440
|
-
onUpload: async (formData) => {
|
|
2441
|
-
const response = await fetch("/api/admin-feedback/upload", {
|
|
2442
|
-
method: "POST",
|
|
2443
|
-
credentials: "include",
|
|
2444
|
-
body: formData
|
|
2445
|
-
});
|
|
2446
|
-
const result = await response.json();
|
|
2447
|
-
if (!result.success || typeof result.mediaId !== "number") {
|
|
2448
|
-
return { success: false, error: result.error || "Upload failed." };
|
|
2449
|
-
}
|
|
2450
|
-
return { success: true, mediaId: result.mediaId };
|
|
2451
|
-
},
|
|
2452
|
-
onDeleteScreenshot: async (mediaId) => {
|
|
2453
|
-
const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
|
|
2454
|
-
method: "DELETE",
|
|
2455
|
-
credentials: "include"
|
|
2456
|
-
});
|
|
2457
|
-
const result = await response.json();
|
|
2458
|
-
if (!result.success) {
|
|
2459
|
-
return { success: false, error: result.error || "Delete failed." };
|
|
2460
|
-
}
|
|
2461
|
-
return { success: true };
|
|
2462
|
-
}
|
|
1560
|
+
title,
|
|
1561
|
+
submitLabel,
|
|
1562
|
+
uploadLabel,
|
|
1563
|
+
allowScreenshotUpload,
|
|
1564
|
+
screenshotMaxFileSizeBytes,
|
|
1565
|
+
screenshotAllowedMimeTypes,
|
|
1566
|
+
capturePolicy,
|
|
1567
|
+
onSubmit: api.submit,
|
|
1568
|
+
onUpload: allowScreenshotUpload ? api.upload : void 0,
|
|
1569
|
+
onDeleteScreenshot: api.deleteScreenshot
|
|
2463
1570
|
}
|
|
2464
1571
|
);
|
|
2465
1572
|
}
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
};
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2489
|
-
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
const dotsRef = React2__default.default.useRef(/* @__PURE__ */ new Map());
|
|
2493
|
-
const tooltipRef = React2__default.default.useRef(null);
|
|
2494
|
-
const rafRef = React2__default.default.useRef(0);
|
|
2495
|
-
const indicatorDataRef = React2__default.default.useRef([]);
|
|
2496
|
-
const createContainer = React2__default.default.useCallback(() => {
|
|
2497
|
-
if (containerRef.current) return containerRef.current;
|
|
2498
|
-
const element = document.createElement("div");
|
|
2499
|
-
element.style.cssText = "position:fixed;inset:0;pointer-events:none;z-index:9998;";
|
|
2500
|
-
document.body.appendChild(element);
|
|
2501
|
-
containerRef.current = element;
|
|
2502
|
-
return element;
|
|
2503
|
-
}, []);
|
|
2504
|
-
const createTooltip = React2__default.default.useCallback(() => {
|
|
2505
|
-
if (tooltipRef.current) return tooltipRef.current;
|
|
2506
|
-
const element = document.createElement("div");
|
|
2507
|
-
element.style.cssText = `
|
|
2508
|
-
position:fixed;
|
|
2509
|
-
z-index:9999;
|
|
2510
|
-
pointer-events:none;
|
|
2511
|
-
opacity:0;
|
|
2512
|
-
max-width:260px;
|
|
2513
|
-
padding:12px 14px;
|
|
2514
|
-
border-radius:16px;
|
|
2515
|
-
border:1px solid rgba(148, 163, 184, 0.18);
|
|
2516
|
-
background:linear-gradient(180deg, rgba(15, 23, 42, 0.96) 0%, rgba(6, 13, 24, 0.96) 100%);
|
|
2517
|
-
color:#f8fafc;
|
|
2518
|
-
box-shadow:0 18px 40px rgba(2, 8, 23, 0.4);
|
|
2519
|
-
backdrop-filter:blur(16px);
|
|
2520
|
-
transition:opacity 0.15s ease;
|
|
2521
|
-
white-space:normal;
|
|
2522
|
-
`;
|
|
2523
|
-
document.body.appendChild(element);
|
|
2524
|
-
tooltipRef.current = element;
|
|
2525
|
-
return element;
|
|
2526
|
-
}, []);
|
|
2527
|
-
const renderTooltip = React2__default.default.useCallback((tooltip, indicator) => {
|
|
2528
|
-
tooltip.replaceChildren();
|
|
2529
|
-
const message = document.createElement("p");
|
|
2530
|
-
message.textContent = indicator.message.length > 80 ? `${indicator.message.slice(0, 80)}...` : indicator.message;
|
|
2531
|
-
message.style.cssText = "margin:0 0 8px;font-size:12px;line-height:1.5;word-break:break-word;";
|
|
2532
|
-
const metaRow = document.createElement("div");
|
|
2533
|
-
metaRow.style.cssText = "display:flex;align-items:center;gap:8px;flex-wrap:wrap;";
|
|
2534
|
-
const status = document.createElement("span");
|
|
2535
|
-
status.textContent = STATUS_LABELS2[indicator.status] || "New";
|
|
2536
|
-
status.style.cssText = `
|
|
2537
|
-
display:inline-flex;
|
|
2538
|
-
align-items:center;
|
|
2539
|
-
border-radius:999px;
|
|
2540
|
-
padding:4px 8px;
|
|
2541
|
-
font-size:10px;
|
|
2542
|
-
font-weight:700;
|
|
2543
|
-
background:rgba(148, 163, 184, 0.12);
|
|
2544
|
-
color:${STATUS_COLORS[indicator.status] || STATUS_COLORS.new};
|
|
2545
|
-
border:1px solid rgba(148, 163, 184, 0.18);
|
|
2546
|
-
`;
|
|
2547
|
-
const time = document.createElement("span");
|
|
2548
|
-
time.textContent = formatRelativeTime2(indicator.createdAt);
|
|
2549
|
-
time.style.cssText = "font-size:10px;color:rgba(148, 163, 184, 0.86);";
|
|
2550
|
-
metaRow.append(status, time);
|
|
2551
|
-
tooltip.append(message, metaRow);
|
|
2552
|
-
}, []);
|
|
2553
|
-
const positionDot = React2__default.default.useCallback((dot, selector) => {
|
|
2554
|
-
let target = null;
|
|
2555
|
-
try {
|
|
2556
|
-
target = document.querySelector(selector);
|
|
2557
|
-
} catch {
|
|
2558
|
-
dot.style.display = "none";
|
|
2559
|
-
return false;
|
|
2560
|
-
}
|
|
2561
|
-
if (!(target instanceof HTMLElement)) {
|
|
2562
|
-
dot.style.display = "none";
|
|
2563
|
-
return false;
|
|
2564
|
-
}
|
|
2565
|
-
const rect = target.getBoundingClientRect();
|
|
2566
|
-
if (rect.width > window.innerWidth * 0.9 || rect.height > window.innerHeight * 0.9) {
|
|
2567
|
-
dot.style.display = "none";
|
|
2568
|
-
return false;
|
|
1573
|
+
function AdminFeedbackProvider({
|
|
1574
|
+
children,
|
|
1575
|
+
collectionSlug = "admin-feedback",
|
|
1576
|
+
...widgetProps
|
|
1577
|
+
}) {
|
|
1578
|
+
const { permissions, user } = ui.useAuth();
|
|
1579
|
+
const { config } = ui.useConfig();
|
|
1580
|
+
const canCreate = Boolean(
|
|
1581
|
+
user && permissions?.collections?.[collectionSlug]?.create
|
|
1582
|
+
);
|
|
1583
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1584
|
+
children,
|
|
1585
|
+
canCreate ? /* @__PURE__ */ jsxRuntime.jsx(AdminFeedbackWidget, { ...widgetProps, apiRoute: config.routes?.api || "/api" }) : null
|
|
1586
|
+
] });
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// src/tenant/extractTenantSlug.ts
|
|
1590
|
+
var extractTenantSlugFromPathname = (pathname, pathMarkers) => {
|
|
1591
|
+
if (pathMarkers.length === 0) {
|
|
1592
|
+
return null;
|
|
1593
|
+
}
|
|
1594
|
+
const segments = pathname.split("?")[0].split("/").filter(Boolean);
|
|
1595
|
+
for (const marker of pathMarkers) {
|
|
1596
|
+
const markerIndex = segments.indexOf(marker);
|
|
1597
|
+
if (markerIndex > 0) {
|
|
1598
|
+
return segments[markerIndex - 1] ?? null;
|
|
2569
1599
|
}
|
|
2570
|
-
|
|
2571
|
-
dot.style.left = `${rect.right + DOT_OFFSET}px`;
|
|
2572
|
-
dot.style.top = `${rect.top - DOT_OFFSET - DOT_SIZE / 2}px`;
|
|
2573
|
-
return true;
|
|
2574
|
-
}, []);
|
|
2575
|
-
const repositionAll = React2__default.default.useCallback(() => {
|
|
2576
|
-
dotsRef.current.forEach((dot, id) => {
|
|
2577
|
-
const indicator = indicatorDataRef.current.find((item) => item.id === id);
|
|
2578
|
-
if (indicator) {
|
|
2579
|
-
positionDot(dot, indicator.selector);
|
|
2580
|
-
}
|
|
2581
|
-
});
|
|
2582
|
-
}, [positionDot]);
|
|
2583
|
-
React2__default.default.useEffect(() => {
|
|
2584
|
-
if (typeof window === "undefined" || typeof document === "undefined") return;
|
|
2585
|
-
let cancelled = false;
|
|
2586
|
-
const fetchAndRender = async () => {
|
|
2587
|
-
try {
|
|
2588
|
-
const authCheck = await fetch("/api/admin-feedback?limit=1", {
|
|
2589
|
-
credentials: "include"
|
|
2590
|
-
});
|
|
2591
|
-
if (!authCheck.ok) return;
|
|
2592
|
-
} catch {
|
|
2593
|
-
return;
|
|
2594
|
-
}
|
|
2595
|
-
const path = pagePath || window.location.pathname;
|
|
2596
|
-
const url = new URL("/api/admin-feedback", window.location.origin);
|
|
2597
|
-
url.searchParams.set("where[selector][exists]", "true");
|
|
2598
|
-
url.searchParams.set("depth", "2");
|
|
2599
|
-
url.searchParams.set("limit", "50");
|
|
2600
|
-
url.searchParams.set("sort", "-createdAt");
|
|
2601
|
-
try {
|
|
2602
|
-
const response = await fetch(url.toString(), { credentials: "include" });
|
|
2603
|
-
if (!response.ok) return;
|
|
2604
|
-
const data = await response.json();
|
|
2605
|
-
if (cancelled) return;
|
|
2606
|
-
const indicators = data.docs.filter((item) => item.selector && item.pagePath === path).map((item) => ({
|
|
2607
|
-
id: item.id,
|
|
2608
|
-
message: item.message,
|
|
2609
|
-
status: item.status,
|
|
2610
|
-
createdAt: item.createdAt,
|
|
2611
|
-
selector: item.selector
|
|
2612
|
-
}));
|
|
2613
|
-
indicatorDataRef.current = indicators;
|
|
2614
|
-
const container = createContainer();
|
|
2615
|
-
const tooltip = createTooltip();
|
|
2616
|
-
const currentIds = new Set(indicators.map((item) => item.id));
|
|
2617
|
-
dotsRef.current.forEach((dot, id) => {
|
|
2618
|
-
if (!currentIds.has(id)) {
|
|
2619
|
-
dot.remove();
|
|
2620
|
-
dotsRef.current.delete(id);
|
|
2621
|
-
}
|
|
2622
|
-
});
|
|
2623
|
-
for (const indicator of indicators) {
|
|
2624
|
-
let dot = dotsRef.current.get(indicator.id);
|
|
2625
|
-
if (!dot) {
|
|
2626
|
-
const element = document.createElement("div");
|
|
2627
|
-
element.style.cssText = `
|
|
2628
|
-
position:fixed;
|
|
2629
|
-
width:${DOT_SIZE}px;
|
|
2630
|
-
height:${DOT_SIZE}px;
|
|
2631
|
-
border-radius:999px;
|
|
2632
|
-
cursor:pointer;
|
|
2633
|
-
pointer-events:auto;
|
|
2634
|
-
z-index:9999;
|
|
2635
|
-
border:2px solid rgba(255,255,255,0.95);
|
|
2636
|
-
box-shadow:0 0 0 6px rgba(15, 23, 42, 0.2), 0 10px 22px rgba(2, 8, 23, 0.34);
|
|
2637
|
-
transition:transform 0.15s ease, box-shadow 0.15s ease;
|
|
2638
|
-
`;
|
|
2639
|
-
element.addEventListener("mouseenter", () => {
|
|
2640
|
-
element.style.transform = "scale(1.25)";
|
|
2641
|
-
element.style.boxShadow = "0 0 0 8px rgba(15, 23, 42, 0.28), 0 14px 28px rgba(2, 8, 23, 0.42)";
|
|
2642
|
-
renderTooltip(tooltip, indicator);
|
|
2643
|
-
const dotRect = element.getBoundingClientRect();
|
|
2644
|
-
tooltip.style.left = `${dotRect.right + 10}px`;
|
|
2645
|
-
tooltip.style.top = `${Math.max(12, dotRect.top - 6)}px`;
|
|
2646
|
-
tooltip.style.opacity = "1";
|
|
2647
|
-
});
|
|
2648
|
-
element.addEventListener("mouseleave", () => {
|
|
2649
|
-
element.style.transform = "";
|
|
2650
|
-
element.style.boxShadow = "0 0 0 6px rgba(15, 23, 42, 0.2), 0 10px 22px rgba(2, 8, 23, 0.34)";
|
|
2651
|
-
tooltip.style.opacity = "0";
|
|
2652
|
-
});
|
|
2653
|
-
element.addEventListener("click", (event) => {
|
|
2654
|
-
event.stopPropagation();
|
|
2655
|
-
window.dispatchEvent(
|
|
2656
|
-
new CustomEvent("feedback:show-detail", {
|
|
2657
|
-
detail: { feedbackId: indicator.id }
|
|
2658
|
-
})
|
|
2659
|
-
);
|
|
2660
|
-
});
|
|
2661
|
-
container.appendChild(element);
|
|
2662
|
-
dotsRef.current.set(indicator.id, element);
|
|
2663
|
-
dot = element;
|
|
2664
|
-
}
|
|
2665
|
-
dot.style.background = STATUS_COLORS[indicator.status] || STATUS_COLORS.new;
|
|
2666
|
-
positionDot(dot, indicator.selector);
|
|
2667
|
-
}
|
|
2668
|
-
} catch {
|
|
2669
|
-
}
|
|
2670
|
-
};
|
|
2671
|
-
const onScroll = () => {
|
|
2672
|
-
if (rafRef.current) return;
|
|
2673
|
-
rafRef.current = requestAnimationFrame(() => {
|
|
2674
|
-
rafRef.current = 0;
|
|
2675
|
-
repositionAll();
|
|
2676
|
-
});
|
|
2677
|
-
};
|
|
2678
|
-
fetchAndRender();
|
|
2679
|
-
window.addEventListener("scroll", onScroll, { passive: true });
|
|
2680
|
-
window.addEventListener("resize", onScroll);
|
|
2681
|
-
return () => {
|
|
2682
|
-
cancelled = true;
|
|
2683
|
-
window.removeEventListener("scroll", onScroll);
|
|
2684
|
-
window.removeEventListener("resize", onScroll);
|
|
2685
|
-
if (rafRef.current) {
|
|
2686
|
-
cancelAnimationFrame(rafRef.current);
|
|
2687
|
-
rafRef.current = 0;
|
|
2688
|
-
}
|
|
2689
|
-
};
|
|
2690
|
-
}, [pagePath, createContainer, createTooltip, positionDot, renderTooltip, repositionAll]);
|
|
2691
|
-
React2__default.default.useEffect(() => {
|
|
2692
|
-
return () => {
|
|
2693
|
-
dotsRef.current.forEach((dot) => dot.remove());
|
|
2694
|
-
dotsRef.current.clear();
|
|
2695
|
-
if (containerRef.current) {
|
|
2696
|
-
containerRef.current.remove();
|
|
2697
|
-
containerRef.current = null;
|
|
2698
|
-
}
|
|
2699
|
-
if (tooltipRef.current) {
|
|
2700
|
-
tooltipRef.current.remove();
|
|
2701
|
-
tooltipRef.current = null;
|
|
2702
|
-
}
|
|
2703
|
-
};
|
|
2704
|
-
}, []);
|
|
1600
|
+
}
|
|
2705
1601
|
return null;
|
|
2706
|
-
}
|
|
1602
|
+
};
|
|
2707
1603
|
|
|
2708
1604
|
// src/client/routeMatcher.ts
|
|
2709
1605
|
var escapeRegex = (input) => input.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
@@ -2734,118 +1630,39 @@ function FrontendFeedbackWidget({
|
|
|
2734
1630
|
title = "Feedback",
|
|
2735
1631
|
submitLabel = "Send",
|
|
2736
1632
|
uploadLabel = "Upload image",
|
|
2737
|
-
|
|
2738
|
-
|
|
1633
|
+
tenantPathMarkers = [],
|
|
1634
|
+
tenantFormDataKey = "tenant",
|
|
1635
|
+
apiRoute = "/api"
|
|
2739
1636
|
}) {
|
|
2740
1637
|
const pathname = navigation.usePathname();
|
|
1638
|
+
const api = React__default.default.useMemo(() => createFeedbackApi(apiRoute), [apiRoute]);
|
|
2741
1639
|
const normalizedPathname = normalizePathname(pathname, locales);
|
|
2742
|
-
const { userId, loading: userLoading } = useCurrentUser();
|
|
2743
|
-
const [page, setPage] = React2__default.default.useState(1);
|
|
2744
|
-
const query = useFeedbackQuery({ pagePath: normalizedPathname, page });
|
|
2745
|
-
const handleUpdateFeedback = React2__default.default.useCallback(
|
|
2746
|
-
async (id, data) => {
|
|
2747
|
-
const response = await fetch(`/api/admin-feedback/update/${id}`, {
|
|
2748
|
-
method: "PATCH",
|
|
2749
|
-
credentials: "include",
|
|
2750
|
-
headers: { "content-type": "application/json" },
|
|
2751
|
-
body: JSON.stringify(data)
|
|
2752
|
-
});
|
|
2753
|
-
const result = await response.json();
|
|
2754
|
-
if (!result.success) {
|
|
2755
|
-
return false;
|
|
2756
|
-
}
|
|
2757
|
-
return true;
|
|
2758
|
-
},
|
|
2759
|
-
[]
|
|
2760
|
-
);
|
|
2761
1640
|
if (!pathMatchesAllowlist(normalizedPathname, include)) {
|
|
2762
1641
|
return null;
|
|
2763
1642
|
}
|
|
2764
|
-
return /* @__PURE__ */ jsxRuntime.
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
feedbacks: query.feedbacks,
|
|
2778
|
-
totalPages: query.totalPages,
|
|
2779
|
-
currentPage: query.currentPage,
|
|
2780
|
-
loading: query.loading,
|
|
2781
|
-
error: query.error,
|
|
2782
|
-
refetch: query.refetch,
|
|
2783
|
-
onPageChange: setPage
|
|
2784
|
-
} : void 0,
|
|
2785
|
-
onSubmit: async (payload) => {
|
|
2786
|
-
const response = await fetch("/api/admin-feedback/submit", {
|
|
2787
|
-
method: "POST",
|
|
2788
|
-
credentials: "include",
|
|
2789
|
-
headers: { "content-type": "application/json" },
|
|
2790
|
-
body: JSON.stringify(payload)
|
|
2791
|
-
});
|
|
2792
|
-
const result = await response.json();
|
|
2793
|
-
if (!result.success) {
|
|
2794
|
-
return { success: false, error: result.error || "Submit failed." };
|
|
2795
|
-
}
|
|
2796
|
-
if (showHistory) {
|
|
2797
|
-
query.refetch();
|
|
2798
|
-
}
|
|
2799
|
-
return { success: true };
|
|
2800
|
-
},
|
|
2801
|
-
onDeleteFeedback: async (id) => {
|
|
2802
|
-
const response = await fetch(`/api/admin-feedback/delete/${id}`, {
|
|
2803
|
-
method: "DELETE",
|
|
2804
|
-
credentials: "include"
|
|
2805
|
-
});
|
|
2806
|
-
const result = await response.json();
|
|
2807
|
-
if (!result.success) {
|
|
2808
|
-
return { success: false, error: result.error || "Delete failed." };
|
|
2809
|
-
}
|
|
2810
|
-
if (showHistory) {
|
|
2811
|
-
query.refetch();
|
|
2812
|
-
}
|
|
2813
|
-
return { success: true };
|
|
2814
|
-
},
|
|
2815
|
-
onUpload: async (formData) => {
|
|
2816
|
-
const response = await fetch("/api/admin-feedback/upload", {
|
|
2817
|
-
method: "POST",
|
|
2818
|
-
credentials: "include",
|
|
2819
|
-
body: formData
|
|
2820
|
-
});
|
|
2821
|
-
const result = await response.json();
|
|
2822
|
-
if (!result.success || typeof result.mediaId !== "number") {
|
|
2823
|
-
return { success: false, error: result.error || "Upload failed." };
|
|
2824
|
-
}
|
|
2825
|
-
return { success: true, mediaId: result.mediaId };
|
|
2826
|
-
},
|
|
2827
|
-
onDeleteScreenshot: async (mediaId) => {
|
|
2828
|
-
const response = await fetch(`/api/admin-feedback/upload/${mediaId}`, {
|
|
2829
|
-
method: "DELETE",
|
|
2830
|
-
credentials: "include"
|
|
2831
|
-
});
|
|
2832
|
-
const result = await response.json();
|
|
2833
|
-
if (!result.success) {
|
|
2834
|
-
return { success: false, error: result.error || "Delete failed." };
|
|
1643
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1644
|
+
FeedbackWidget,
|
|
1645
|
+
{
|
|
1646
|
+
title,
|
|
1647
|
+
submitLabel,
|
|
1648
|
+
uploadLabel,
|
|
1649
|
+
allowScreenshotUpload: true,
|
|
1650
|
+
onSubmit: api.submit,
|
|
1651
|
+
onUpload: async (formData) => {
|
|
1652
|
+
if (tenantPathMarkers.length > 0) {
|
|
1653
|
+
const tenantSlug = extractTenantSlugFromPathname(pathname, tenantPathMarkers);
|
|
1654
|
+
if (tenantSlug) {
|
|
1655
|
+
formData.set(tenantFormDataKey, tenantSlug);
|
|
2835
1656
|
}
|
|
2836
|
-
return { success: true };
|
|
2837
1657
|
}
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
1658
|
+
return api.upload(formData);
|
|
1659
|
+
},
|
|
1660
|
+
onDeleteScreenshot: api.deleteScreenshot
|
|
1661
|
+
}
|
|
1662
|
+
);
|
|
2841
1663
|
}
|
|
2842
1664
|
|
|
1665
|
+
exports.AdminFeedbackProvider = AdminFeedbackProvider;
|
|
2843
1666
|
exports.AdminFeedbackWidget = AdminFeedbackWidget;
|
|
2844
|
-
exports.FeedbackDetail = FeedbackDetail;
|
|
2845
|
-
exports.FeedbackHistory = FeedbackHistory;
|
|
2846
|
-
exports.FeedbackIndicators = FeedbackIndicators;
|
|
2847
1667
|
exports.FeedbackWidget = FeedbackWidget;
|
|
2848
1668
|
exports.FrontendFeedbackWidget = FrontendFeedbackWidget;
|
|
2849
|
-
exports.pathMatchesAllowlist = pathMatchesAllowlist;
|
|
2850
|
-
exports.useCurrentUser = useCurrentUser;
|
|
2851
|
-
exports.useFeedbackQuery = useFeedbackQuery;
|