@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.
@@ -0,0 +1,42 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ import type { CollaborationActor, ReviewComment, ReviewThread, ThreadReadState } from "@sentropic/design-system-review-core";
4
+ import type { CommentRef } from "./review-markdown.js";
5
+ export type CommentThreadProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
6
+ thread: ReviewThread;
7
+ currentUser: CollaborationActor;
8
+ /** Server-side moderator override mirroring `author-or-admin` for edit/delete. */
9
+ canModerate?: boolean;
10
+ /** Whether replying is allowed when the thread is open. */
11
+ canReply?: boolean;
12
+ /** Optional host-held read state for unread comment indicators. */
13
+ readState?: ThreadReadState | string | null;
14
+ /** Optional display label for `thread.assignedTo` (defaults to the raw member id). */
15
+ assigneeLabel?: string;
16
+ /** Optional URL builder for live `authorship.runId` links. */
17
+ runHrefBuilder?: (runId: string, comment: ReviewComment) => string;
18
+ /** Optional URL builder for `Ref: decision:<id>` / `Ref: track:<id>` chips. */
19
+ refHrefBuilder?: (ref: CommentRef) => string;
20
+ class?: string;
21
+ onReply?: (threadId: string, body: string) => void | Promise<void>;
22
+ onResolve?: (threadId: string) => void | Promise<void>;
23
+ onReopen?: (threadId: string) => void | Promise<void>;
24
+ onEditComment?: (commentId: string, body: string) => void | Promise<void>;
25
+ onDeleteComment?: (commentId: string) => void | Promise<void>;
26
+ /** Optional re-anchor capability (hidden when absent per SPEC-r6 §2/§3). */
27
+ onReanchor?: (threadId: string) => void | Promise<void>;
28
+ onRunClick?: (runId: string, comment: ReviewComment) => void;
29
+ onRefClick?: (ref: CommentRef, comment: ReviewComment) => void;
30
+ /** Optional custom header slot. */
31
+ header?: Snippet<[{
32
+ thread: ReviewThread;
33
+ }]>;
34
+ /** Optional slot replacing the default safe markdown-lite comment body. */
35
+ commentBody?: Snippet<[{
36
+ comment: ReviewComment;
37
+ }]>;
38
+ };
39
+ declare const CommentThread: import("svelte").Component<CommentThreadProps, {}, "">;
40
+ type CommentThread = ReturnType<typeof CommentThread>;
41
+ export default CommentThread;
42
+ //# sourceMappingURL=CommentThread.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CommentThread.svelte.d.ts","sourceRoot":"","sources":["../src/lib/CommentThread.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,kBAAkB,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IAC5E,MAAM,EAAE,YAAY,CAAC;IACrB,WAAW,EAAE,kBAAkB,CAAC;IAChC,kFAAkF;IAClF,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,2DAA2D;IAC3D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mEAAmE;IACnE,SAAS,CAAC,EAAE,eAAe,GAAG,MAAM,GAAG,IAAI,CAAC;IAC5C,sFAAsF;IACtF,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,8DAA8D;IAC9D,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,KAAK,MAAM,CAAC;IACnE,+EAA+E;IAC/E,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,UAAU,KAAK,MAAM,CAAC;IAC7C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAA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4
5
 
@@ -27,8 +28,44 @@
27
28
  ...rest
28
29
  }: DrawerProps = $props();
29
30
 
31
+ let drawerEl: HTMLElement | undefined = $state();
32
+ let closeButton: HTMLButtonElement | undefined = $state();
33
+ let previousFocus: HTMLElement | null = null;
34
+ let wasOpen = false;
35
+
36
+ const focusableSelector = [
37
+ "a[href]",
38
+ "button:not([disabled])",
39
+ "input:not([disabled]):not([type='hidden'])",
40
+ "select:not([disabled])",
41
+ "textarea:not([disabled])",
42
+ "[tabindex]:not([tabindex='-1'])",
43
+ ].join(",");
44
+
30
45
  const classes = () => ["st-drawer", `st-drawer--${side}`, className].filter(Boolean).join(" ");
31
46
 
47
+ $effect(() => {
48
+ if (open && !wasOpen) {
49
+ wasOpen = true;
50
+ previousFocus = document.activeElement instanceof HTMLElement ? document.activeElement : null;
51
+ void tick().then(() => {
52
+ if (!open || !drawerEl) return;
53
+ if (!drawerEl.contains(document.activeElement)) {
54
+ (closeButton ?? drawerEl).focus();
55
+ }
56
+ });
57
+ } else if (!open && wasOpen) {
58
+ wasOpen = false;
59
+ const target = previousFocus;
60
+ previousFocus = null;
61
+ void tick().then(() => {
62
+ if (target?.isConnected) {
63
+ target.focus();
64
+ }
65
+ });
66
+ }
67
+ });
68
+
32
69
  function close() {
33
70
  open = false;
34
71
  onclose?.();
@@ -40,11 +77,52 @@
40
77
  }
41
78
  }
42
79
 
80
+ function trapFocus(event: KeyboardEvent) {
81
+ if (!drawerEl || event.key !== "Tab") return;
82
+ const focusables = Array.from(drawerEl.querySelectorAll<HTMLElement>(focusableSelector)).filter(
83
+ (el) => !el.hasAttribute("disabled") && el.getAttribute("aria-hidden") !== "true",
84
+ );
85
+
86
+ if (focusables.length === 0) {
87
+ event.preventDefault();
88
+ drawerEl.focus();
89
+ return;
90
+ }
91
+
92
+ const first = focusables[0]!;
93
+ const last = focusables[focusables.length - 1]!;
94
+ const active = document.activeElement;
95
+
96
+ if (!drawerEl.contains(active)) {
97
+ event.preventDefault();
98
+ first.focus();
99
+ return;
100
+ }
101
+
102
+ if (event.shiftKey && active === first) {
103
+ event.preventDefault();
104
+ last.focus();
105
+ } else if (!event.shiftKey && active === last) {
106
+ event.preventDefault();
107
+ first.focus();
108
+ }
109
+ }
110
+
43
111
  function onWindowKeydown(event: KeyboardEvent) {
44
- if (event.key === "Escape" && open) {
112
+ if (!open || event.defaultPrevented) return;
113
+ const targetEl = event.target instanceof Element ? event.target : null;
114
+ const activeEl = document.activeElement instanceof Element ? document.activeElement : null;
115
+ const otherModal =
116
+ targetEl?.closest('[aria-modal="true"]') ?? activeEl?.closest('[aria-modal="true"]');
117
+ if (otherModal && otherModal !== drawerEl) {
118
+ return;
119
+ }
120
+ if (event.key === "Escape") {
45
121
  event.preventDefault();
46
122
  close();
123
+ return;
47
124
  }
125
+ trapFocus(event);
48
126
  }
49
127
  </script>
50
128
 
@@ -52,13 +130,27 @@
52
130
 
53
131
  {#if open}
54
132
  <div class="st-drawer__backdrop" onclick={onBackdropClick} role="presentation">
55
- <aside {...rest} class={classes()} role="dialog" aria-modal="true" aria-label={title}>
133
+ <aside
134
+ {...rest}
135
+ bind:this={drawerEl}
136
+ class={classes()}
137
+ role="dialog"
138
+ aria-modal="true"
139
+ aria-label={title}
140
+ tabindex="-1"
141
+ >
56
142
  <header class="st-drawer__header">
57
143
  <div>
58
- <h2 class="st-drawer__title">{title}</h2>
144
+ <h2 class="st-drawer__title" tabindex="-1">{title}</h2>
59
145
  {#if description}<p class="st-drawer__description">{description}</p>{/if}
60
146
  </div>
61
- <button class="st-drawer__close" type="button" aria-label={closeLabel} onclick={close}>
147
+ <button
148
+ bind:this={closeButton}
149
+ class="st-drawer__close"
150
+ type="button"
151
+ aria-label={closeLabel}
152
+ onclick={close}
153
+ >
62
154
  <span aria-hidden="true">x</span>
63
155
  </button>
64
156
  </header>
@@ -1 +1 @@
1
- {"version":3,"file":"Drawer.svelte.d.ts","sourceRoot":"","sources":["../src/lib/Drawer.svelte.ts"],"names":[],"mappings":"AAGA,OAA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nB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACtB,CAAC;AAoJJ,QAAA,MAAM,MAAM,qDAAwC,CAAC;AACrD,KAAK,MAAM,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,CAAC;AACxC,eAAe,MAAM,CAAC"}
@@ -0,0 +1,267 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLAttributes } from "svelte/elements";
3
+ import type {
4
+ CollaborationActor,
5
+ ReviewThread,
6
+ ThreadReadState,
7
+ } from "@sentropic/design-system-review-core";
8
+
9
+ export type OrphanListProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
10
+ threads: readonly ReviewThread[];
11
+ currentUser: CollaborationActor;
12
+ readState?: ThreadReadState | null;
13
+ heading?: string;
14
+ class?: string;
15
+ onSelect?: (threadId: string) => void;
16
+ /** Optional re-anchor action; button is hidden when unbound (SPEC-r6 §2, §3). */
17
+ onReanchor?: (threadId: string) => void | Promise<void>;
18
+ onResolve?: (threadId: string) => void | Promise<void>;
19
+ onReopen?: (threadId: string) => void | Promise<void>;
20
+ };
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ import { Unlink } from "@lucide/svelte";
25
+ import {
26
+ getCommentStateLabel,
27
+ isUnread,
28
+ } from "@sentropic/design-system-review-core";
29
+ import Badge from "./Badge.svelte";
30
+ import Button from "./Button.svelte";
31
+ import CommentAuthorship from "./CommentAuthorship.svelte";
32
+ import EmptyState from "./EmptyState.svelte";
33
+ import { formatAnchorLabel, formatReviewError } from "./review-markdown.js";
34
+
35
+ let {
36
+ threads,
37
+ currentUser,
38
+ readState = null,
39
+ heading = "No longer attached",
40
+ class: className,
41
+ onSelect,
42
+ onReanchor,
43
+ onResolve,
44
+ onReopen,
45
+ ...rest
46
+ }: OrphanListProps = $props();
47
+
48
+ let actionError = $state<string | null>(null);
49
+ let pendingId = $state<string | null>(null);
50
+
51
+ const uid = $props.id();
52
+ const headingId = `st-review-orphans-heading-${uid}`;
53
+ const classes = $derived(["st-review-orphans", className].filter(Boolean).join(" "));
54
+
55
+ async function runThreadAction(
56
+ threadId: string,
57
+ fn: ((id: string) => void | Promise<void>) | undefined,
58
+ ) {
59
+ if (!fn || pendingId !== null) return;
60
+ actionError = null;
61
+ pendingId = threadId;
62
+ try {
63
+ await fn(threadId);
64
+ } catch (err) {
65
+ actionError = formatReviewError(err);
66
+ } finally {
67
+ pendingId = null;
68
+ }
69
+ }
70
+ </script>
71
+
72
+ <section {...rest} class={classes} aria-labelledby={headingId}>
73
+ <header class="st-review-orphans__header">
74
+ <h3 id={headingId} class="st-review-orphans__heading">
75
+ <Unlink size={14} strokeWidth={2} aria-hidden="true" />
76
+ <span>{heading}</span>
77
+ </h3>
78
+ <Badge size="sm" tone="warning" class="st-review-orphans__count">
79
+ {threads.length}
80
+ </Badge>
81
+ </header>
82
+
83
+ {#if actionError}
84
+ <div class="st-review-orphans__error" role="alert">
85
+ {actionError}
86
+ </div>
87
+ {/if}
88
+
89
+ {#if threads.length === 0}
90
+ <EmptyState
91
+ title="No unattached threads"
92
+ message="All comment threads are currently anchored to the document."
93
+ />
94
+ {:else}
95
+ <ul class="st-review-orphans__list">
96
+ {#each threads as thread (thread.threadId)}
97
+ {@const rootComment = thread.comments[0]}
98
+ {@const unread = isUnread(thread, currentUser, readState)}
99
+ {@const stateLabel = getCommentStateLabel(thread.state)}
100
+ {@const excerpt =
101
+ thread.anchor !== null
102
+ ? formatAnchorLabel(thread.anchor, 100)
103
+ : "Original location removed"}
104
+
105
+ <li
106
+ class="st-review-orphans__item"
107
+ class:st-review-orphans__item--unread={unread}
108
+ data-thread-id={thread.threadId}
109
+ data-thread-state={thread.state}
110
+ data-unread={unread ? "true" : "false"}
111
+ >
112
+ <div class="st-review-orphans__item-top">
113
+ {#if rootComment}
114
+ <CommentAuthorship
115
+ author={rootComment.authorship.author}
116
+ sponsor={rootComment.authorship.sponsor}
117
+ size="sm"
118
+ />
119
+ {/if}
120
+ <Badge
121
+ size="sm"
122
+ tone={thread.state === "closed" ? "success" : "info"}
123
+ >
124
+ {stateLabel}
125
+ </Badge>
126
+ </div>
127
+
128
+ <p class="st-review-orphans__excerpt">{excerpt}</p>
129
+
130
+ {#if rootComment}
131
+ <p class="st-review-orphans__preview">{rootComment.body}</p>
132
+ {/if}
133
+
134
+ <div class="st-review-orphans__actions">
135
+ {#if onSelect}
136
+ <Button
137
+ type="button"
138
+ variant="secondary"
139
+ size="sm"
140
+ aria-label={`Open thread ${thread.threadId}`}
141
+ onclick={() => onSelect(thread.threadId)}
142
+ >
143
+ Open ({thread.comments.length})
144
+ </Button>
145
+ {/if}
146
+ {#if onReanchor}
147
+ <Button
148
+ type="button"
149
+ variant="ghost"
150
+ size="sm"
151
+ disabled={pendingId === thread.threadId}
152
+ onclick={() => runThreadAction(thread.threadId, onReanchor)}
153
+ >
154
+ Re-anchor
155
+ </Button>
156
+ {/if}
157
+ {#if thread.state === "open" && onResolve}
158
+ <Button
159
+ type="button"
160
+ variant="ghost"
161
+ size="sm"
162
+ disabled={pendingId === thread.threadId}
163
+ onclick={() => runThreadAction(thread.threadId, onResolve)}
164
+ >
165
+ Resolve
166
+ </Button>
167
+ {:else if thread.state === "closed" && onReopen}
168
+ <Button
169
+ type="button"
170
+ variant="ghost"
171
+ size="sm"
172
+ disabled={pendingId === thread.threadId}
173
+ onclick={() => runThreadAction(thread.threadId, onReopen)}
174
+ >
175
+ Reopen
176
+ </Button>
177
+ {/if}
178
+ </div>
179
+ </li>
180
+ {/each}
181
+ </ul>
182
+ {/if}
183
+ </section>
184
+
185
+ <style>
186
+ .st-review-orphans {
187
+ display: grid;
188
+ gap: var(--st-spacing-2, 0.5rem);
189
+ }
190
+
191
+ .st-review-orphans__header {
192
+ align-items: center;
193
+ display: flex;
194
+ gap: var(--st-spacing-2, 0.5rem);
195
+ justify-content: space-between;
196
+ }
197
+
198
+ .st-review-orphans__heading {
199
+ align-items: center;
200
+ color: var(--st-semantic-text-secondary);
201
+ display: inline-flex;
202
+ font-size: 0.8125rem;
203
+ font-weight: 600;
204
+ gap: var(--st-spacing-1, 0.25rem);
205
+ margin: 0;
206
+ }
207
+
208
+ .st-review-orphans__error {
209
+ background: color-mix(in srgb, var(--st-semantic-feedback-danger, #b91c1c) 10%, white);
210
+ border: 1px solid var(--st-semantic-feedback-danger, #b91c1c);
211
+ border-radius: var(--st-radius-sm, 0.375rem);
212
+ color: var(--st-semantic-feedback-danger, #b91c1c);
213
+ font-size: 0.8125rem;
214
+ padding: var(--st-spacing-2, 0.5rem);
215
+ }
216
+
217
+ .st-review-orphans__list {
218
+ display: grid;
219
+ gap: var(--st-spacing-2, 0.5rem);
220
+ list-style: none;
221
+ margin: 0;
222
+ padding: 0;
223
+ }
224
+
225
+ .st-review-orphans__item {
226
+ background: var(--st-semantic-surface-raised, #ffffff);
227
+ border: 1px solid var(--st-semantic-border-subtle);
228
+ border-radius: var(--st-radius-md, 0.5rem);
229
+ display: grid;
230
+ gap: var(--st-spacing-2, 0.5rem);
231
+ padding: var(--st-spacing-3, 0.75rem);
232
+ }
233
+
234
+ .st-review-orphans__item--unread {
235
+ border-color: var(--st-semantic-border-interactive, #2563eb);
236
+ }
237
+
238
+ .st-review-orphans__item-top {
239
+ align-items: flex-start;
240
+ display: flex;
241
+ gap: var(--st-spacing-2, 0.5rem);
242
+ justify-content: space-between;
243
+ }
244
+
245
+ .st-review-orphans__excerpt {
246
+ color: var(--st-semantic-text-secondary);
247
+ font-size: 0.75rem;
248
+ font-style: italic;
249
+ margin: 0;
250
+ }
251
+
252
+ .st-review-orphans__preview {
253
+ color: var(--st-semantic-text-primary);
254
+ font-size: 0.8125rem;
255
+ line-height: 1.45;
256
+ margin: 0;
257
+ overflow: hidden;
258
+ text-overflow: ellipsis;
259
+ white-space: nowrap;
260
+ }
261
+
262
+ .st-review-orphans__actions {
263
+ display: flex;
264
+ flex-wrap: wrap;
265
+ gap: var(--st-spacing-1, 0.25rem);
266
+ }
267
+ </style>
@@ -0,0 +1,18 @@
1
+ import type { HTMLAttributes } from "svelte/elements";
2
+ import type { CollaborationActor, ReviewThread, ThreadReadState } from "@sentropic/design-system-review-core";
3
+ export type OrphanListProps = Omit<HTMLAttributes<HTMLElement>, "class"> & {
4
+ threads: readonly ReviewThread[];
5
+ currentUser: CollaborationActor;
6
+ readState?: ThreadReadState | null;
7
+ heading?: string;
8
+ class?: string;
9
+ onSelect?: (threadId: string) => void;
10
+ /** Optional re-anchor action; button is hidden when unbound (SPEC-r6 §2, §3). */
11
+ onReanchor?: (threadId: string) => void | Promise<void>;
12
+ onResolve?: (threadId: string) => void | Promise<void>;
13
+ onReopen?: (threadId: string) => void | Promise<void>;
14
+ };
15
+ declare const OrphanList: import("svelte").Component<OrphanListProps, {}, "">;
16
+ type OrphanList = ReturnType<typeof OrphanList>;
17
+ export default OrphanList;
18
+ //# sourceMappingURL=OrphanList.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OrphanList.svelte.d.ts","sourceRoot":"","sources":["../src/lib/OrphanList.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EACV,kBAAkB,EAClB,YAAY,EACZ,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAE9C,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,cAAc,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC,GAAG;IACzE,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;IACjC,WAAW,EAAE,kBAAkB,CAAC;IAChC,SAAS,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;IACnC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,iFAAiF;IACjF,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,SAAS,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACvD,CAAC;AA2IJ,QAAA,MAAM,UAAU,qDAAwC,CAAC;AACzD,KAAK,UAAU,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAChD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,110 @@
1
+ <script lang="ts" module>
2
+ import type { HTMLButtonAttributes } from "svelte/elements";
3
+ import type { ReviewMode } from "./CommentLayer.svelte";
4
+
5
+ export type ReviewModeToggleProps = Omit<
6
+ HTMLButtonAttributes,
7
+ "class" | "type" | "disabled" | "aria-pressed"
8
+ > & {
9
+ /** Current host-controlled mode (`"view"` or `"review"`). */
10
+ mode?: ReviewMode;
11
+ /** Number of open comment threads shown beside the label (e.g. "Review · 3"). */
12
+ openCount?: number;
13
+ /** Number of unread threads for the current user. */
14
+ unreadCount?: number;
15
+ /** Visible toggle label (default "Review"). */
16
+ label?: string;
17
+ disabled?: boolean;
18
+ class?: string;
19
+ onModeChange?: (mode: ReviewMode) => void;
20
+ };
21
+ </script>
22
+
23
+ <script lang="ts">
24
+ import { MessageSquare } from "@lucide/svelte";
25
+ import Badge from "./Badge.svelte";
26
+ import Button from "./Button.svelte";
27
+
28
+ let {
29
+ mode = "view",
30
+ openCount = 0,
31
+ unreadCount = 0,
32
+ label = "Review",
33
+ disabled = false,
34
+ class: className,
35
+ onModeChange,
36
+ onclick,
37
+ ...rest
38
+ }: ReviewModeToggleProps = $props();
39
+
40
+ const isReview = $derived(mode === "review");
41
+
42
+ const ariaLabel = $derived.by(() => {
43
+ const parts = [label];
44
+ if (openCount > 0) parts.push(`${openCount} open`);
45
+ if (unreadCount > 0) parts.push(`${unreadCount} unread`);
46
+ return parts.join(", ");
47
+ });
48
+
49
+ const classes = $derived(
50
+ [
51
+ "st-review-toggle",
52
+ isReview ? "st-review-toggle--active" : undefined,
53
+ className,
54
+ ]
55
+ .filter(Boolean)
56
+ .join(" "),
57
+ );
58
+
59
+ function handleClick(event: MouseEvent & { currentTarget: EventTarget & HTMLButtonElement }) {
60
+ onclick?.(event);
61
+ if (disabled) return;
62
+ onModeChange?.(isReview ? "view" : "review");
63
+ }
64
+ </script>
65
+
66
+ <Button
67
+ {...rest}
68
+ type="button"
69
+ variant={isReview ? "primary" : "secondary"}
70
+ size="sm"
71
+ class={classes}
72
+ {disabled}
73
+ aria-pressed={isReview ? "true" : "false"}
74
+ aria-label={ariaLabel}
75
+ data-review-mode={mode}
76
+ onclick={handleClick}
77
+ >
78
+ <MessageSquare size={15} strokeWidth={2} aria-hidden="true" />
79
+ <span class="st-review-toggle__label">
80
+ {label}{#if openCount > 0}<span class="st-review-toggle__count"> · {openCount}</span>{/if}
81
+ </span>
82
+ {#if unreadCount > 0}
83
+ <Badge
84
+ size="sm"
85
+ shape="circle"
86
+ tone="info"
87
+ class="st-review-toggle__unread"
88
+ aria-hidden="true"
89
+ >
90
+ {unreadCount}
91
+ </Badge>
92
+ {/if}
93
+ </Button>
94
+
95
+ <style>
96
+ :global(.st-review-toggle) {
97
+ gap: var(--st-component-review-toggle-gap, var(--st-spacing-2, 0.5rem));
98
+ }
99
+
100
+ .st-review-toggle__label {
101
+ align-items: center;
102
+ display: inline-flex;
103
+ font-variant-numeric: tabular-nums;
104
+ }
105
+
106
+ .st-review-toggle__count {
107
+ font-weight: 600;
108
+ opacity: 0.9;
109
+ }
110
+ </style>
@@ -0,0 +1,19 @@
1
+ import type { HTMLButtonAttributes } from "svelte/elements";
2
+ import type { ReviewMode } from "./CommentLayer.svelte";
3
+ export type ReviewModeToggleProps = Omit<HTMLButtonAttributes, "class" | "type" | "disabled" | "aria-pressed"> & {
4
+ /** Current host-controlled mode (`"view"` or `"review"`). */
5
+ mode?: ReviewMode;
6
+ /** Number of open comment threads shown beside the label (e.g. "Review · 3"). */
7
+ openCount?: number;
8
+ /** Number of unread threads for the current user. */
9
+ unreadCount?: number;
10
+ /** Visible toggle label (default "Review"). */
11
+ label?: string;
12
+ disabled?: boolean;
13
+ class?: string;
14
+ onModeChange?: (mode: ReviewMode) => void;
15
+ };
16
+ declare const ReviewModeToggle: import("svelte").Component<ReviewModeToggleProps, {}, "">;
17
+ type ReviewModeToggle = ReturnType<typeof ReviewModeToggle>;
18
+ export default ReviewModeToggle;
19
+ //# sourceMappingURL=ReviewModeToggle.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ReviewModeToggle.svelte.d.ts","sourceRoot":"","sources":["../src/lib/ReviewModeToggle.svelte.ts"],"names":[],"mappings":"AAGE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG,IAAI,CACtC,oBAAoB,EACpB,OAAO,GAAG,MAAM,GAAG,UAAU,GAAG,cAAc,CAC/C,GAAG;IACF,6DAA6D;IAC7D,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,iFAAiF;IACjF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qDAAqD;IACrD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,IAAI,CAAC;CAC3C,CAAC;AAoEJ,QAAA,MAAM,gBAAgB,2DAAwC,CAAC;AAC/D,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC5D,eAAe,gBAAgB,CAAC"}