@auscera/design-labs 0.0.0-stage → 0.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.
Files changed (57) hide show
  1. package/apps/workspace/.skills/design-labs/SKILL.md +63 -0
  2. package/apps/workspace/.skills/design-labs/references/commands.md +38 -0
  3. package/apps/workspace/AGENTS.md +9 -0
  4. package/apps/workspace/app/(lab)/compare/page.tsx +2 -0
  5. package/apps/workspace/app/(lab)/lab.css +412 -0
  6. package/apps/workspace/app/(lab)/layout.tsx +21 -0
  7. package/apps/workspace/app/(lab)/page.tsx +2 -0
  8. package/apps/workspace/app/api/annotations/route.ts +94 -0
  9. package/apps/workspace/app/api/versions/events/route.ts +63 -0
  10. package/apps/workspace/app/api/versions/route.ts +7 -0
  11. package/apps/workspace/components/animated-icons.tsx +72 -0
  12. package/apps/workspace/components/dotmatrix-loader.css +1228 -0
  13. package/apps/workspace/components/glass-controls.tsx +47 -0
  14. package/apps/workspace/components/lab-providers.tsx +17 -0
  15. package/apps/workspace/components/molecules/brand-lockup.tsx +13 -0
  16. package/apps/workspace/components/molecules/pane-url-popover.css +92 -0
  17. package/apps/workspace/components/molecules/pane-url-popover.tsx +191 -0
  18. package/apps/workspace/components/pane-preferences.tsx +75 -0
  19. package/apps/workspace/components/pane-viewport.css +34 -0
  20. package/apps/workspace/components/pane-viewport.tsx +199 -0
  21. package/apps/workspace/components/preview-pane.css +293 -0
  22. package/apps/workspace/components/preview-pane.tsx +662 -0
  23. package/apps/workspace/components/ui/dotm-triangle-11.tsx +170 -0
  24. package/apps/workspace/components/ui/dotmatrix-core.tsx +1649 -0
  25. package/apps/workspace/components/ui/dotmatrix-hooks.ts +224 -0
  26. package/apps/workspace/components/version-select.tsx +220 -0
  27. package/apps/workspace/components/workspace.tsx +313 -0
  28. package/apps/workspace/eslint.config.mjs +3 -0
  29. package/apps/workspace/lab.config.json +1 -0
  30. package/apps/workspace/lib/annotation-export.ts +28 -0
  31. package/apps/workspace/lib/annotation-types.ts +38 -0
  32. package/apps/workspace/lib/device-presets.ts +103 -0
  33. package/apps/workspace/lib/use-annotation-bridge.ts +130 -0
  34. package/apps/workspace/lib/version-types.ts +12 -0
  35. package/apps/workspace/lib/website-url.ts +78 -0
  36. package/apps/workspace/next-env.d.ts +6 -0
  37. package/apps/workspace/next.config.mjs +1 -0
  38. package/apps/workspace/package.json +35 -0
  39. package/apps/workspace/public/apple-touch-icon.png +0 -0
  40. package/apps/workspace/public/brand/design-labs-script.LICENSE.txt +93 -0
  41. package/apps/workspace/public/brand/design-labs-script.woff2 +0 -0
  42. package/apps/workspace/public/brand/logo.webp +0 -0
  43. package/apps/workspace/public/brand/wordmark.css +42 -0
  44. package/apps/workspace/public/favicon.ico +0 -0
  45. package/apps/workspace/public/icon-192.png +0 -0
  46. package/apps/workspace/public/icon-512.png +0 -0
  47. package/apps/workspace/public/preview-bridge.js +411 -0
  48. package/apps/workspace/public/site.webmanifest +1 -0
  49. package/apps/workspace/scripts/annotation-store.mjs +308 -0
  50. package/apps/workspace/scripts/lab.mjs +414 -0
  51. package/apps/workspace/scripts/migrate.mjs +2 -0
  52. package/apps/workspace/scripts/prepare-preview.mjs +203 -0
  53. package/apps/workspace/tsconfig.json +24 -0
  54. package/package.json +9 -3
  55. package/scripts/install.mjs +67 -0
  56. package/scripts/update.mjs +204 -0
  57. package/README.md +0 -3
@@ -0,0 +1,662 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
4
+ import {
5
+ Columns2,
6
+ Rows2,
7
+ Maximize2,
8
+ Minimize2,
9
+ ExternalLink,
10
+ X,
11
+ Smartphone,
12
+ Link,
13
+ MousePointer,
14
+ List,
15
+ Download,
16
+ Copy,
17
+ Trash2,
18
+ } from "./animated-icons";
19
+ import { AnimatePresence, motion, useReducedMotion } from "framer-motion";
20
+ import { PaneUrlPopover } from "./molecules/pane-url-popover";
21
+ import { formatWebsiteUrl } from "../lib/website-url";
22
+ import { VersionSelect } from "./version-select";
23
+ import { PaneViewport, DeviceControls } from "./pane-viewport";
24
+ import { usePanePreference } from "./pane-preferences";
25
+ import { useAnnotationBridge } from "../lib/use-annotation-bridge";
26
+ import { annotationMarkdown, downloadReview } from "../lib/annotation-export";
27
+ import type { Annotation, TargetContext } from "../lib/annotation-types";
28
+ import type { LabVersion } from "../lib/version-types";
29
+ import "./preview-pane.css";
30
+ const keys = (key: string) => ["design-labs", "annotations", key] as const;
31
+ async function requestAnnotations(method: string, body: object) {
32
+ const r = await fetch("/api/annotations", {
33
+ method,
34
+ headers: { "Content-Type": "application/json" },
35
+ body: JSON.stringify(body),
36
+ });
37
+ if (!r.ok) {
38
+ const data = await r.json();
39
+ throw Error(data.error || "Could not save annotations");
40
+ }
41
+ return r.json();
42
+ }
43
+ export function PreviewPane({
44
+ id,
45
+ version,
46
+ options,
47
+ maximized,
48
+ onVersionChange,
49
+ onSplit,
50
+ onMaximize,
51
+ onClose,
52
+ }: {
53
+ id: string;
54
+ version?: LabVersion;
55
+ options: LabVersion[];
56
+ maximized: boolean;
57
+ onVersionChange: (value: string) => void;
58
+ onSplit: (direction: "row" | "column") => void;
59
+ onMaximize: () => void;
60
+ onClose: () => void;
61
+ }) {
62
+ const [preference, update] = usePanePreference(id);
63
+ const v: LabVersion = version || {
64
+ key: "",
65
+ project: "",
66
+ category: "landing",
67
+ label: "Website",
68
+ summary: "",
69
+ status: "needs-setup",
70
+ };
71
+ const usingUrl = preference.sourceMode === "url";
72
+ const previewUrl = usingUrl ? preference.url : v.path;
73
+ const previewLabel = usingUrl ? formatWebsiteUrl(preference.url) : v.label;
74
+ const canAnnotate = !usingUrl && Boolean(version?.path);
75
+ const [urlAnchor, setUrlAnchor] = useState<HTMLElement>();
76
+ const reduced = useReducedMotion();
77
+ const frame = useRef<HTMLIFrameElement>(null);
78
+ const body = useRef<HTMLDivElement>(null);
79
+ const textarea = useRef<HTMLTextAreaElement>(null);
80
+ const [picking, setPicking] = useState(false),
81
+ [review, setReview] = useState(false),
82
+ [selected, setSelected] = useState<string[]>([]),
83
+ [notice, setNotice] = useState("");
84
+ const [loaded, setLoaded] = useState(false);
85
+ const client = useQueryClient();
86
+ const query = useQuery<Annotation[]>({
87
+ queryKey: keys(v.key),
88
+ queryFn: async () => {
89
+ const r = await fetch(
90
+ `/api/annotations?versionKey=${encodeURIComponent(v.key)}`,
91
+ );
92
+ if (!r.ok) throw Error("Could not load saved annotations");
93
+ return r.json();
94
+ },
95
+ enabled: preference.tools && canAnnotate,
96
+ staleTime: 30000,
97
+ gcTime: 300000,
98
+ });
99
+ const notes = query.data || [];
100
+ const onTarget = useCallback(
101
+ (target: TargetContext) => {
102
+ setPicking(false);
103
+ update({ draft: { comment: "", target } });
104
+ setReview(false);
105
+ },
106
+ [update],
107
+ );
108
+ const bridge = useAnnotationBridge(
109
+ frame,
110
+ previewUrl,
111
+ preference.tools && canAnnotate,
112
+ onTarget,
113
+ () => setPicking(false),
114
+ );
115
+
116
+ const { ready, resolve, send } = bridge;
117
+ const save = useMutation({
118
+ mutationFn: (draft: NonNullable<typeof preference.draft>) =>
119
+ requestAnnotations("PUT", { versionKey: v.key, ...draft }),
120
+ onSuccess: async () => {
121
+ update({ draft: undefined });
122
+ setNotice("Annotation saved");
123
+ await client.invalidateQueries({ queryKey: keys(v.key) });
124
+ },
125
+ });
126
+ const remove = useMutation({
127
+ mutationFn: (ids: string[]) =>
128
+ requestAnnotations("DELETE", { versionKey: v.key, ids }),
129
+ onSuccess: async () => {
130
+ setSelected([]);
131
+ setNotice("Annotations deleted");
132
+ await client.invalidateQueries({ queryKey: keys(v.key) });
133
+ },
134
+ });
135
+ useEffect(() => {
136
+ if (ready)
137
+ resolve(
138
+ (query.data || []).filter((a) => a.target.pathname === bridge.pathname),
139
+ );
140
+ }, [ready, resolve, query.data, bridge.pathname]); // Current route only; resolve anew after DOM/scroll events in bridge.
141
+ const draftIdentity = preference.draft
142
+ ? `${preference.draft.id || "new"}:${preference.draft.target.selector}`
143
+ : undefined;
144
+ useEffect(() => {
145
+ if (draftIdentity) textarea.current?.focus();
146
+ }, [draftIdentity]);
147
+ useEffect(() => {
148
+ const esc = (e: KeyboardEvent) => {
149
+ if (e.key === "Escape") {
150
+ setPicking(false);
151
+ send({ type: "inspect", enabled: false });
152
+ if (preference.draft) update({ draft: undefined });
153
+ }
154
+ };
155
+ window.addEventListener("keydown", esc);
156
+ return () => window.removeEventListener("keydown", esc);
157
+ }, [send, preference.draft, update]);
158
+ function closeTools() {
159
+ bridge.send({ type: "inspect", enabled: false });
160
+ setPicking(false);
161
+ setReview(false);
162
+ setSelected([]);
163
+ setNotice("");
164
+ update({ tools: false, draft: undefined });
165
+ }
166
+ function inspect() {
167
+ if (!bridge.ready) return;
168
+ const next = !picking;
169
+ setPicking(next);
170
+ setReview(false);
171
+ update({ draft: undefined });
172
+ bridge.send({ type: "inspect", enabled: next });
173
+ }
174
+ const exportItems = selected.length
175
+ ? notes.filter((a) => selected.includes(a.id))
176
+ : notes;
177
+ async function copy() {
178
+ try {
179
+ await navigator.clipboard.writeText(
180
+ annotationMarkdown(exportItems, v.label),
181
+ );
182
+ setNotice(`Copied ${exportItems.length} annotations`);
183
+ } catch {
184
+ setNotice("Clipboard unavailable. Use the Markdown download instead.");
185
+ }
186
+ }
187
+ function locate(a: Annotation) {
188
+ if (a.target.pathname !== bridge.pathname && frame.current && v.path) {
189
+ const base = new URL(v.path, location.href);
190
+ frame.current.src = base.origin + a.target.pathname;
191
+ setNotice(
192
+ "Opening annotated page; select the comment again to locate it.",
193
+ );
194
+ return;
195
+ }
196
+ bridge.send({ type: "locate", selector: a.target.selector });
197
+ update({ draft: { id: a.id, comment: a.comment, target: a.target } });
198
+ setReview(false);
199
+ }
200
+ function edit(a: Annotation) {
201
+ bridge.send({ type: "inspect", enabled: false });
202
+ setPicking(false);
203
+ update({ draft: { id: a.id, comment: a.comment, target: a.target } });
204
+ setReview(false);
205
+ }
206
+ function chooseUrl(anchor: HTMLButtonElement) {
207
+ if (preference.url) {
208
+ closeTools();
209
+ setLoaded(false);
210
+ update({ sourceMode: "url" });
211
+ } else setUrlAnchor(anchor);
212
+ }
213
+ function openUrl(url: string) {
214
+ closeTools();
215
+ setLoaded(false);
216
+ update({ sourceMode: "url", url });
217
+ setUrlAnchor(undefined);
218
+ }
219
+ const draft = preference.draft;
220
+ return (
221
+ <section className="workspace-pane" data-pane-id={id}>
222
+ <div className="pane-toolbar">
223
+ <div className="pane-source-switch">
224
+ <AnimatePresence initial={false} mode="wait">
225
+ <motion.div
226
+ className="pane-source-state"
227
+ key={preference.responsive ? "devices" : "source"}
228
+ initial={reduced ? false : { opacity: 0, y: 4 }}
229
+ animate={{ opacity: 1, y: 0 }}
230
+ exit={{ opacity: 0, y: reduced ? 0 : -4 }}
231
+ transition={{ duration: reduced ? 0 : 0.14, ease: "easeOut" }}
232
+ >
233
+ {preference.responsive ? (
234
+ <DeviceControls
235
+ size={preference.size}
236
+ onChange={(size) => update({ size })}
237
+ />
238
+ ) : (
239
+ <VersionSelect
240
+ options={options}
241
+ value={v.key}
242
+ url={{
243
+ value: preference.url,
244
+ active: usingUrl,
245
+ onSelect: chooseUrl,
246
+ onEdit: setUrlAnchor,
247
+ }}
248
+ onChange={(value) => {
249
+ closeTools();
250
+ setLoaded(false);
251
+ update({ sourceMode: "version" });
252
+ onVersionChange(value);
253
+ }}
254
+ />
255
+ )}
256
+ </motion.div>
257
+ </AnimatePresence>
258
+ </div>
259
+ <div className="pane-actions">
260
+ <button
261
+ title={preference.url ? "Edit website URL" : "Open website URL"}
262
+ aria-label={
263
+ preference.url ? "Edit website URL" : "Open website URL"
264
+ }
265
+ aria-haspopup="dialog"
266
+ aria-expanded={Boolean(urlAnchor)}
267
+ onClick={(event) => setUrlAnchor(event.currentTarget)}
268
+ >
269
+ <Link size={16} />
270
+ </button>
271
+ <button
272
+ title={
273
+ preference.responsive
274
+ ? "Exit responsive mode"
275
+ : "Responsive preview"
276
+ }
277
+ aria-label={
278
+ preference.responsive
279
+ ? "Exit responsive mode"
280
+ : "Responsive preview"
281
+ }
282
+ aria-pressed={preference.responsive}
283
+ className={preference.responsive ? "mode-active" : ""}
284
+ onClick={() => update({ responsive: !preference.responsive })}
285
+ >
286
+ <Smartphone size={16} />
287
+ {preference.responsive && <X size={10} />}
288
+ </button>
289
+ <button
290
+ title={
291
+ canAnnotate
292
+ ? preference.tools
293
+ ? "Exit annotation mode"
294
+ : "Annotation tools"
295
+ : "Annotations require a saved Design Labs preview"
296
+ }
297
+ aria-label={
298
+ preference.tools ? "Exit annotation mode" : "Annotation tools"
299
+ }
300
+ aria-pressed={preference.tools}
301
+ disabled={!canAnnotate}
302
+ className={preference.tools ? "mode-active" : ""}
303
+ onClick={() =>
304
+ preference.tools ? closeTools() : update({ tools: true })
305
+ }
306
+ >
307
+ <MousePointer size={16} />
308
+ {preference.tools && <X size={10} />}
309
+ </button>
310
+ <button
311
+ title="Add pane right"
312
+ aria-label="Add pane right"
313
+ onClick={() => onSplit("row")}
314
+ >
315
+ <Columns2 size={16} />
316
+ </button>
317
+ <button
318
+ title="Add pane below"
319
+ aria-label="Add pane below"
320
+ onClick={() => onSplit("column")}
321
+ >
322
+ <Rows2 size={16} />
323
+ </button>
324
+ <button
325
+ title={maximized ? "Restore pane" : "Maximize pane"}
326
+ aria-label={maximized ? "Restore pane" : "Maximize pane"}
327
+ onClick={onMaximize}
328
+ >
329
+ {maximized ? <Minimize2 size={16} /> : <Maximize2 size={16} />}
330
+ </button>
331
+ {previewUrl && (
332
+ <a
333
+ href={previewUrl}
334
+ target="_blank"
335
+ rel="noreferrer"
336
+ title="Open in new tab"
337
+ aria-label="Open in new tab"
338
+ >
339
+ <ExternalLink size={16} />
340
+ </a>
341
+ )}
342
+ <button title="Close pane" aria-label="Close pane" onClick={onClose}>
343
+ <X size={16} />
344
+ </button>
345
+ </div>
346
+ </div>
347
+ {urlAnchor && (
348
+ <PaneUrlPopover
349
+ anchor={urlAnchor}
350
+ initialValue={preference.url}
351
+ onClose={() => setUrlAnchor(undefined)}
352
+ onSubmit={openUrl}
353
+ />
354
+ )}
355
+ <div className="pane-body" ref={body}>
356
+ <PaneViewport
357
+ responsive={preference.responsive}
358
+ size={preference.size}
359
+ onSizeChange={(size) => update({ size })}
360
+ >
361
+ {previewUrl ? (
362
+ <iframe
363
+ ref={frame}
364
+ key={usingUrl ? "url" : "version"}
365
+ title={`${previewLabel} preview`}
366
+ src={previewUrl}
367
+ sandbox={
368
+ usingUrl
369
+ ? "allow-scripts allow-same-origin allow-forms allow-popups allow-downloads"
370
+ : undefined
371
+ }
372
+ referrerPolicy={usingUrl ? "no-referrer" : undefined}
373
+ onLoad={() => {
374
+ setLoaded(true);
375
+ bridge.connect();
376
+ }}
377
+ />
378
+ ) : (
379
+ <p className="empty-state">
380
+ Choose a saved version or{" "}
381
+ <button
382
+ className="button"
383
+ onClick={(event) => setUrlAnchor(event.currentTarget)}
384
+ >
385
+ Open website URL
386
+ </button>
387
+ </p>
388
+ )}
389
+ {preference.tools &&
390
+ canAnnotate &&
391
+ bridge.pins
392
+ .filter((pin) => pin.found && pin.bounds)
393
+ .map((pin) => {
394
+ const a = notes.find((a) => a.id === pin.id);
395
+ if (!a || !pin.bounds) return null;
396
+ return (
397
+ <button
398
+ key={pin.id}
399
+ className="annotation-pin"
400
+ style={{ left: pin.bounds.x, top: pin.bounds.y }}
401
+ title={a.comment}
402
+ aria-label={`Edit annotation ${notes.indexOf(a) + 1}`}
403
+ onClick={() => edit(a)}
404
+ >
405
+ {notes.indexOf(a) + 1}
406
+ </button>
407
+ );
408
+ })}
409
+ </PaneViewport>
410
+ {preference.tools && canAnnotate && (
411
+ <>
412
+ <div
413
+ className="annotation-tools"
414
+ role="toolbar"
415
+ aria-label="Annotation controls"
416
+ >
417
+ <button
418
+ className={`button${picking ? " mode-active" : ""}`}
419
+ disabled={!bridge.ready}
420
+ aria-pressed={picking}
421
+ onClick={inspect}
422
+ >
423
+ <MousePointer size={14} />
424
+ {picking ? "Selecting…" : "Annotate"}
425
+ </button>
426
+ <button
427
+ className="button"
428
+ onClick={() => {
429
+ setReview(!review);
430
+ update({ draft: undefined });
431
+ setPicking(false);
432
+ bridge.send({ type: "inspect", enabled: false });
433
+ }}
434
+ >
435
+ <List size={14} />
436
+ View all <span>{notes.length}</span>
437
+ </button>
438
+ <button
439
+ className="button"
440
+ title="Export all annotations as Markdown"
441
+ aria-label="Export annotations"
442
+ disabled={!notes.length}
443
+ onClick={() => downloadReview(notes, v.label, "md")}
444
+ >
445
+ <Download size={14} />
446
+ </button>
447
+ <button
448
+ className="button"
449
+ title="Exit annotation mode"
450
+ aria-label="Close annotation toolbar"
451
+ onClick={closeTools}
452
+ >
453
+ <X size={14} />
454
+ </button>
455
+ </div>
456
+ {!bridge.ready && (
457
+ <div className="bridge-status" role="status">
458
+ {loaded
459
+ ? "Connecting preview inspector… If this preview uses another port, prepare its bridge adapter."
460
+ : "Waiting for preview…"}
461
+ </div>
462
+ )}
463
+ {notice && (
464
+ <div className="annotation-notice" role="status">
465
+ {notice}
466
+ <button
467
+ aria-label="Dismiss message"
468
+ onClick={() => setNotice("")}
469
+ >
470
+ <X size={12} />
471
+ </button>
472
+ </div>
473
+ )}
474
+ {draft && (
475
+ <div
476
+ className="annotation-editor review-panel"
477
+ role="dialog"
478
+ aria-label={draft.id ? "Edit annotation" : "New annotation"}
479
+ >
480
+ <div className="review-panel-heading">
481
+ <strong>
482
+ {draft.id ? "Edit annotation" : "New annotation"}
483
+ </strong>
484
+ <button
485
+ className="button"
486
+ aria-label="Cancel annotation"
487
+ onClick={() => update({ draft: undefined })}
488
+ >
489
+ <X size={14} />
490
+ </button>
491
+ </div>
492
+ <code>
493
+ {draft.target.tag} · {draft.target.selector}
494
+ </code>
495
+ <small>
496
+ {draft.target.pathname} · {draft.target.viewport.width} ×{" "}
497
+ {draft.target.viewport.height}
498
+ </small>
499
+ <textarea
500
+ ref={textarea}
501
+ aria-label="Annotation comment"
502
+ placeholder="Describe the change for your agent…"
503
+ maxLength={8000}
504
+ value={draft.comment}
505
+ onChange={(e) =>
506
+ update({ draft: { ...draft, comment: e.target.value } })
507
+ }
508
+ onKeyDown={(e) => {
509
+ if (
510
+ (e.ctrlKey || e.metaKey) &&
511
+ e.key === "Enter" &&
512
+ draft.comment.trim()
513
+ ) {
514
+ e.preventDefault();
515
+ save.mutate(draft);
516
+ }
517
+ }}
518
+ />
519
+ {save.error && <p role="alert">{save.error.message}</p>}
520
+ <div className="review-panel-actions">
521
+ <button
522
+ className="button"
523
+ onClick={() => update({ draft: undefined })}
524
+ >
525
+ Cancel
526
+ </button>
527
+ <button
528
+ className="button"
529
+ disabled={!draft.comment.trim() || save.isPending}
530
+ onClick={() => save.mutate(draft)}
531
+ >
532
+ {save.isPending ? "Saving…" : "Save annotation"}
533
+ </button>
534
+ </div>
535
+ </div>
536
+ )}
537
+ {review && (
538
+ <div
539
+ className="review-panel annotation-review"
540
+ role="dialog"
541
+ aria-label="All annotations"
542
+ >
543
+ <div className="review-panel-heading">
544
+ <strong>Annotations · {v.label}</strong>
545
+ <button
546
+ className="button"
547
+ aria-label="Close review"
548
+ onClick={() => setReview(false)}
549
+ >
550
+ <X size={14} />
551
+ </button>
552
+ </div>
553
+ {query.isPending ? (
554
+ <p>Loading annotations…</p>
555
+ ) : query.error ? (
556
+ <p role="alert">{query.error.message}</p>
557
+ ) : !notes.length ? (
558
+ <p>No annotations yet. Use Annotate to select an element.</p>
559
+ ) : (
560
+ <>
561
+ <label className="review-select-all">
562
+ <input
563
+ type="checkbox"
564
+ checked={selected.length === notes.length}
565
+ onChange={(e) =>
566
+ setSelected(
567
+ e.target.checked ? notes.map((a) => a.id) : [],
568
+ )
569
+ }
570
+ />
571
+ Select all
572
+ </label>
573
+ <div className="annotation-list">
574
+ {notes.map((a, i) => {
575
+ const pin = bridge.pins.find((p) => p.id === a.id);
576
+ return (
577
+ <div className="annotation-list-item" key={a.id}>
578
+ <input
579
+ type="checkbox"
580
+ aria-label={`Select annotation ${i + 1}`}
581
+ checked={selected.includes(a.id)}
582
+ onChange={(e) =>
583
+ setSelected((old) =>
584
+ e.target.checked
585
+ ? [...old, a.id]
586
+ : old.filter((id) => id !== a.id),
587
+ )
588
+ }
589
+ />
590
+ <button
591
+ className="annotation-item-content"
592
+ onClick={() => locate(a)}
593
+ >
594
+ <strong>
595
+ {i + 1}. {a.comment}
596
+ </strong>
597
+ <small>
598
+ {a.target.pathname} · {a.target.viewport.width}{" "}
599
+ × {a.target.viewport.height}
600
+ </small>
601
+ <code>{a.target.selector}</code>
602
+ {pin && !pin.found && (
603
+ <small className="target-missing">
604
+ Target changed or missing
605
+ </small>
606
+ )}
607
+ </button>
608
+ <button
609
+ className="button"
610
+ title="Delete annotation"
611
+ aria-label={`Delete annotation ${i + 1}`}
612
+ disabled={remove.isPending}
613
+ onClick={() => remove.mutate([a.id])}
614
+ >
615
+ <Trash2 size={14} />
616
+ </button>
617
+ </div>
618
+ );
619
+ })}
620
+ </div>
621
+ <div className="review-panel-actions">
622
+ <button className="button" onClick={copy}>
623
+ <Copy size={14} />
624
+ {selected.length ? "Copy selected" : "Copy all"}
625
+ </button>
626
+ <button
627
+ className="button"
628
+ onClick={() =>
629
+ downloadReview(exportItems, v.label, "md")
630
+ }
631
+ >
632
+ <Download size={14} />
633
+ Markdown
634
+ </button>
635
+ <button
636
+ className="button"
637
+ onClick={() =>
638
+ downloadReview(exportItems, v.label, "json")
639
+ }
640
+ >
641
+ JSON
642
+ </button>
643
+ <button
644
+ className="button"
645
+ disabled={!selected.length || remove.isPending}
646
+ onClick={() => remove.mutate(selected)}
647
+ >
648
+ <Trash2 size={14} />
649
+ Delete selected
650
+ </button>
651
+ </div>
652
+ </>
653
+ )}
654
+ {remove.error && <p role="alert">{remove.error.message}</p>}
655
+ </div>
656
+ )}
657
+ </>
658
+ )}
659
+ </div>
660
+ </section>
661
+ );
662
+ }