@sentropic/design-system-svelte 0.42.0 → 0.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CommentAuthorship.svelte +186 -0
- package/dist/CommentAuthorship.svelte.d.ts +18 -0
- package/dist/CommentAuthorship.svelte.d.ts.map +1 -0
- package/dist/CommentComposer.svelte +336 -0
- package/dist/CommentComposer.svelte.d.ts +33 -0
- package/dist/CommentComposer.svelte.d.ts.map +1 -0
- package/dist/CommentLayer.svelte +1621 -0
- package/dist/CommentLayer.svelte.d.ts +64 -0
- package/dist/CommentLayer.svelte.d.ts.map +1 -0
- package/dist/CommentPin.svelte +219 -0
- package/dist/CommentPin.svelte.d.ts +26 -0
- package/dist/CommentPin.svelte.d.ts.map +1 -0
- package/dist/CommentThread.svelte +801 -0
- package/dist/CommentThread.svelte.d.ts +42 -0
- package/dist/CommentThread.svelte.d.ts.map +1 -0
- package/dist/Drawer.svelte +96 -4
- package/dist/Drawer.svelte.d.ts.map +1 -1
- package/dist/OrphanList.svelte +267 -0
- package/dist/OrphanList.svelte.d.ts +18 -0
- package/dist/OrphanList.svelte.d.ts.map +1 -0
- package/dist/ReviewModeToggle.svelte +110 -0
- package/dist/ReviewModeToggle.svelte.d.ts +19 -0
- package/dist/ReviewModeToggle.svelte.d.ts.map +1 -0
- package/dist/ThreadPanel.svelte +654 -0
- package/dist/ThreadPanel.svelte.d.ts +42 -0
- package/dist/ThreadPanel.svelte.d.ts.map +1 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/review-markdown.d.ts +90 -0
- package/dist/review-markdown.d.ts.map +1 -0
- package/dist/review-markdown.js +379 -0
- package/package.json +2 -1
|
@@ -0,0 +1,801 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
4
|
+
import type {
|
|
5
|
+
CollaborationActor,
|
|
6
|
+
ReviewComment,
|
|
7
|
+
ReviewThread,
|
|
8
|
+
ThreadReadState,
|
|
9
|
+
} from "@sentropic/design-system-review-core";
|
|
10
|
+
import type { CommentRef } from "./review-markdown.js";
|
|
11
|
+
|
|
12
|
+
export type CommentThreadProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
|
|
13
|
+
thread: ReviewThread;
|
|
14
|
+
currentUser: CollaborationActor;
|
|
15
|
+
/** Server-side moderator override mirroring `author-or-admin` for edit/delete. */
|
|
16
|
+
canModerate?: boolean;
|
|
17
|
+
/** Whether replying is allowed when the thread is open. */
|
|
18
|
+
canReply?: boolean;
|
|
19
|
+
/** Optional host-held read state for unread comment indicators. */
|
|
20
|
+
readState?: ThreadReadState | string | null;
|
|
21
|
+
/** Optional display label for `thread.assignedTo` (defaults to the raw member id). */
|
|
22
|
+
assigneeLabel?: string;
|
|
23
|
+
/** Optional URL builder for live `authorship.runId` links. */
|
|
24
|
+
runHrefBuilder?: (runId: string, comment: ReviewComment) => string;
|
|
25
|
+
/** Optional URL builder for `Ref: decision:<id>` / `Ref: track:<id>` chips. */
|
|
26
|
+
refHrefBuilder?: (ref: CommentRef) => string;
|
|
27
|
+
class?: string;
|
|
28
|
+
onReply?: (threadId: string, body: string) => void | Promise<void>;
|
|
29
|
+
onResolve?: (threadId: string) => void | Promise<void>;
|
|
30
|
+
onReopen?: (threadId: string) => void | Promise<void>;
|
|
31
|
+
onEditComment?: (commentId: string, body: string) => void | Promise<void>;
|
|
32
|
+
onDeleteComment?: (commentId: string) => void | Promise<void>;
|
|
33
|
+
/** Optional re-anchor capability (hidden when absent per SPEC-r6 §2/§3). */
|
|
34
|
+
onReanchor?: (threadId: string) => void | Promise<void>;
|
|
35
|
+
onRunClick?: (runId: string, comment: ReviewComment) => void;
|
|
36
|
+
onRefClick?: (ref: CommentRef, comment: ReviewComment) => void;
|
|
37
|
+
/** Optional custom header slot. */
|
|
38
|
+
header?: Snippet<[{ thread: ReviewThread }]>;
|
|
39
|
+
/** Optional slot replacing the default safe markdown-lite comment body. */
|
|
40
|
+
commentBody?: Snippet<[{ comment: ReviewComment }]>;
|
|
41
|
+
};
|
|
42
|
+
</script>
|
|
43
|
+
|
|
44
|
+
<script lang="ts">
|
|
45
|
+
import { tick } from "svelte";
|
|
46
|
+
import { CheckCircle2, ExternalLink, Link2, Pencil, RotateCcw, Trash2 } from "@lucide/svelte";
|
|
47
|
+
import {
|
|
48
|
+
canEditOrDeleteComment,
|
|
49
|
+
getCommentStateLabel,
|
|
50
|
+
isCommentUnread,
|
|
51
|
+
type CommentState,
|
|
52
|
+
} from "@sentropic/design-system-review-core";
|
|
53
|
+
import Badge from "./Badge.svelte";
|
|
54
|
+
import Button from "./Button.svelte";
|
|
55
|
+
import CommentAuthorship from "./CommentAuthorship.svelte";
|
|
56
|
+
import CommentComposer from "./CommentComposer.svelte";
|
|
57
|
+
import IconButton from "./IconButton.svelte";
|
|
58
|
+
import {
|
|
59
|
+
formatAnchorLabel,
|
|
60
|
+
formatReviewError,
|
|
61
|
+
parseCommentBody,
|
|
62
|
+
type MarkdownInline,
|
|
63
|
+
} from "./review-markdown.js";
|
|
64
|
+
|
|
65
|
+
let {
|
|
66
|
+
thread,
|
|
67
|
+
currentUser,
|
|
68
|
+
canModerate = false,
|
|
69
|
+
canReply = true,
|
|
70
|
+
readState = null,
|
|
71
|
+
assigneeLabel,
|
|
72
|
+
runHrefBuilder,
|
|
73
|
+
refHrefBuilder,
|
|
74
|
+
class: className,
|
|
75
|
+
onReply,
|
|
76
|
+
onResolve,
|
|
77
|
+
onReopen,
|
|
78
|
+
onEditComment,
|
|
79
|
+
onDeleteComment,
|
|
80
|
+
onReanchor,
|
|
81
|
+
onRunClick,
|
|
82
|
+
onRefClick,
|
|
83
|
+
header,
|
|
84
|
+
commentBody,
|
|
85
|
+
...rest
|
|
86
|
+
}: CommentThreadProps = $props();
|
|
87
|
+
|
|
88
|
+
let threadEl: HTMLElement | undefined = $state();
|
|
89
|
+
let editingCommentId = $state<string | null>(null);
|
|
90
|
+
let editInvokerEl = $state<HTMLElement | null>(null);
|
|
91
|
+
let mutationError = $state<string | null>(null);
|
|
92
|
+
let optimisticState = $state<CommentState | null>(null);
|
|
93
|
+
let optimisticDeletedIds = $state<string[]>([]);
|
|
94
|
+
let optimisticEdits = $state<Record<string, string>>({});
|
|
95
|
+
let pendingAction = $state<boolean>(false);
|
|
96
|
+
|
|
97
|
+
const effectiveState = $derived<CommentState>(optimisticState ?? thread.state);
|
|
98
|
+
const stateLabel = $derived(getCommentStateLabel(effectiveState));
|
|
99
|
+
const anchorExcerpt = $derived(formatAnchorLabel(thread.anchor, 140));
|
|
100
|
+
const isOrphan = $derived(thread.anchor === null);
|
|
101
|
+
|
|
102
|
+
const visibleComments = $derived(
|
|
103
|
+
thread.comments
|
|
104
|
+
.filter((c) => !optimisticDeletedIds.includes(c.id))
|
|
105
|
+
.map((c) => {
|
|
106
|
+
const editedBody = optimisticEdits[c.id];
|
|
107
|
+
return editedBody !== undefined ? { ...c, body: editedBody } : c;
|
|
108
|
+
}),
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const resolvedLastReadAt = $derived.by(() => {
|
|
112
|
+
if (readState === null || readState === undefined) return undefined;
|
|
113
|
+
if (typeof readState === "string") return readState;
|
|
114
|
+
if (readState instanceof Map) return readState.get(thread.threadId);
|
|
115
|
+
return (readState as Readonly<Record<string, string | undefined>>)[thread.threadId];
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const classes = $derived(
|
|
119
|
+
[
|
|
120
|
+
"st-review-thread",
|
|
121
|
+
effectiveState === "closed" ? "st-review-thread--resolved" : undefined,
|
|
122
|
+
className,
|
|
123
|
+
]
|
|
124
|
+
.filter(Boolean)
|
|
125
|
+
.join(" "),
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
function formatTimestamp(iso: string): string {
|
|
129
|
+
const parsed = Date.parse(iso);
|
|
130
|
+
if (!Number.isFinite(parsed)) return iso;
|
|
131
|
+
return new Date(parsed).toLocaleString(undefined, {
|
|
132
|
+
month: "short",
|
|
133
|
+
day: "numeric",
|
|
134
|
+
hour: "2-digit",
|
|
135
|
+
minute: "2-digit",
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function runHref(runId: string, comment: ReviewComment): string {
|
|
140
|
+
return runHrefBuilder ? runHrefBuilder(runId, comment) : `#run-${encodeURIComponent(runId)}`;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function refHref(ref: CommentRef): string {
|
|
144
|
+
return refHrefBuilder
|
|
145
|
+
? refHrefBuilder(ref)
|
|
146
|
+
: `#${encodeURIComponent(ref.kind)}-${encodeURIComponent(ref.id)}`;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function handleResolve() {
|
|
150
|
+
if (!onResolve || pendingAction) return;
|
|
151
|
+
mutationError = null;
|
|
152
|
+
optimisticState = "closed";
|
|
153
|
+
pendingAction = true;
|
|
154
|
+
try {
|
|
155
|
+
await onResolve(thread.threadId);
|
|
156
|
+
} catch (err) {
|
|
157
|
+
mutationError = formatReviewError(err);
|
|
158
|
+
} finally {
|
|
159
|
+
optimisticState = null;
|
|
160
|
+
pendingAction = false;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
async function handleReopen() {
|
|
165
|
+
if (!onReopen || pendingAction) return;
|
|
166
|
+
mutationError = null;
|
|
167
|
+
optimisticState = "open";
|
|
168
|
+
pendingAction = true;
|
|
169
|
+
try {
|
|
170
|
+
await onReopen(thread.threadId);
|
|
171
|
+
} catch (err) {
|
|
172
|
+
mutationError = formatReviewError(err);
|
|
173
|
+
} finally {
|
|
174
|
+
optimisticState = null;
|
|
175
|
+
pendingAction = false;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
async function handleReanchor() {
|
|
180
|
+
if (!onReanchor || pendingAction) return;
|
|
181
|
+
mutationError = null;
|
|
182
|
+
pendingAction = true;
|
|
183
|
+
try {
|
|
184
|
+
await onReanchor(thread.threadId);
|
|
185
|
+
} catch (err) {
|
|
186
|
+
mutationError = formatReviewError(err);
|
|
187
|
+
} finally {
|
|
188
|
+
pendingAction = false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
function focusEditButtonFor(commentId: string | null, fallbackInvoker: HTMLElement | null) {
|
|
193
|
+
void tick().then(() => {
|
|
194
|
+
if (commentId && threadEl) {
|
|
195
|
+
const items = threadEl.querySelectorAll<HTMLElement>("[data-comment-id]");
|
|
196
|
+
for (const item of items) {
|
|
197
|
+
if (item.getAttribute("data-comment-id") === commentId) {
|
|
198
|
+
const btn = item.querySelector<HTMLElement>('button[aria-label="Edit comment"]');
|
|
199
|
+
if (btn) {
|
|
200
|
+
btn.focus();
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
if (fallbackInvoker?.isConnected) {
|
|
207
|
+
fallbackInvoker.focus();
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function startEdit(commentId: string, event: MouseEvent) {
|
|
213
|
+
mutationError = null;
|
|
214
|
+
editInvokerEl = event.currentTarget as HTMLElement | null;
|
|
215
|
+
editingCommentId = commentId;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function cancelEdit() {
|
|
219
|
+
const id = editingCommentId;
|
|
220
|
+
const invoker = editInvokerEl;
|
|
221
|
+
editingCommentId = null;
|
|
222
|
+
editInvokerEl = null;
|
|
223
|
+
focusEditButtonFor(id, invoker);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
async function submitEdit(commentId: string, nextBody: string) {
|
|
227
|
+
if (!onEditComment) return;
|
|
228
|
+
mutationError = null;
|
|
229
|
+
const prev = { ...optimisticEdits };
|
|
230
|
+
optimisticEdits = { ...optimisticEdits, [commentId]: nextBody };
|
|
231
|
+
try {
|
|
232
|
+
await onEditComment(commentId, nextBody);
|
|
233
|
+
const invoker = editInvokerEl;
|
|
234
|
+
editingCommentId = null;
|
|
235
|
+
editInvokerEl = null;
|
|
236
|
+
const next = { ...optimisticEdits };
|
|
237
|
+
delete next[commentId];
|
|
238
|
+
optimisticEdits = next;
|
|
239
|
+
focusEditButtonFor(commentId, invoker);
|
|
240
|
+
} catch (err) {
|
|
241
|
+
optimisticEdits = prev;
|
|
242
|
+
mutationError = formatReviewError(err);
|
|
243
|
+
throw err;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async function handleDelete(commentId: string) {
|
|
248
|
+
if (!onDeleteComment || pendingAction) return;
|
|
249
|
+
mutationError = null;
|
|
250
|
+
optimisticDeletedIds = [...optimisticDeletedIds, commentId];
|
|
251
|
+
pendingAction = true;
|
|
252
|
+
try {
|
|
253
|
+
await onDeleteComment(commentId);
|
|
254
|
+
} catch (err) {
|
|
255
|
+
optimisticDeletedIds = optimisticDeletedIds.filter((id) => id !== commentId);
|
|
256
|
+
mutationError = formatReviewError(err);
|
|
257
|
+
} finally {
|
|
258
|
+
pendingAction = false;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async function handleReplySubmit(body: string) {
|
|
263
|
+
if (!onReply) return;
|
|
264
|
+
mutationError = null;
|
|
265
|
+
await onReply(thread.threadId, body);
|
|
266
|
+
}
|
|
267
|
+
</script>
|
|
268
|
+
|
|
269
|
+
{#snippet renderInlines(nodes: MarkdownInline[])}
|
|
270
|
+
{#each nodes as node}
|
|
271
|
+
{#if node.type === "text"}
|
|
272
|
+
{node.text}
|
|
273
|
+
{:else if node.type === "break"}
|
|
274
|
+
<br />
|
|
275
|
+
{:else if node.type === "code"}
|
|
276
|
+
<code class="st-review-md__code">{node.text}</code>
|
|
277
|
+
{:else if node.type === "bold"}
|
|
278
|
+
<strong>{@render renderInlines(node.children)}</strong>
|
|
279
|
+
{:else if node.type === "italic"}
|
|
280
|
+
<em>{@render renderInlines(node.children)}</em>
|
|
281
|
+
{:else if node.type === "strike"}
|
|
282
|
+
<del>{@render renderInlines(node.children)}</del>
|
|
283
|
+
{:else if node.type === "link"}
|
|
284
|
+
<a
|
|
285
|
+
class="st-review-md__link"
|
|
286
|
+
href={node.href}
|
|
287
|
+
target={node.external ? "_blank" : undefined}
|
|
288
|
+
rel={node.external ? "noopener noreferrer" : undefined}
|
|
289
|
+
>
|
|
290
|
+
{node.label}
|
|
291
|
+
</a>
|
|
292
|
+
{/if}
|
|
293
|
+
{/each}
|
|
294
|
+
{/snippet}
|
|
295
|
+
|
|
296
|
+
<section
|
|
297
|
+
{...rest}
|
|
298
|
+
bind:this={threadEl}
|
|
299
|
+
class={classes}
|
|
300
|
+
aria-label={`Comment thread ${thread.threadId}`}
|
|
301
|
+
data-thread-id={thread.threadId}
|
|
302
|
+
data-thread-state={effectiveState}
|
|
303
|
+
>
|
|
304
|
+
{#if header}
|
|
305
|
+
<header class="st-review-thread__header">
|
|
306
|
+
{@render header({ thread })}
|
|
307
|
+
</header>
|
|
308
|
+
{:else}
|
|
309
|
+
<header class="st-review-thread__header">
|
|
310
|
+
<div class="st-review-thread__meta">
|
|
311
|
+
<p class="st-review-thread__anchor" title={anchorExcerpt}>
|
|
312
|
+
{anchorExcerpt}
|
|
313
|
+
</p>
|
|
314
|
+
<div class="st-review-thread__badges">
|
|
315
|
+
<Badge
|
|
316
|
+
size="sm"
|
|
317
|
+
tone={effectiveState === "closed" ? "success" : "info"}
|
|
318
|
+
class="st-review-thread__state"
|
|
319
|
+
>
|
|
320
|
+
{stateLabel}
|
|
321
|
+
</Badge>
|
|
322
|
+
{#if thread.assignedTo}
|
|
323
|
+
<span class="st-review-thread__assignee">
|
|
324
|
+
Assigned to {assigneeLabel ?? thread.assignedTo}
|
|
325
|
+
</span>
|
|
326
|
+
{/if}
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
|
|
330
|
+
<div class="st-review-thread__header-actions">
|
|
331
|
+
{#if isOrphan && onReanchor}
|
|
332
|
+
<Button
|
|
333
|
+
type="button"
|
|
334
|
+
variant="ghost"
|
|
335
|
+
size="sm"
|
|
336
|
+
disabled={pendingAction}
|
|
337
|
+
onclick={handleReanchor}
|
|
338
|
+
>
|
|
339
|
+
Re-anchor
|
|
340
|
+
</Button>
|
|
341
|
+
{/if}
|
|
342
|
+
{#if effectiveState === "open" && onResolve}
|
|
343
|
+
<Button
|
|
344
|
+
type="button"
|
|
345
|
+
variant="secondary"
|
|
346
|
+
size="sm"
|
|
347
|
+
disabled={pendingAction}
|
|
348
|
+
onclick={handleResolve}
|
|
349
|
+
>
|
|
350
|
+
Resolve
|
|
351
|
+
</Button>
|
|
352
|
+
{:else if effectiveState === "closed" && onReopen}
|
|
353
|
+
<Button
|
|
354
|
+
type="button"
|
|
355
|
+
variant="secondary"
|
|
356
|
+
size="sm"
|
|
357
|
+
disabled={pendingAction}
|
|
358
|
+
onclick={handleReopen}
|
|
359
|
+
>
|
|
360
|
+
Reopen
|
|
361
|
+
</Button>
|
|
362
|
+
{/if}
|
|
363
|
+
</div>
|
|
364
|
+
</header>
|
|
365
|
+
{/if}
|
|
366
|
+
|
|
367
|
+
{#if mutationError}
|
|
368
|
+
<div class="st-review-thread__error" role="alert">
|
|
369
|
+
{mutationError}
|
|
370
|
+
</div>
|
|
371
|
+
{/if}
|
|
372
|
+
|
|
373
|
+
<ol class="st-review-thread__list">
|
|
374
|
+
{#each visibleComments as comment (comment.id)}
|
|
375
|
+
{@const parsed = parseCommentBody(comment.body)}
|
|
376
|
+
{@const canEditDelete = canEditOrDeleteComment(comment, currentUser, { canModerate })}
|
|
377
|
+
{@const unread = isCommentUnread(comment, currentUser, resolvedLastReadAt)}
|
|
378
|
+
{@const isEdited = comment.updatedAt !== undefined && comment.updatedAt !== comment.createdAt}
|
|
379
|
+
{@const isEditing = editingCommentId === comment.id}
|
|
380
|
+
|
|
381
|
+
<li
|
|
382
|
+
class="st-review-thread__item"
|
|
383
|
+
class:st-review-thread__item--unread={unread}
|
|
384
|
+
class:st-review-thread__item--resolution={parsed.resolution !== null}
|
|
385
|
+
data-comment-id={comment.id}
|
|
386
|
+
data-unread={unread ? "true" : "false"}
|
|
387
|
+
data-resolution-record={parsed.resolution !== null ? "true" : undefined}
|
|
388
|
+
>
|
|
389
|
+
<div class="st-review-thread__item-header">
|
|
390
|
+
<CommentAuthorship
|
|
391
|
+
author={comment.authorship.author}
|
|
392
|
+
sponsor={comment.authorship.sponsor}
|
|
393
|
+
size="sm"
|
|
394
|
+
/>
|
|
395
|
+
|
|
396
|
+
<div class="st-review-thread__item-meta">
|
|
397
|
+
<time class="st-review-thread__time" datetime={comment.createdAt}>
|
|
398
|
+
{formatTimestamp(comment.createdAt)}
|
|
399
|
+
</time>
|
|
400
|
+
{#if isEdited}
|
|
401
|
+
<span class="st-review-thread__edited" title={`Edited ${comment.updatedAt}`}>
|
|
402
|
+
edited
|
|
403
|
+
</span>
|
|
404
|
+
{/if}
|
|
405
|
+
{#if comment.authorship.runId}
|
|
406
|
+
<a
|
|
407
|
+
class="st-review-thread__run-link"
|
|
408
|
+
href={runHref(comment.authorship.runId, comment)}
|
|
409
|
+
onclick={(event) => {
|
|
410
|
+
if (onRunClick) {
|
|
411
|
+
event.preventDefault();
|
|
412
|
+
onRunClick(comment.authorship.runId!, comment);
|
|
413
|
+
}
|
|
414
|
+
}}
|
|
415
|
+
>
|
|
416
|
+
<ExternalLink size={12} strokeWidth={2} aria-hidden="true" />
|
|
417
|
+
<span>Run {comment.authorship.runId}</span>
|
|
418
|
+
</a>
|
|
419
|
+
{/if}
|
|
420
|
+
{#if canEditDelete && !isEditing}
|
|
421
|
+
<div class="st-review-thread__item-actions">
|
|
422
|
+
{#if onEditComment}
|
|
423
|
+
<IconButton
|
|
424
|
+
size="sm"
|
|
425
|
+
variant="ghost"
|
|
426
|
+
aria-label="Edit comment"
|
|
427
|
+
disabled={pendingAction}
|
|
428
|
+
onclick={(event) => startEdit(comment.id, event)}
|
|
429
|
+
>
|
|
430
|
+
<Pencil size={14} strokeWidth={2} aria-hidden="true" />
|
|
431
|
+
</IconButton>
|
|
432
|
+
{/if}
|
|
433
|
+
{#if onDeleteComment}
|
|
434
|
+
<IconButton
|
|
435
|
+
size="sm"
|
|
436
|
+
variant="danger"
|
|
437
|
+
aria-label="Delete comment"
|
|
438
|
+
disabled={pendingAction}
|
|
439
|
+
onclick={() => handleDelete(comment.id)}
|
|
440
|
+
>
|
|
441
|
+
<Trash2 size={14} strokeWidth={2} aria-hidden="true" />
|
|
442
|
+
</IconButton>
|
|
443
|
+
{/if}
|
|
444
|
+
</div>
|
|
445
|
+
{/if}
|
|
446
|
+
</div>
|
|
447
|
+
</div>
|
|
448
|
+
|
|
449
|
+
{#if parsed.resolution !== null}
|
|
450
|
+
<div class="st-review-thread__resolution-banner">
|
|
451
|
+
<CheckCircle2 size={14} strokeWidth={2} aria-hidden="true" />
|
|
452
|
+
<span>Resolved in {parsed.resolution.version}</span>
|
|
453
|
+
</div>
|
|
454
|
+
{/if}
|
|
455
|
+
|
|
456
|
+
{#if isEditing}
|
|
457
|
+
<div class="st-review-thread__edit-form">
|
|
458
|
+
<CommentComposer
|
|
459
|
+
author={comment.authorship.author}
|
|
460
|
+
sponsor={comment.authorship.sponsor}
|
|
461
|
+
initialBody={comment.body}
|
|
462
|
+
submitLabel="Save"
|
|
463
|
+
cancelLabel="Cancel"
|
|
464
|
+
label="Edit comment"
|
|
465
|
+
autofocus={true}
|
|
466
|
+
trapFocus={true}
|
|
467
|
+
clearOnSubmit={false}
|
|
468
|
+
onSubmit={(nextBody) => submitEdit(comment.id, nextBody)}
|
|
469
|
+
onCancel={cancelEdit}
|
|
470
|
+
/>
|
|
471
|
+
</div>
|
|
472
|
+
{:else}
|
|
473
|
+
<div class="st-review-thread__body">
|
|
474
|
+
{#if commentBody}
|
|
475
|
+
{@render commentBody({ comment })}
|
|
476
|
+
{:else}
|
|
477
|
+
{#each parsed.blocks as block}
|
|
478
|
+
{#if block.type === "paragraph"}
|
|
479
|
+
<p class="st-review-md__p">{@render renderInlines(block.inlines)}</p>
|
|
480
|
+
{:else if block.type === "codeblock"}
|
|
481
|
+
<pre class="st-review-md__pre"><code>{block.code}</code></pre>
|
|
482
|
+
{:else if block.type === "blockquote"}
|
|
483
|
+
<blockquote class="st-review-md__quote">
|
|
484
|
+
{@render renderInlines(block.inlines)}
|
|
485
|
+
</blockquote>
|
|
486
|
+
{:else if block.type === "list"}
|
|
487
|
+
{#if block.ordered}
|
|
488
|
+
<ol class="st-review-md__list">
|
|
489
|
+
{#each block.items as item}
|
|
490
|
+
<li>{@render renderInlines(item)}</li>
|
|
491
|
+
{/each}
|
|
492
|
+
</ol>
|
|
493
|
+
{:else}
|
|
494
|
+
<ul class="st-review-md__list">
|
|
495
|
+
{#each block.items as item}
|
|
496
|
+
<li>{@render renderInlines(item)}</li>
|
|
497
|
+
{/each}
|
|
498
|
+
</ul>
|
|
499
|
+
{/if}
|
|
500
|
+
{/if}
|
|
501
|
+
{/each}
|
|
502
|
+
{/if}
|
|
503
|
+
</div>
|
|
504
|
+
|
|
505
|
+
{#if parsed.refs.length > 0}
|
|
506
|
+
<div class="st-review-thread__refs">
|
|
507
|
+
{#each parsed.refs as ref (`${ref.kind}:${ref.id}`)}
|
|
508
|
+
<a
|
|
509
|
+
class="st-review-ref-chip"
|
|
510
|
+
href={refHref(ref)}
|
|
511
|
+
data-ref-kind={ref.kind}
|
|
512
|
+
data-ref-id={ref.id}
|
|
513
|
+
onclick={(event) => {
|
|
514
|
+
if (onRefClick) {
|
|
515
|
+
event.preventDefault();
|
|
516
|
+
onRefClick(ref, comment);
|
|
517
|
+
}
|
|
518
|
+
}}
|
|
519
|
+
>
|
|
520
|
+
<Link2 size={12} strokeWidth={2} aria-hidden="true" />
|
|
521
|
+
<span>{ref.kind}:{ref.id}</span>
|
|
522
|
+
</a>
|
|
523
|
+
{/each}
|
|
524
|
+
</div>
|
|
525
|
+
{/if}
|
|
526
|
+
{/if}
|
|
527
|
+
</li>
|
|
528
|
+
{/each}
|
|
529
|
+
</ol>
|
|
530
|
+
|
|
531
|
+
{#if effectiveState === "closed"}
|
|
532
|
+
<div class="st-review-thread__resolved-notice">
|
|
533
|
+
<span>Comment resolved. Reopen to reply.</span>
|
|
534
|
+
{#if onReopen}
|
|
535
|
+
<Button
|
|
536
|
+
type="button"
|
|
537
|
+
variant="ghost"
|
|
538
|
+
size="sm"
|
|
539
|
+
disabled={pendingAction}
|
|
540
|
+
onclick={handleReopen}
|
|
541
|
+
>
|
|
542
|
+
<RotateCcw size={14} strokeWidth={2} aria-hidden="true" />
|
|
543
|
+
<span>Reopen</span>
|
|
544
|
+
</Button>
|
|
545
|
+
{/if}
|
|
546
|
+
</div>
|
|
547
|
+
{:else if canReply && onReply}
|
|
548
|
+
<div class="st-review-thread__reply">
|
|
549
|
+
<CommentComposer
|
|
550
|
+
author={currentUser}
|
|
551
|
+
placeholder="Reply…"
|
|
552
|
+
submitLabel="Reply"
|
|
553
|
+
label="Reply to thread"
|
|
554
|
+
autofocus={false}
|
|
555
|
+
trapFocus={false}
|
|
556
|
+
onSubmit={handleReplySubmit}
|
|
557
|
+
/>
|
|
558
|
+
</div>
|
|
559
|
+
{/if}
|
|
560
|
+
</section>
|
|
561
|
+
|
|
562
|
+
<style>
|
|
563
|
+
.st-review-thread {
|
|
564
|
+
background: var(
|
|
565
|
+
--st-component-review-thread-background,
|
|
566
|
+
var(--st-semantic-surface-raised, #ffffff)
|
|
567
|
+
);
|
|
568
|
+
border: 1px solid
|
|
569
|
+
var(--st-component-review-thread-border, var(--st-semantic-border-subtle));
|
|
570
|
+
border-radius: var(--st-component-review-thread-radius, var(--st-radius-md, 0.5rem));
|
|
571
|
+
color: var(--st-semantic-text-primary);
|
|
572
|
+
display: grid;
|
|
573
|
+
gap: var(--st-spacing-3, 0.75rem);
|
|
574
|
+
padding: var(--st-spacing-3, 0.75rem);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
.st-review-thread__header {
|
|
578
|
+
align-items: flex-start;
|
|
579
|
+
border-bottom: 1px solid var(--st-semantic-border-subtle);
|
|
580
|
+
display: flex;
|
|
581
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
582
|
+
justify-content: space-between;
|
|
583
|
+
padding-bottom: var(--st-spacing-2, 0.5rem);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
.st-review-thread__meta {
|
|
587
|
+
display: grid;
|
|
588
|
+
gap: var(--st-spacing-1, 0.25rem);
|
|
589
|
+
min-width: 0;
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
.st-review-thread__anchor {
|
|
593
|
+
background: var(--st-semantic-surface-subtle, #f8fafc);
|
|
594
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
595
|
+
box-shadow: inset 3px 0 0 var(--st-semantic-border-interactive, #2563eb);
|
|
596
|
+
color: var(--st-semantic-text-secondary);
|
|
597
|
+
font-size: 0.8125rem;
|
|
598
|
+
line-height: 1.4;
|
|
599
|
+
margin: 0;
|
|
600
|
+
overflow: hidden;
|
|
601
|
+
padding: var(--st-spacing-1, 0.25rem) var(--st-spacing-2, 0.5rem);
|
|
602
|
+
text-overflow: ellipsis;
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
.st-review-thread__badges {
|
|
606
|
+
align-items: center;
|
|
607
|
+
display: inline-flex;
|
|
608
|
+
flex-wrap: wrap;
|
|
609
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
.st-review-thread__assignee {
|
|
613
|
+
color: var(--st-semantic-text-secondary);
|
|
614
|
+
font-size: 0.75rem;
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
.st-review-thread__header-actions {
|
|
618
|
+
align-items: center;
|
|
619
|
+
display: inline-flex;
|
|
620
|
+
flex: 0 0 auto;
|
|
621
|
+
gap: var(--st-spacing-1, 0.25rem);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
.st-review-thread__error {
|
|
625
|
+
background: color-mix(in srgb, var(--st-semantic-feedback-danger, #b91c1c) 10%, white);
|
|
626
|
+
border: 1px solid var(--st-semantic-feedback-danger, #b91c1c);
|
|
627
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
628
|
+
color: var(--st-semantic-feedback-danger, #b91c1c);
|
|
629
|
+
font-size: 0.8125rem;
|
|
630
|
+
padding: var(--st-spacing-2, 0.5rem);
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
.st-review-thread__list {
|
|
634
|
+
display: grid;
|
|
635
|
+
gap: var(--st-spacing-3, 0.75rem);
|
|
636
|
+
list-style: none;
|
|
637
|
+
margin: 0;
|
|
638
|
+
padding: 0;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
.st-review-thread__item {
|
|
642
|
+
display: grid;
|
|
643
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
644
|
+
padding: var(--st-spacing-2, 0.5rem);
|
|
645
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
.st-review-thread__item--unread {
|
|
649
|
+
background: color-mix(
|
|
650
|
+
in srgb,
|
|
651
|
+
var(--st-semantic-feedback-info, #2563eb) 6%,
|
|
652
|
+
var(--st-semantic-surface-raised, #ffffff)
|
|
653
|
+
);
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
.st-review-thread__item--resolution {
|
|
657
|
+
background: color-mix(
|
|
658
|
+
in srgb,
|
|
659
|
+
var(--st-semantic-feedback-success, #15803d) 7%,
|
|
660
|
+
var(--st-semantic-surface-raised, #ffffff)
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
.st-review-thread__item-header {
|
|
665
|
+
align-items: flex-start;
|
|
666
|
+
display: flex;
|
|
667
|
+
flex-wrap: wrap;
|
|
668
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
669
|
+
justify-content: space-between;
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
.st-review-thread__item-meta {
|
|
673
|
+
align-items: center;
|
|
674
|
+
color: var(--st-semantic-text-secondary);
|
|
675
|
+
display: inline-flex;
|
|
676
|
+
flex-wrap: wrap;
|
|
677
|
+
font-size: 0.75rem;
|
|
678
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.st-review-thread__time {
|
|
682
|
+
font-variant-numeric: tabular-nums;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
.st-review-thread__edited {
|
|
686
|
+
font-style: italic;
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
.st-review-thread__run-link {
|
|
690
|
+
align-items: center;
|
|
691
|
+
color: var(--st-semantic-text-link, #2563eb);
|
|
692
|
+
display: inline-flex;
|
|
693
|
+
gap: 0.25rem;
|
|
694
|
+
text-decoration: none;
|
|
695
|
+
}
|
|
696
|
+
|
|
697
|
+
.st-review-thread__run-link:hover {
|
|
698
|
+
text-decoration: underline;
|
|
699
|
+
}
|
|
700
|
+
|
|
701
|
+
.st-review-thread__item-actions {
|
|
702
|
+
align-items: center;
|
|
703
|
+
display: inline-flex;
|
|
704
|
+
gap: 0.125rem;
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
.st-review-thread__resolution-banner {
|
|
708
|
+
align-items: center;
|
|
709
|
+
color: var(--st-semantic-feedback-success, #15803d);
|
|
710
|
+
display: inline-flex;
|
|
711
|
+
font-size: 0.75rem;
|
|
712
|
+
font-weight: 600;
|
|
713
|
+
gap: 0.25rem;
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
.st-review-thread__body {
|
|
717
|
+
display: grid;
|
|
718
|
+
font-size: 0.875rem;
|
|
719
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
720
|
+
line-height: 1.5;
|
|
721
|
+
word-break: break-word;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
.st-review-md__p {
|
|
725
|
+
margin: 0;
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
.st-review-md__code {
|
|
729
|
+
background: var(--st-semantic-surface-subtle, #f1f5f9);
|
|
730
|
+
border-radius: 0.25rem;
|
|
731
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
732
|
+
font-size: 0.8125rem;
|
|
733
|
+
padding: 0.1rem 0.3rem;
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
.st-review-md__pre {
|
|
737
|
+
background: var(--st-semantic-surface-subtle, #f1f5f9);
|
|
738
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
739
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
740
|
+
font-size: 0.8125rem;
|
|
741
|
+
margin: 0;
|
|
742
|
+
overflow-x: auto;
|
|
743
|
+
padding: var(--st-spacing-2, 0.5rem);
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
.st-review-md__quote {
|
|
747
|
+
background: var(--st-semantic-surface-subtle, #f8fafc);
|
|
748
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
749
|
+
box-shadow: inset 3px 0 0 var(--st-semantic-border-strong, #94a3b8);
|
|
750
|
+
color: var(--st-semantic-text-secondary);
|
|
751
|
+
margin: 0;
|
|
752
|
+
padding: var(--st-spacing-1, 0.25rem) var(--st-spacing-2, 0.5rem);
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
.st-review-md__list {
|
|
756
|
+
margin: 0;
|
|
757
|
+
padding-inline-start: 1.25rem;
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
.st-review-md__link {
|
|
761
|
+
color: var(--st-semantic-text-link, #2563eb);
|
|
762
|
+
text-decoration: underline;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
.st-review-thread__refs {
|
|
766
|
+
display: flex;
|
|
767
|
+
flex-wrap: wrap;
|
|
768
|
+
gap: var(--st-spacing-1, 0.25rem);
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
.st-review-ref-chip {
|
|
772
|
+
align-items: center;
|
|
773
|
+
background: var(--st-semantic-surface-subtle, #f1f5f9);
|
|
774
|
+
border: 1px solid var(--st-semantic-border-subtle);
|
|
775
|
+
border-radius: var(--st-radius-pill, 999px);
|
|
776
|
+
color: var(--st-semantic-text-link, #2563eb);
|
|
777
|
+
display: inline-flex;
|
|
778
|
+
font-size: 0.75rem;
|
|
779
|
+
font-weight: 600;
|
|
780
|
+
gap: 0.25rem;
|
|
781
|
+
padding: 0.125rem 0.5rem;
|
|
782
|
+
text-decoration: none;
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
.st-review-ref-chip:hover {
|
|
786
|
+
border-color: var(--st-semantic-border-interactive, #2563eb);
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
.st-review-thread__resolved-notice {
|
|
790
|
+
align-items: center;
|
|
791
|
+
background: var(--st-semantic-surface-subtle, #f8fafc);
|
|
792
|
+
border-radius: var(--st-radius-sm, 0.375rem);
|
|
793
|
+
color: var(--st-semantic-text-secondary);
|
|
794
|
+
display: flex;
|
|
795
|
+
flex-wrap: wrap;
|
|
796
|
+
font-size: 0.8125rem;
|
|
797
|
+
gap: var(--st-spacing-2, 0.5rem);
|
|
798
|
+
justify-content: space-between;
|
|
799
|
+
padding: var(--st-spacing-2, 0.5rem) var(--st-spacing-3, 0.75rem);
|
|
800
|
+
}
|
|
801
|
+
</style>
|