@spunto/design-system 0.80.0 → 0.81.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/package.json
CHANGED
|
@@ -17,12 +17,18 @@
|
|
|
17
17
|
// side of the archive, a finished row gets its own Archive button on hover, and « Select » turns
|
|
18
18
|
// the rows into checkboxes for doing it in bulk. Only `done`/`failed` rows can be put away — a live
|
|
19
19
|
// conversation is dropped, not archived — so live rows cannot be picked.
|
|
20
|
+
//
|
|
21
|
+
// On hold (optional): the same kind of switch for the tasks in review someone set aside for later
|
|
22
|
+
// (their machine parked), and a row in review gets its own « On hold » / « Back to review » button
|
|
23
|
+
// on hover. Still `in-review` — the list just keeps them out of the way until asked.
|
|
20
24
|
|
|
21
25
|
import { useState, type ReactNode } from "react"
|
|
22
26
|
import {
|
|
23
27
|
ArchiveIcon,
|
|
24
28
|
ArchiveRestoreIcon,
|
|
25
29
|
CheckSquareIcon,
|
|
30
|
+
PauseCircleIcon,
|
|
31
|
+
Undo2Icon,
|
|
26
32
|
ChevronRightIcon,
|
|
27
33
|
Loader2Icon,
|
|
28
34
|
MessagesSquareIcon,
|
|
@@ -75,6 +81,16 @@ export interface TaskConversationListProps<T extends TaskConversation = TaskConv
|
|
|
75
81
|
/** An archive change is in flight: the selection's buttons wait for it. */
|
|
76
82
|
archiving?: boolean
|
|
77
83
|
|
|
84
|
+
/** Whether the « On hold » view is listed. Without `onHeldChange` there is no « On hold » switch. */
|
|
85
|
+
held?: boolean
|
|
86
|
+
onHeldChange?: (held: boolean) => void
|
|
87
|
+
/** How many conversations on hold match the search — drawn on the switch. */
|
|
88
|
+
heldCount?: number
|
|
89
|
+
/** Put a row in review on hold (`true`) or back to review (`false`) — its own button, on hover. Omitted → no button. */
|
|
90
|
+
onHoldChange?: (task: T, hold: boolean) => void
|
|
91
|
+
/** Which rows in review offer that button — e.g. only the reader's own. @default every one */
|
|
92
|
+
canHold?: (task: T) => boolean
|
|
93
|
+
|
|
78
94
|
/** @default "Agents" */
|
|
79
95
|
title?: string
|
|
80
96
|
/** Next to the title — typically the "New" task button. */
|
|
@@ -130,6 +146,7 @@ function ConversationRow({
|
|
|
130
146
|
picking,
|
|
131
147
|
picked,
|
|
132
148
|
onArchiveChange,
|
|
149
|
+
onHoldChange,
|
|
133
150
|
}: {
|
|
134
151
|
task: TaskConversation
|
|
135
152
|
selected: boolean
|
|
@@ -139,6 +156,8 @@ function ConversationRow({
|
|
|
139
156
|
picked?: boolean
|
|
140
157
|
/** A finished row's own Archive/Unarchive button, on hover. */
|
|
141
158
|
onArchiveChange?: (archived: boolean) => void
|
|
159
|
+
/** A row in review's own On hold / Back to review button, on hover. */
|
|
160
|
+
onHoldChange?: (hold: boolean) => void
|
|
142
161
|
}) {
|
|
143
162
|
const tone = task.pendingAction ? taskPendingActionConfig[task.pendingAction].textClass : taskStateStyle(task.state).textClass
|
|
144
163
|
const pickable = isFinished(task) && !task.pendingAction
|
|
@@ -182,7 +201,15 @@ function ConversationRow({
|
|
|
182
201
|
)}
|
|
183
202
|
</button>
|
|
184
203
|
)
|
|
185
|
-
|
|
204
|
+
const held = Boolean(task.onHoldAt)
|
|
205
|
+
const hover =
|
|
206
|
+
picking ? null
|
|
207
|
+
: onArchiveChange && pickable ? { label: archived ? "Unarchive" : "Archive", icon: archived ? ArchiveRestoreIcon : ArchiveIcon, run: () => onArchiveChange(!archived) }
|
|
208
|
+
: onHoldChange && task.state === "in-review" && !task.pendingAction
|
|
209
|
+
? { label: held ? "Back to review" : "On hold", icon: held ? Undo2Icon : PauseCircleIcon, run: () => onHoldChange(!held) }
|
|
210
|
+
: null
|
|
211
|
+
if (!hover) return row
|
|
212
|
+
const Icon = hover.icon
|
|
186
213
|
return (
|
|
187
214
|
<div className="group relative">
|
|
188
215
|
{row}
|
|
@@ -190,17 +217,36 @@ function ConversationRow({
|
|
|
190
217
|
on hover, and absent on touch — which has no hover, and has « Select » instead. */}
|
|
191
218
|
<button
|
|
192
219
|
type="button"
|
|
193
|
-
onClick={
|
|
194
|
-
aria-label={
|
|
195
|
-
title={
|
|
220
|
+
onClick={hover.run}
|
|
221
|
+
aria-label={hover.label}
|
|
222
|
+
title={hover.label}
|
|
196
223
|
className="absolute top-1.5 right-1.5 flex h-6 w-6 items-center justify-center rounded-md border border-border bg-card text-muted-foreground opacity-0 shadow-sm transition-opacity group-hover:opacity-100 hover:text-foreground focus-visible:opacity-100 pointer-coarse:hidden"
|
|
197
224
|
>
|
|
198
|
-
|
|
225
|
+
<Icon className="h-3.5 w-3.5" />
|
|
199
226
|
</button>
|
|
200
227
|
</div>
|
|
201
228
|
)
|
|
202
229
|
}
|
|
203
230
|
|
|
231
|
+
/** A switch at the end of the chips that flips the list to another view (« On hold », « Archived »). */
|
|
232
|
+
function ViewSwitch({ label, icon: Icon, count, active, onClick }: { label: string; icon: typeof ArchiveIcon; count?: number; active: boolean; onClick: () => void }) {
|
|
233
|
+
return (
|
|
234
|
+
<button
|
|
235
|
+
type="button"
|
|
236
|
+
onClick={onClick}
|
|
237
|
+
aria-pressed={active}
|
|
238
|
+
className={cn(
|
|
239
|
+
"flex shrink-0 touch-manipulation items-center gap-1 rounded-full border border-dashed px-2.5 py-1 text-[11px] font-medium transition-colors active:bg-muted pointer-coarse:px-3 pointer-coarse:py-1.5 pointer-coarse:text-[12px]",
|
|
240
|
+
active ? "border-solid border-foreground/30 bg-muted text-foreground" : "text-muted-foreground hover:bg-muted/60",
|
|
241
|
+
)}
|
|
242
|
+
>
|
|
243
|
+
<Icon className="h-3 w-3" />
|
|
244
|
+
{label}
|
|
245
|
+
{count !== undefined && <span className={cn("tabular-nums", !active && "text-muted-foreground/70")}>{count}</span>}
|
|
246
|
+
</button>
|
|
247
|
+
)
|
|
248
|
+
}
|
|
249
|
+
|
|
204
250
|
export function TaskConversationList<T extends TaskConversation>({
|
|
205
251
|
tasks,
|
|
206
252
|
total,
|
|
@@ -220,6 +266,11 @@ export function TaskConversationList<T extends TaskConversation>({
|
|
|
220
266
|
onArchiveChange,
|
|
221
267
|
onArchiveAllFinished,
|
|
222
268
|
archiving = false,
|
|
269
|
+
held = false,
|
|
270
|
+
onHeldChange,
|
|
271
|
+
heldCount,
|
|
272
|
+
onHoldChange,
|
|
273
|
+
canHold,
|
|
223
274
|
title = "Agents",
|
|
224
275
|
action,
|
|
225
276
|
className,
|
|
@@ -299,23 +350,29 @@ export function TaskConversationList<T extends TaskConversation>({
|
|
|
299
350
|
onClick={() => toggle(state)}
|
|
300
351
|
/>
|
|
301
352
|
))}
|
|
353
|
+
{onHeldChange && (
|
|
354
|
+
<ViewSwitch
|
|
355
|
+
label="On hold"
|
|
356
|
+
icon={PauseCircleIcon}
|
|
357
|
+
count={heldCount}
|
|
358
|
+
active={held}
|
|
359
|
+
onClick={() => {
|
|
360
|
+
stopPicking()
|
|
361
|
+
onHeldChange(!held)
|
|
362
|
+
}}
|
|
363
|
+
/>
|
|
364
|
+
)}
|
|
302
365
|
{onArchivedChange && (
|
|
303
|
-
<
|
|
304
|
-
|
|
366
|
+
<ViewSwitch
|
|
367
|
+
label="Archived"
|
|
368
|
+
icon={ArchiveIcon}
|
|
369
|
+
count={archivedCount}
|
|
370
|
+
active={archived}
|
|
305
371
|
onClick={() => {
|
|
306
372
|
stopPicking()
|
|
307
373
|
onArchivedChange(!archived)
|
|
308
374
|
}}
|
|
309
|
-
|
|
310
|
-
className={cn(
|
|
311
|
-
"flex shrink-0 touch-manipulation items-center gap-1 rounded-full border border-dashed px-2.5 py-1 text-[11px] font-medium transition-colors active:bg-muted pointer-coarse:px-3 pointer-coarse:py-1.5 pointer-coarse:text-[12px]",
|
|
312
|
-
archived ? "border-solid border-foreground/30 bg-muted text-foreground" : "text-muted-foreground hover:bg-muted/60",
|
|
313
|
-
)}
|
|
314
|
-
>
|
|
315
|
-
<ArchiveIcon className="h-3 w-3" />
|
|
316
|
-
Archived
|
|
317
|
-
{archivedCount !== undefined && <span className={cn("tabular-nums", !archived && "text-muted-foreground/70")}>{archivedCount}</span>}
|
|
318
|
-
</button>
|
|
375
|
+
/>
|
|
319
376
|
)}
|
|
320
377
|
</div>
|
|
321
378
|
|
|
@@ -374,9 +431,11 @@ export function TaskConversationList<T extends TaskConversation>({
|
|
|
374
431
|
<p className="px-3 py-4 text-xs leading-relaxed text-muted-foreground">
|
|
375
432
|
{query || states.length > 0
|
|
376
433
|
? "No conversation matches that filter."
|
|
377
|
-
:
|
|
378
|
-
? "
|
|
379
|
-
:
|
|
434
|
+
: held
|
|
435
|
+
? "Nothing on hold. Put a task in review on hold to park its machine and keep it out of the way until you come back to it."
|
|
436
|
+
: archived
|
|
437
|
+
? "No archived conversation. Archive a finished one to put it here."
|
|
438
|
+
: "No delegated work yet. Open a project and start a task."}
|
|
380
439
|
</p>
|
|
381
440
|
)}
|
|
382
441
|
|
|
@@ -395,6 +454,7 @@ export function TaskConversationList<T extends TaskConversation>({
|
|
|
395
454
|
picking={picking}
|
|
396
455
|
picked={picked.has(task.id)}
|
|
397
456
|
onArchiveChange={onArchiveChange && ((value) => onArchiveChange([task], value))}
|
|
457
|
+
onHoldChange={onHoldChange && (canHold?.(task) ?? true) ? (value) => onHoldChange(task, value) : undefined}
|
|
398
458
|
/>
|
|
399
459
|
))}
|
|
400
460
|
</div>
|
|
@@ -37,7 +37,7 @@ export type { NewTaskComposerProps } from "./new-task-composer"
|
|
|
37
37
|
export { clearTaskDraft, readTaskDraft, useTaskDraft } from "./prompt-draft"
|
|
38
38
|
|
|
39
39
|
// ── The cockpit ─────────────────────────────────────────────────────────────────────────────
|
|
40
|
-
export { TaskArchiveButton, TaskArchivedBadge, TaskCockpit, TaskPanelTabs } from "./task-cockpit"
|
|
40
|
+
export { TaskArchiveButton, TaskArchivedBadge, TaskCockpit, TaskHoldButton, TaskOnHoldBadge, TaskPanelTabs } from "./task-cockpit"
|
|
41
41
|
export type { TaskCockpitProps, TaskCockpitView } from "./task-cockpit"
|
|
42
42
|
export { TaskCockpitMobile, useVisualViewport } from "./task-cockpit-mobile"
|
|
43
43
|
export type { TaskCockpitMobileProps, VisualViewportState } from "./task-cockpit-mobile"
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
import { useEffect, useState, type ReactNode } from "react"
|
|
20
20
|
import { createPortal } from "react-dom"
|
|
21
|
-
import { ArchiveIcon, ArchiveRestoreIcon, CheckCircle2Icon, ChevronLeftIcon, Loader2Icon, SlidersHorizontalIcon, XIcon } from "lucide-react"
|
|
21
|
+
import { ArchiveIcon, ArchiveRestoreIcon, CheckCircle2Icon, ChevronLeftIcon, Loader2Icon, PauseCircleIcon, SlidersHorizontalIcon, Undo2Icon, XIcon } from "lucide-react"
|
|
22
22
|
|
|
23
23
|
import { cn, formatRelativeTime } from "../../utils"
|
|
24
24
|
import { useOverlayContainer } from "../spunto-provider"
|
|
@@ -127,6 +127,12 @@ function NavStatus({ task, action, since }: { task: TaskItem; action: TaskPendin
|
|
|
127
127
|
Archived
|
|
128
128
|
</>
|
|
129
129
|
)}
|
|
130
|
+
{task.state === "in-review" && task.onHoldAt && (
|
|
131
|
+
<>
|
|
132
|
+
<span aria-hidden>·</span>
|
|
133
|
+
On hold
|
|
134
|
+
</>
|
|
135
|
+
)}
|
|
130
136
|
</p>
|
|
131
137
|
)
|
|
132
138
|
}
|
|
@@ -174,6 +180,8 @@ export function TaskCockpitMobile({
|
|
|
174
180
|
titleUpdating,
|
|
175
181
|
onArchiveChange,
|
|
176
182
|
archiveUpdating,
|
|
183
|
+
onHoldChange,
|
|
184
|
+
holdUpdating,
|
|
177
185
|
backHref,
|
|
178
186
|
onBack,
|
|
179
187
|
render,
|
|
@@ -240,6 +248,24 @@ export function TaskCockpitMobile({
|
|
|
240
248
|
{task && <NavStatus task={task} action={action} since={since} />}
|
|
241
249
|
</div>
|
|
242
250
|
|
|
251
|
+
{task?.state === "in-review" && onHoldChange && (
|
|
252
|
+
<button
|
|
253
|
+
type="button"
|
|
254
|
+
disabled={action !== null || holdUpdating}
|
|
255
|
+
onClick={() => onHoldChange(!task.onHoldAt)}
|
|
256
|
+
aria-label={task.onHoldAt ? "Back to review" : "On hold"}
|
|
257
|
+
className={NAV_BUTTON}
|
|
258
|
+
>
|
|
259
|
+
{holdUpdating ? (
|
|
260
|
+
<Loader2Icon className="h-5 w-5 animate-spin" />
|
|
261
|
+
) : task.onHoldAt ? (
|
|
262
|
+
<Undo2Icon className="h-5 w-5" />
|
|
263
|
+
) : (
|
|
264
|
+
<PauseCircleIcon className="h-5 w-5" />
|
|
265
|
+
)}
|
|
266
|
+
</button>
|
|
267
|
+
)}
|
|
268
|
+
|
|
243
269
|
{task?.state === "in-review" && onAccept && (
|
|
244
270
|
<button
|
|
245
271
|
type="button"
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
// mount `TaskCockpitMobile` instead: a different screen, not this one squeezed.
|
|
25
25
|
|
|
26
26
|
import { useState, type ReactNode } from "react"
|
|
27
|
-
import { ArchiveIcon, ArchiveRestoreIcon, ArrowLeftIcon, CheckCircle2Icon, Loader2Icon, XCircleIcon } from "lucide-react"
|
|
27
|
+
import { ArchiveIcon, ArchiveRestoreIcon, ArrowLeftIcon, CheckCircle2Icon, Loader2Icon, PauseCircleIcon, Undo2Icon, XCircleIcon } from "lucide-react"
|
|
28
28
|
|
|
29
29
|
import { cn } from "../../utils"
|
|
30
30
|
import { Button } from "../button"
|
|
@@ -65,6 +65,14 @@ export interface TaskCockpitProps {
|
|
|
65
65
|
onArchiveChange?: (archived: boolean) => void
|
|
66
66
|
/** The archive toggle is in flight. */
|
|
67
67
|
archiveUpdating?: boolean
|
|
68
|
+
/**
|
|
69
|
+
* Set a task in review aside for later (`true` — the app parks its machine), or bring it back to
|
|
70
|
+
* « In review » (`false`); `task.onHoldAt` says which is offered. Only drawn on an `in-review`
|
|
71
|
+
* task. Omitted → no button.
|
|
72
|
+
*/
|
|
73
|
+
onHoldChange?: (hold: boolean) => void
|
|
74
|
+
/** The hold toggle is in flight. */
|
|
75
|
+
holdUpdating?: boolean
|
|
68
76
|
|
|
69
77
|
/** Back arrow in the top bar. Omitted when the cockpit sits next to its own list. */
|
|
70
78
|
backHref?: string
|
|
@@ -182,6 +190,8 @@ export function TaskCockpit({
|
|
|
182
190
|
titleUpdating,
|
|
183
191
|
onArchiveChange,
|
|
184
192
|
archiveUpdating,
|
|
193
|
+
onHoldChange,
|
|
194
|
+
holdUpdating,
|
|
185
195
|
backHref,
|
|
186
196
|
render,
|
|
187
197
|
view: viewProp,
|
|
@@ -238,14 +248,18 @@ export function TaskCockpit({
|
|
|
238
248
|
</h1>
|
|
239
249
|
<TaskStateBadge state={task.state} machine={task.machine} machinePaused={task.machinePaused} pendingAction={action} pendingSince={since} />
|
|
240
250
|
{task.userArchivedAt && <TaskArchivedBadge />}
|
|
251
|
+
{task.state === "in-review" && task.onHoldAt && <TaskOnHoldBadge />}
|
|
241
252
|
</div>
|
|
242
253
|
|
|
243
254
|
{!live && onArchiveChange && (
|
|
244
255
|
<TaskArchiveButton archived={Boolean(task.userArchivedAt)} updating={archiveUpdating} disabled={busy} onArchiveChange={onArchiveChange} />
|
|
245
256
|
)}
|
|
246
257
|
|
|
247
|
-
{live && (onAccept || onDrop) && (
|
|
258
|
+
{live && (onAccept || onDrop || onHoldChange) && (
|
|
248
259
|
<div className="flex shrink-0 items-center gap-2">
|
|
260
|
+
{task.state === "in-review" && onHoldChange && (
|
|
261
|
+
<TaskHoldButton onHold={Boolean(task.onHoldAt)} updating={holdUpdating} disabled={busy} onHoldChange={onHoldChange} />
|
|
262
|
+
)}
|
|
249
263
|
{task.state === "in-review" && onAccept && (
|
|
250
264
|
<Button size="sm" disabled={busy} onClick={onAccept} className="h-8 gap-1.5 px-3 text-xs">
|
|
251
265
|
{action === "accepting" ? <Loader2Icon className="h-3.5 w-3.5 animate-spin" /> : <CheckCircle2Icon className="h-3.5 w-3.5" />}
|
|
@@ -307,6 +321,54 @@ export function TaskArchivedBadge({ className }: { className?: string }) {
|
|
|
307
321
|
)
|
|
308
322
|
}
|
|
309
323
|
|
|
324
|
+
/** "On hold", next to the state of a task in review someone set aside for later. */
|
|
325
|
+
export function TaskOnHoldBadge({ className }: { className?: string }) {
|
|
326
|
+
return (
|
|
327
|
+
<span
|
|
328
|
+
className={cn(
|
|
329
|
+
"inline-flex shrink-0 items-center gap-1 rounded-full border border-border bg-muted/60 px-2 py-0.5 text-[10px] font-medium text-muted-foreground",
|
|
330
|
+
className,
|
|
331
|
+
)}
|
|
332
|
+
>
|
|
333
|
+
<PauseCircleIcon className="h-3 w-3" />
|
|
334
|
+
On hold
|
|
335
|
+
</span>
|
|
336
|
+
)
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
/**
|
|
340
|
+
* On hold / Back to review, on a task in review. A ghost button like Archive: it files the task
|
|
341
|
+
* (and parks its machine), it does not judge the work.
|
|
342
|
+
*/
|
|
343
|
+
export function TaskHoldButton({
|
|
344
|
+
onHold,
|
|
345
|
+
updating = false,
|
|
346
|
+
disabled = false,
|
|
347
|
+
onHoldChange,
|
|
348
|
+
className,
|
|
349
|
+
}: {
|
|
350
|
+
onHold: boolean
|
|
351
|
+
updating?: boolean
|
|
352
|
+
disabled?: boolean
|
|
353
|
+
onHoldChange: (hold: boolean) => void
|
|
354
|
+
className?: string
|
|
355
|
+
}) {
|
|
356
|
+
const Icon = updating ? Loader2Icon : onHold ? Undo2Icon : PauseCircleIcon
|
|
357
|
+
return (
|
|
358
|
+
<Button
|
|
359
|
+
variant="ghost"
|
|
360
|
+
size="sm"
|
|
361
|
+
disabled={disabled || updating}
|
|
362
|
+
onClick={() => onHoldChange(!onHold)}
|
|
363
|
+
title={onHold ? "Back to « In review »" : "Park its machine and set it aside until you come back to it"}
|
|
364
|
+
className={cn("h-8 shrink-0 gap-1.5 px-3 text-xs text-muted-foreground", className)}
|
|
365
|
+
>
|
|
366
|
+
<Icon className={cn("h-3.5 w-3.5", updating && "animate-spin")} />
|
|
367
|
+
{onHold ? "Back to review" : "On hold"}
|
|
368
|
+
</Button>
|
|
369
|
+
)
|
|
370
|
+
}
|
|
371
|
+
|
|
310
372
|
/**
|
|
311
373
|
* Archive / Unarchive, on a finished task. Quiet on purpose — a ghost button: it files the
|
|
312
374
|
* conversation, it does nothing to the work, so it must not look like Accept or Drop.
|
|
@@ -66,6 +66,8 @@ export interface TaskItem {
|
|
|
66
66
|
machinePaused?: boolean
|
|
67
67
|
/** When a member put this finished task away — it then lives in the « Archived » view. Null = not archived. */
|
|
68
68
|
userArchivedAt?: string | null
|
|
69
|
+
/** When a member set this task in review aside for later — it then lives in the « On hold » view. Null = not on hold. */
|
|
70
|
+
onHoldAt?: string | null
|
|
69
71
|
}
|
|
70
72
|
|
|
71
73
|
/** A row of the org-wide conversation list: a task plus the project it belongs to. */
|