@heyramzi/ui 2.0.1 → 2.2.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 +48 -24
- package/scripts/sync-shadcn.mjs +3 -4
- package/src/agents/agent-avatar.svelte +604 -575
- package/src/agents/agent-cast.svelte +179 -183
- package/src/agents/demo.svelte +125 -113
- package/src/agents/helpers.ts +23 -17
- package/src/agents/index.ts +4 -4
- package/src/agents/page-state.ts +6 -6
- package/src/agents/types.ts +6 -6
- package/src/ai/ai-button/AiButton.svelte +4 -12
- package/src/ai/generation-progress/GenerationProgress.svelte +10 -3
- package/src/ai/prompt-input/PromptInputTextarea.svelte +1 -2
- package/src/ai/response/Response.css +2 -3
- package/src/animations/avatar-group-hover.css +2 -16
- package/src/animations/card-tilt.css +3 -6
- package/src/animations/digit-pop-in.css +2 -15
- package/src/animations/dropdown.css +4 -17
- package/src/animations/input-clear-dissolve.css +5 -18
- package/src/animations/input-shake.css +9 -41
- package/src/animations/learn-more-hover.css +17 -9
- package/src/animations/like-button.css +2 -4
- package/src/animations/page-side-by-side.css +2 -10
- package/src/animations/plus-menu-morph.css +2 -5
- package/src/animations/shimmer-text.css +5 -18
- package/src/animations/spinning-counter.css +2 -6
- package/src/animations/success-check.css +2 -15
- package/src/animations/thinking-states.css +2 -7
- package/src/brand/brand.test.ts +21 -5
- package/src/brand/index.ts +4 -10
- package/src/canvas/README.md +9 -12
- package/src/canvas/card/card-frame.svelte +43 -39
- package/src/canvas/card/resize-handles.svelte +89 -80
- package/src/canvas/chrome/chrome-zoom.svelte +101 -100
- package/src/canvas/chrome/lock-badge.svelte +8 -8
- package/src/canvas/chrome/side-handles.svelte +24 -19
- package/src/canvas/chrome/size-chip.svelte +30 -30
- package/src/canvas/chrome/snap-guides.svelte +20 -20
- package/src/canvas/components/icons/ToolIcon.svelte +8 -8
- package/src/canvas/components/shared/svg/PreviewSvg.svelte +19 -19
- package/src/canvas/components/shared/svg/ShapeOutline.svelte +71 -48
- package/src/canvas/components/shared/svg/StrokeNode.svelte +21 -27
- package/src/canvas/components/shared/svg/TextRule.svelte +25 -17
- package/src/canvas/edges/bend-handle.svelte +46 -46
- package/src/canvas/edges/edge-gradient.svelte +10 -10
- package/src/canvas/edges/gradient-edge.svelte +45 -29
- package/src/canvas/editor/lock.test.ts +6 -1
- package/src/canvas/editor/style.ts +7 -1
- package/src/canvas/headless/svg-figure.test.ts +5 -1
- package/src/canvas/lod/lod-switch.svelte +111 -106
- package/src/canvas/pen/PenField.svelte +87 -81
- package/src/canvas/pen/PenOverlay.svelte +127 -127
- package/src/canvas/pen/ShapeNode.svelte +31 -32
- package/src/canvas/pen/TextNode.svelte +54 -53
- package/src/canvas/pen/host-field.test.svelte +7 -7
- package/src/canvas/pen/shapes.ts +7 -1
- package/src/canvas/screen/GlyphIcon.svelte +22 -17
- package/src/canvas/screen/PartView.svelte +138 -72
- package/src/canvas/screen/ScreenBody.svelte +81 -60
- package/src/canvas/screen/ScreenCard.svelte +20 -20
- package/src/canvas/ui/CanvasToolbar.svelte +173 -85
- package/src/canvas/ui/FrameLayer.svelte +59 -59
- package/src/canvas/ui/PenLayer.svelte +39 -30
- package/src/canvas/ui/StylePanel.svelte +119 -102
- package/src/canvas/ui/canvas-grid.svelte +137 -129
- package/src/charts/animated-value.svelte +1 -1
- package/src/charts/area-chart.css +2 -5
- package/src/charts/area-chart.svelte +1 -1
- package/src/charts/bar-chart.css +2 -3
- package/src/charts/bar-chart.svelte +1 -1
- package/src/charts/charts.css +5 -17
- package/src/charts/crosshair.svelte +1 -1
- package/src/charts/dashboard/dashboard-empty.svelte +25 -25
- package/src/charts/dashboard/dashboard-section.svelte +24 -24
- package/src/charts/dashboard/data-panel.svelte +50 -50
- package/src/charts/dashboard/data-sort-head.svelte +56 -56
- package/src/charts/dashboard/data-table.svelte +138 -138
- package/src/charts/dashboard/panel-grid.svelte +30 -30
- package/src/charts/dashboard/period-filter.svelte +25 -25
- package/src/charts/dashboard/rating-chip.svelte +19 -19
- package/src/charts/dashboard/stat-band.svelte +32 -32
- package/src/charts/dashboard/stat-tile.svelte +106 -99
- package/src/charts/donut-chart.svelte +1 -1
- package/src/charts/edge-fade.svelte +1 -1
- package/src/charts/figure.svelte +1 -1
- package/src/charts/gauge-chart.css +4 -7
- package/src/charts/gauge-chart.svelte +1 -1
- package/src/charts/hover-focus.svelte +1 -1
- package/src/charts/legend.css +1 -3
- package/src/charts/legend.svelte +1 -1
- package/src/charts/line-chart.svelte +1 -1
- package/src/charts/number-chart.css +6 -9
- package/src/charts/number-chart.svelte +1 -1
- package/src/charts/reference-line.svelte +19 -19
- package/src/charts/reveal.svelte +1 -1
- package/src/charts/ring-chart.css +2 -4
- package/src/charts/ring-chart.svelte +1 -1
- package/src/charts/sparkline.svelte +5 -2
- package/src/charts/stat-card.svelte +1 -1
- package/src/charts/time-series-chart.css +2 -5
- package/src/charts/trend-pill.css +2 -4
- package/src/charts/trend-pill.svelte +1 -1
- package/src/components/copy/copy-button.svelte +93 -98
- package/src/components/copy/copy-button.test.ts +10 -2
- package/src/components/data-table/infinite-scroll.svelte +42 -42
- package/src/components/data-table/pagination.svelte +34 -22
- package/src/components/data-table/row-arrow.svelte +19 -16
- package/src/components/data-table/row-context-menu.svelte +52 -52
- package/src/components/data-table/sortable-head.svelte +25 -25
- package/src/components/data-table/table-skeleton.svelte +41 -36
- package/src/components/docs/doc-page.svelte +18 -9
- package/src/components/docs/on-this-page.svelte +16 -3
- package/src/components/docs/scroll-spy.svelte.ts +2 -3
- package/src/components/field-row/field-row.svelte +10 -8
- package/src/components/hold-to-confirm/hold-to-confirm.svelte +5 -1
- package/src/components/icon/icon.svelte +14 -14
- package/src/components/language-flag/language-flag.svelte +3 -1
- package/src/components/list-page/detail-empty.svelte +34 -34
- package/src/components/list-page/detail-header.svelte +55 -47
- package/src/components/list-page/detail-panel.svelte +51 -59
- package/src/components/list-page/detail-row.svelte +19 -19
- package/src/components/list-page/detail-stack.svelte +21 -21
- package/src/components/list-page/empty-state.svelte +30 -30
- package/src/components/list-page/filter-item.svelte +20 -20
- package/src/components/list-page/filter-popover.svelte +60 -55
- package/src/components/list-page/grouped-list.svelte +4 -2
- package/src/components/list-page/index.ts +8 -4
- package/src/components/list-page/list-page-shell.svelte +2 -5
- package/src/components/list-page/master-detail.svelte +87 -88
- package/src/components/list-page/notice-bar.svelte +38 -38
- package/src/components/list-page/prev-next.svelte +63 -63
- package/src/components/list-page/rail-body.svelte +18 -18
- package/src/components/list-page/rail-empty.svelte +23 -30
- package/src/components/list-page/rail-head.svelte +24 -24
- package/src/components/list-page/rail-row.svelte +77 -73
- package/src/components/list-page/section-host.ts +2 -3
- package/src/components/locale-switch/locale-switch.svelte +41 -41
- package/src/components/mark/mark.svelte +34 -38
- package/src/components/open-in/index.ts +1 -5
- package/src/components/open-in/open-in.svelte +40 -40
- package/src/components/picker/mark-picker.svelte +49 -49
- package/src/components/picker/picker.svelte +5 -3
- package/src/components/section-header/index.ts +1 -0
- package/src/components/section-header/section-header.svelte +1 -1
- package/src/components/section-header/section-header.test.ts +7 -1
- package/src/components/section-header/section-label.svelte +39 -0
- package/src/components/segmented/animated-tabs.svelte +31 -2
- package/src/components/segmented/collapse.test.ts +2 -1
- package/src/components/segmented/index.ts +2 -0
- package/src/components/segmented/segment.svelte +52 -49
- package/src/components/segmented/segmented-filter.svelte +79 -80
- package/src/components/segmented/segmented-nav.svelte +34 -40
- package/src/components/segmented/segmented-overflow.svelte +53 -50
- package/src/components/segmented/segmented-track.svelte +62 -46
- package/src/components/segmented/segmented.ts +2 -3
- package/src/components/star-rating-input/star-rating-input.svelte +103 -103
- package/src/components/svg/svg.svelte +4 -4
- package/src/components/table-view/table-view.svelte +17 -2
- package/src/components/table-view/table-view.test.ts +7 -1
- package/src/components/table-view/types.ts +11 -11
- package/src/components/tags-input/index.ts +13 -0
- package/src/components/tags-input/tags-input.svelte +305 -0
- package/src/components/tags-input/tags.test.ts +64 -0
- package/src/components/tags-input/tags.ts +142 -0
- package/src/components/theme/index.ts +2 -4
- package/src/components/theme/theme-provider.svelte +1 -3
- package/src/components/toolbar/index.ts +2 -0
- package/src/components/{list-page → toolbar}/toolbar-search.svelte +25 -25
- package/src/components/toolbar/toolbar.svelte +13 -9
- package/src/components/toolbar/toolbar.test.ts +10 -1
- package/src/design/index.css +21 -78
- package/src/design/polish.css +26 -35
- package/src/editor/editor-toolbar.svelte +104 -99
- package/src/editor/editor.svelte +296 -266
- package/src/editor/image-toolbar.svelte +20 -22
- package/src/editor/index.ts +1 -4
- package/src/editor/inline-editor.svelte +280 -238
- package/src/editor/markdown.ts +15 -15
- package/src/editor/renderer.svelte +71 -71
- package/src/editor/slash-menu.svelte +24 -27
- package/src/effects/animated-beam/diagrams/BeamSvg.svelte +1 -1
- package/src/effects/image-comparison/ImageComparison.svelte +11 -1
- package/src/effects/interactive-hover-button/InteractiveHoverButton.svelte +59 -46
- package/src/effects/magic-card/MagicCard.css +14 -7
- package/src/effects/marquee/Marquee.svelte +3 -5
- package/src/effects/reveal/observe.ts +0 -3
- package/src/effects/spotlight/Spotlight.svelte +1 -1
- package/src/effects/theme-toggle/ThemeToggle.css +25 -22
- package/src/effects/theme-toggle/ThemeToggle.svelte +6 -7
- package/src/gallery.test.ts +14 -4
- package/src/inbox/README.md +27 -0
- package/src/inbox/inbox.test.ts +214 -0
- package/src/inbox/index.ts +31 -0
- package/src/inbox/logic.ts +169 -0
- package/src/inbox/thread-inbox.svelte +439 -0
- package/src/inbox/types.ts +161 -0
- package/src/lib/theme-transition.ts +2 -4
- package/src/lib/tone.ts +2 -4
- package/src/lib/utils.ts +2 -2
- package/src/modules.test.ts +105 -0
- package/src/onboarding/define-tours.test.ts +55 -40
- package/src/onboarding/define-tours.ts +23 -23
- package/src/onboarding/demo.svelte +24 -5
- package/src/onboarding/index.ts +1 -8
- package/src/onboarding/onboarding-provider.svelte +19 -7
- package/src/onboarding/onboarding.svelte.ts +16 -16
- package/src/onboarding/pick.test.ts +61 -52
- package/src/onboarding/pick.ts +16 -13
- package/src/onboarding/stores.test.ts +80 -80
- package/src/onboarding/stores.ts +41 -39
- package/src/onboarding/tour-card.svelte +30 -5
- package/src/onboarding/tour-runner.svelte +12 -3
- package/src/onboarding/types.ts +20 -12
- package/src/onboarding/wait.ts +22 -22
- package/src/panel/README.md +5 -0
- package/src/panel/index.ts +2 -0
- package/src/panel/side-panel.svelte +194 -0
- package/src/record/README.md +3 -0
- package/src/record/demo-data.ts +352 -0
- package/src/record/field-section.svelte +57 -0
- package/src/record/fields.ts +194 -0
- package/src/record/format.ts +94 -0
- package/src/{tasks/record → record}/index.ts +49 -35
- package/src/{tasks/record → record}/info-list.svelte +145 -114
- package/src/record/kinds.ts +42 -0
- package/src/record/logic.ts +326 -0
- package/src/record/next-up.svelte +81 -0
- package/src/{tasks/record → record}/project-list.svelte +56 -50
- package/src/{tasks/record → record}/record-demo.svelte +130 -110
- package/src/{tasks/record → record}/record-header.svelte +37 -28
- package/src/{tasks/record → record}/record-shell.svelte +54 -54
- package/src/record/record-stats.svelte +48 -0
- package/src/record/record-timeline.svelte +251 -0
- package/src/record/record.test.ts +471 -0
- package/src/{tasks/record → record}/steps-rail.svelte +225 -216
- package/src/record/types.ts +299 -0
- package/src/record/where-we-are.svelte +125 -0
- package/src/shadcn/button/button.svelte +1 -1
- package/src/shadcn/card/card-title.svelte +1 -5
- package/src/shadcn/hooks/use-highlighted-code.svelte.ts +2 -13
- package/src/shadcn/sheet/sheet-content.svelte +2 -4
- package/src/shadcn/table/table-cell.svelte +2 -3
- package/src/shadcn/utilities.css +3 -8
- package/src/slides/Controls.svelte +150 -124
- package/src/slides/Deck.svelte +243 -238
- package/src/slides/Fragment.svelte +64 -57
- package/src/slides/Overview.svelte +106 -101
- package/src/slides/Presenter.svelte +300 -266
- package/src/slides/Slide.svelte +185 -170
- package/src/slides/SlideList.svelte +16 -12
- package/src/slides/ambient.d.ts +1 -1
- package/src/slides/bridges.ts +42 -23
- package/src/slides/deck-controller.svelte.ts +47 -35
- package/src/slides/demo-slides.svelte +330 -306
- package/src/slides/demo.svelte +164 -160
- package/src/slides/export/capture.ts +20 -16
- package/src/slides/export/ffmpeg.ts +43 -38
- package/src/slides/export/index.ts +5 -5
- package/src/slides/export/launch.ts +3 -1
- package/src/slides/export/pdf.ts +30 -27
- package/src/slides/export/types.ts +10 -8
- package/src/slides/index.ts +11 -11
- package/src/slides/labels.ts +22 -19
- package/src/slides/layout.ts +9 -2
- package/src/slides/model.ts +4 -4
- package/src/slides/navigation.ts +43 -31
- package/src/slides/theme.css +5 -7
- package/src/slides/types.ts +9 -10
- package/src/status/README.md +18 -0
- package/src/status/define-statuses.ts +25 -0
- package/src/status/index.ts +11 -0
- package/src/{tasks → status}/status-badge.svelte +3 -1
- package/src/{tasks → status}/status-dot.svelte +1 -3
- package/src/{tasks → status}/status-icon.svelte +1 -1
- package/src/status/status-types.ts +40 -0
- package/src/tasks/README.md +1 -1
- package/src/tasks/board-order.ts +2 -4
- package/src/tasks/demo.svelte +192 -34
- package/src/tasks/detail/detail-demo.svelte +75 -15
- package/src/tasks/detail/detail-types.ts +45 -45
- package/src/tasks/detail/task-detail.svelte +40 -10
- package/src/tasks/detail/task-property.svelte +8 -2
- package/src/tasks/detail/task-thread.svelte +53 -12
- package/src/tasks/gantt/gantt-bar.svelte +17 -6
- package/src/tasks/gantt/gantt-grid.svelte +40 -9
- package/src/tasks/gantt/gantt-group-row.svelte +8 -2
- package/src/tasks/gantt/gantt-header.svelte +9 -3
- package/src/tasks/gantt/gantt-task-row.svelte +26 -6
- package/src/tasks/gantt/gantt.css +2 -1
- package/src/tasks/gantt/gantt.test.ts +4 -2
- package/src/tasks/gantt/logic.test.ts +110 -20
- package/src/tasks/gantt/logic.ts +42 -6
- package/src/tasks/inbox/inbox-card.svelte +15 -7
- package/src/tasks/inbox/inbox-draft.svelte +1 -1
- package/src/tasks/inbox/inbox-logic.ts +6 -40
- package/src/tasks/inbox/inbox-statuses.ts +24 -24
- package/src/tasks/inbox/inbox-trace.svelte +9 -3
- package/src/tasks/inbox/inbox-types.ts +54 -58
- package/src/tasks/inbox/index.ts +22 -21
- package/src/tasks/index.ts +52 -53
- package/src/tasks/kanban-board.svelte +16 -12
- package/src/tasks/kanban-types.ts +2 -3
- package/src/tasks/presets/sales.ts +7 -7
- package/src/tasks/task-gantt.svelte +28 -8
- package/src/tasks/task-list.svelte +41 -17
- package/src/tasks/time/duration.ts +40 -40
- package/src/tasks/time/time-chip.svelte +9 -2
- package/src/tasks/time/time-dot.svelte +1 -1
- package/src/tasks/time/time-ring.svelte +11 -3
- package/src/tasks/time/time-tracker.svelte +57 -15
- package/src/tasks/time/time-types.ts +57 -57
- package/src/tasks/use-kanban-dnd.svelte.ts +2 -3
- package/src/thread/README.md +31 -0
- package/src/thread/index.ts +12 -0
- package/src/thread/logic.ts +61 -0
- package/src/thread/thread.svelte +432 -0
- package/src/thread/thread.test.ts +73 -0
- package/src/thread/types.ts +93 -0
- package/src/tokens/craft.css +17 -53
- package/src/tokens/index.css +3 -13
- package/src/tokens/palette.css +13 -11
- package/src/tokens/primitives.css +10 -23
- package/src/components/list-page/section-label.svelte +0 -39
- package/src/tasks/define-statuses.ts +0 -32
- package/src/tasks/inbox/inbox.svelte +0 -203
- package/src/tasks/record/demo-data.ts +0 -286
- package/src/tasks/record/field-section.svelte +0 -53
- package/src/tasks/record/fields.ts +0 -142
- package/src/tasks/record/format.ts +0 -87
- package/src/tasks/record/kinds.ts +0 -42
- package/src/tasks/record/logic.ts +0 -324
- package/src/tasks/record/next-up.svelte +0 -70
- package/src/tasks/record/record-stats.svelte +0 -48
- package/src/tasks/record/record-timeline.svelte +0 -231
- package/src/tasks/record/record.test.ts +0 -350
- package/src/tasks/record/types.ts +0 -280
- package/src/tasks/record/where-we-are.svelte +0 -121
- package/src/tasks/side-panel.svelte +0 -193
- package/src/tasks/status-types.ts +0 -40
- /package/src/components/{list-page → toolbar}/toolbar-trigger.ts +0 -0
- /package/src/{tasks → panel}/side-panel-types.ts +0 -0
- /package/src/{tasks/record → record}/gutter.ts +0 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from "svelte";
|
|
3
|
+
import { ArrowBendDownRight, Check, MapPin, PencilSimple, Trash } from "phosphor-svelte";
|
|
4
|
+
import { cn } from "../lib/utils.js";
|
|
5
|
+
import { AgentAvatar } from "../agents/index.js";
|
|
6
|
+
import { TONE_CLASS } from "../lib/tone.js";
|
|
7
|
+
import RichRenderer from "../editor/renderer.svelte";
|
|
8
|
+
import { Skeleton } from "../shadcn/skeleton/index.js";
|
|
9
|
+
import { buildThread, fillCount, resolveThreadLabels, resolvedCount } from "./logic.js";
|
|
10
|
+
import type { ThreadComment, ThreadLabels, ThreadPost } from "./types.js";
|
|
11
|
+
|
|
12
|
+
interface Props {
|
|
13
|
+
comments: ThreadComment[];
|
|
14
|
+
/** Rows still on their way. Draws skeleton rows in place of the thread. */
|
|
15
|
+
loading?: boolean;
|
|
16
|
+
labels?: Partial<ThreadLabels>;
|
|
17
|
+
/** Replaces the default avatar for a person or an agent, drawn in a 24px slot. */
|
|
18
|
+
avatar?: Snippet<[ThreadComment]>;
|
|
19
|
+
/** Content under a comment's body, such as files. */
|
|
20
|
+
attachments?: Snippet<[ThreadComment]>;
|
|
21
|
+
/** Replaces the default "Pinned" chip on a comment that has an anchor. */
|
|
22
|
+
anchorChip?: Snippet<[ThreadComment]>;
|
|
23
|
+
/** How a timestamp reads. Defaults to a short date. */
|
|
24
|
+
when?: (comment: ThreadComment) => string;
|
|
25
|
+
/** Returns false to keep the draft. Without it no composer shows. */
|
|
26
|
+
onPost?: (post: ThreadPost) => void | boolean | Promise<void | boolean>;
|
|
27
|
+
onEdit?: (comment: ThreadComment, body: string) => void | Promise<void>;
|
|
28
|
+
onDelete?: (comment: ThreadComment) => void | Promise<void>;
|
|
29
|
+
/** Without it a root has no resolve button. */
|
|
30
|
+
onResolve?: (comment: ThreadComment, resolved: boolean) => void | Promise<void>;
|
|
31
|
+
/** A click on a pinned comment's chip, to move a canvas to its node. */
|
|
32
|
+
onAnchor?: (comment: ThreadComment) => void;
|
|
33
|
+
/** Whose comments carry the edit and delete buttons. A rich comment can't be edited here. */
|
|
34
|
+
canEdit?: (comment: ThreadComment) => boolean;
|
|
35
|
+
class?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
let {
|
|
39
|
+
comments,
|
|
40
|
+
loading = false,
|
|
41
|
+
labels: labelOverrides,
|
|
42
|
+
avatar,
|
|
43
|
+
attachments,
|
|
44
|
+
anchorChip,
|
|
45
|
+
when = (comment) =>
|
|
46
|
+
new Date(comment.createdAt).toLocaleDateString(undefined, { month: "short", day: "numeric" }),
|
|
47
|
+
onPost,
|
|
48
|
+
onEdit,
|
|
49
|
+
onDelete,
|
|
50
|
+
onResolve,
|
|
51
|
+
onAnchor,
|
|
52
|
+
canEdit = () => false,
|
|
53
|
+
class: className,
|
|
54
|
+
}: Props = $props();
|
|
55
|
+
|
|
56
|
+
let labels = $derived(resolveThreadLabels(labelOverrides));
|
|
57
|
+
let nodes = $derived(buildThread(comments));
|
|
58
|
+
let resolved = $derived(resolvedCount(nodes));
|
|
59
|
+
let showResolved = $state(false);
|
|
60
|
+
let shown = $derived(showResolved ? nodes : nodes.filter((node) => !node.comment.resolved));
|
|
61
|
+
|
|
62
|
+
let draft = $state("");
|
|
63
|
+
let replyTo = $state<string | null>(null);
|
|
64
|
+
let replyDraft = $state("");
|
|
65
|
+
let sending = $state(false);
|
|
66
|
+
let editingId = $state<string | null>(null);
|
|
67
|
+
let editDraft = $state("");
|
|
68
|
+
|
|
69
|
+
async function post(body: string, parentId: string | null): Promise<boolean> {
|
|
70
|
+
const text = body.trim();
|
|
71
|
+
if (!text || sending || !onPost) return false;
|
|
72
|
+
sending = true;
|
|
73
|
+
try {
|
|
74
|
+
return (await onPost({ body: text, parentId })) !== false;
|
|
75
|
+
} finally {
|
|
76
|
+
sending = false;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
async function sendRoot(): Promise<void> {
|
|
81
|
+
if (await post(draft, null)) draft = "";
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async function sendReply(): Promise<void> {
|
|
85
|
+
if (await post(replyDraft, replyTo)) {
|
|
86
|
+
replyDraft = "";
|
|
87
|
+
replyTo = null;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function submitOnModEnter(event: KeyboardEvent, send: () => Promise<void>): void {
|
|
92
|
+
if (event.key === "Enter" && (event.metaKey || event.ctrlKey)) {
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
void send();
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async function saveEdit(comment: ThreadComment): Promise<void> {
|
|
99
|
+
const body = editDraft.trim();
|
|
100
|
+
editingId = null;
|
|
101
|
+
if (!body || body === comment.body) return;
|
|
102
|
+
await onEdit?.(comment, body);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function initial(name: string): string {
|
|
106
|
+
return name.trim().charAt(0).toLocaleUpperCase() || "?";
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
{#snippet composer(
|
|
111
|
+
value: string,
|
|
112
|
+
placeholder: string,
|
|
113
|
+
onSend: () => Promise<void>,
|
|
114
|
+
set: (next: string) => void,
|
|
115
|
+
isReply: boolean,
|
|
116
|
+
)}
|
|
117
|
+
<div
|
|
118
|
+
class="rounded-lg border border-input transition-shadow focus-within:ring-3 focus-within:ring-ring/50"
|
|
119
|
+
>
|
|
120
|
+
<!-- svelte-ignore a11y_autofocus -->
|
|
121
|
+
<textarea
|
|
122
|
+
{value}
|
|
123
|
+
oninput={(event) => set(event.currentTarget.value)}
|
|
124
|
+
onkeydown={(event) => submitOnModEnter(event, onSend)}
|
|
125
|
+
rows={2}
|
|
126
|
+
{placeholder}
|
|
127
|
+
aria-label={placeholder}
|
|
128
|
+
autofocus={isReply}
|
|
129
|
+
class="block max-h-60 min-h-16 w-full resize-none border-0 bg-transparent px-3 py-2 text-sm leading-relaxed outline-none [field-sizing:content] placeholder:text-muted-foreground"
|
|
130
|
+
></textarea>
|
|
131
|
+
<div class="flex justify-end px-2 pb-2">
|
|
132
|
+
<button
|
|
133
|
+
type="button"
|
|
134
|
+
class="thread-button thread-primary"
|
|
135
|
+
onclick={onSend}
|
|
136
|
+
disabled={!value.trim() || sending}
|
|
137
|
+
>
|
|
138
|
+
{sending ? labels.sending : isReply ? labels.reply : labels.send}
|
|
139
|
+
</button>
|
|
140
|
+
</div>
|
|
141
|
+
</div>
|
|
142
|
+
{/snippet}
|
|
143
|
+
|
|
144
|
+
{#snippet row(comment: ThreadComment, isRoot: boolean)}
|
|
145
|
+
<div class="group/row relative flex gap-3">
|
|
146
|
+
<span class="relative size-6 shrink-0">
|
|
147
|
+
{#if avatar}
|
|
148
|
+
{@render avatar(comment)}
|
|
149
|
+
{:else if comment.author.kind === "agent"}
|
|
150
|
+
<AgentAvatar name={comment.author.name} size={24} paused interactive={false} />
|
|
151
|
+
{:else if comment.author.avatar}
|
|
152
|
+
<img src={comment.author.avatar} alt="" class="size-6 rounded-full object-cover" />
|
|
153
|
+
{:else}
|
|
154
|
+
<span
|
|
155
|
+
class="grid size-6 place-items-center rounded-full bg-muted text-xs font-medium text-muted-foreground"
|
|
156
|
+
aria-hidden="true"
|
|
157
|
+
>
|
|
158
|
+
{initial(comment.author.name)}
|
|
159
|
+
</span>
|
|
160
|
+
{/if}
|
|
161
|
+
</span>
|
|
162
|
+
|
|
163
|
+
<div class="min-w-0 flex-1">
|
|
164
|
+
<div class="flex min-h-6 flex-wrap items-center gap-x-2">
|
|
165
|
+
<span class="truncate text-[13px] font-medium">{comment.author.name}</span>
|
|
166
|
+
{#if comment.author.kind === "agent"}
|
|
167
|
+
<span
|
|
168
|
+
class={cn(
|
|
169
|
+
"inline-flex h-5 items-center rounded-sm border px-1.5 text-xs font-medium",
|
|
170
|
+
TONE_CLASS.accent,
|
|
171
|
+
)}
|
|
172
|
+
>
|
|
173
|
+
{labels.agent}
|
|
174
|
+
</span>
|
|
175
|
+
{/if}
|
|
176
|
+
<span class="text-xs text-muted-foreground tabular-nums">{when(comment)}</span>
|
|
177
|
+
{#if comment.edited}
|
|
178
|
+
<span class="text-xs text-muted-foreground">{labels.edited}</span>
|
|
179
|
+
{/if}
|
|
180
|
+
{#if comment.anchor}
|
|
181
|
+
{#if anchorChip}
|
|
182
|
+
{@render anchorChip(comment)}
|
|
183
|
+
{:else if onAnchor}
|
|
184
|
+
<button type="button" class="thread-chip" onclick={() => onAnchor(comment)}>
|
|
185
|
+
<MapPin class="size-3" aria-hidden="true" />{labels.pinned}
|
|
186
|
+
</button>
|
|
187
|
+
{:else}
|
|
188
|
+
<span class="thread-chip"
|
|
189
|
+
><MapPin class="size-3" aria-hidden="true" />{labels.pinned}</span
|
|
190
|
+
>
|
|
191
|
+
{/if}
|
|
192
|
+
{/if}
|
|
193
|
+
{#if editingId !== comment.id}
|
|
194
|
+
<span
|
|
195
|
+
class="ms-auto flex gap-0.5 opacity-0 transition-opacity group-hover/row:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-100"
|
|
196
|
+
>
|
|
197
|
+
{#if isRoot && onResolve}
|
|
198
|
+
<button
|
|
199
|
+
type="button"
|
|
200
|
+
class="thread-icon"
|
|
201
|
+
aria-label={comment.resolved ? labels.unresolve : labels.resolve}
|
|
202
|
+
aria-pressed={comment.resolved ?? false}
|
|
203
|
+
onclick={() => onResolve(comment, !comment.resolved)}
|
|
204
|
+
>
|
|
205
|
+
<Check class="size-3.5" aria-hidden="true" />
|
|
206
|
+
</button>
|
|
207
|
+
{/if}
|
|
208
|
+
{#if canEdit(comment)}
|
|
209
|
+
{#if onEdit && !comment.content}
|
|
210
|
+
<button
|
|
211
|
+
type="button"
|
|
212
|
+
class="thread-icon"
|
|
213
|
+
aria-label={labels.edit}
|
|
214
|
+
onclick={() => {
|
|
215
|
+
editingId = comment.id;
|
|
216
|
+
editDraft = comment.body;
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
<PencilSimple class="size-3.5" aria-hidden="true" />
|
|
220
|
+
</button>
|
|
221
|
+
{/if}
|
|
222
|
+
{#if onDelete}
|
|
223
|
+
<button
|
|
224
|
+
type="button"
|
|
225
|
+
class="thread-icon"
|
|
226
|
+
aria-label={labels.delete}
|
|
227
|
+
onclick={() => onDelete?.(comment)}
|
|
228
|
+
>
|
|
229
|
+
<Trash class="size-3.5" aria-hidden="true" />
|
|
230
|
+
</button>
|
|
231
|
+
{/if}
|
|
232
|
+
{/if}
|
|
233
|
+
</span>
|
|
234
|
+
{/if}
|
|
235
|
+
</div>
|
|
236
|
+
|
|
237
|
+
{#if editingId === comment.id}
|
|
238
|
+
<textarea
|
|
239
|
+
bind:value={editDraft}
|
|
240
|
+
rows={3}
|
|
241
|
+
aria-label={labels.edit}
|
|
242
|
+
class="mt-1 w-full resize-y rounded-md border border-input bg-transparent px-2.5 py-2 text-sm leading-relaxed outline-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50"
|
|
243
|
+
></textarea>
|
|
244
|
+
<div class="mt-2 flex justify-end gap-1.5">
|
|
245
|
+
<button type="button" class="thread-button" onclick={() => (editingId = null)}
|
|
246
|
+
>{labels.cancel}</button
|
|
247
|
+
>
|
|
248
|
+
<button
|
|
249
|
+
type="button"
|
|
250
|
+
class="thread-button thread-primary"
|
|
251
|
+
onclick={() => saveEdit(comment)}>{labels.save}</button
|
|
252
|
+
>
|
|
253
|
+
</div>
|
|
254
|
+
{:else if comment.content}
|
|
255
|
+
<div class="text-sm leading-relaxed"><RichRenderer content={comment.content} /></div>
|
|
256
|
+
{:else}
|
|
257
|
+
<p class="text-sm leading-relaxed whitespace-pre-wrap text-pretty">{comment.body}</p>
|
|
258
|
+
{/if}
|
|
259
|
+
|
|
260
|
+
{@render attachments?.(comment)}
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
{/snippet}
|
|
264
|
+
|
|
265
|
+
<section aria-label={labels.title} class={cn("flex flex-col gap-3", className)}>
|
|
266
|
+
<div class="flex h-7 items-center justify-between">
|
|
267
|
+
<h2 class="text-xs font-medium text-muted-foreground">{labels.title}</h2>
|
|
268
|
+
{#if resolved > 0}
|
|
269
|
+
<button
|
|
270
|
+
type="button"
|
|
271
|
+
class="thread-button"
|
|
272
|
+
aria-expanded={showResolved}
|
|
273
|
+
onclick={() => (showResolved = !showResolved)}
|
|
274
|
+
>
|
|
275
|
+
{showResolved ? labels.hideResolved : fillCount(labels.showResolved, resolved)}
|
|
276
|
+
</button>
|
|
277
|
+
{/if}
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
{#if loading}
|
|
281
|
+
<ol class="flex flex-col gap-4" aria-busy="true">
|
|
282
|
+
{#each [0, 1] as placeholder (placeholder)}
|
|
283
|
+
<li class="flex gap-3">
|
|
284
|
+
<Skeleton class="size-6 shrink-0 rounded-full" />
|
|
285
|
+
<div class="flex flex-1 flex-col gap-2">
|
|
286
|
+
<Skeleton class="h-3.5 w-28" />
|
|
287
|
+
<Skeleton class="h-3.5 w-full" />
|
|
288
|
+
</div>
|
|
289
|
+
</li>
|
|
290
|
+
{/each}
|
|
291
|
+
</ol>
|
|
292
|
+
{:else if shown.length > 0}
|
|
293
|
+
<ol class="flex flex-col gap-4">
|
|
294
|
+
{#each shown as node (node.comment.id)}
|
|
295
|
+
<li
|
|
296
|
+
class={cn("flex flex-col gap-3", node.comment.resolved && "opacity-60")}
|
|
297
|
+
data-resolved={node.comment.resolved || undefined}
|
|
298
|
+
>
|
|
299
|
+
{@render row(node.comment, true)}
|
|
300
|
+
{#if node.comment.resolved}
|
|
301
|
+
<span class="ms-9 text-xs text-muted-foreground">{labels.resolved}</span>
|
|
302
|
+
{/if}
|
|
303
|
+
{#if node.replies.length > 0}
|
|
304
|
+
<ol class="ms-3 flex flex-col gap-3 border-s border-border ps-6">
|
|
305
|
+
{#each node.replies as reply (reply.id)}
|
|
306
|
+
<li>{@render row(reply, false)}</li>
|
|
307
|
+
{/each}
|
|
308
|
+
</ol>
|
|
309
|
+
{/if}
|
|
310
|
+
{#if onPost && !node.comment.resolved}
|
|
311
|
+
{#if replyTo === node.comment.id}
|
|
312
|
+
<div class="ms-9">
|
|
313
|
+
{@render composer(
|
|
314
|
+
replyDraft,
|
|
315
|
+
labels.replyPlaceholder,
|
|
316
|
+
sendReply,
|
|
317
|
+
(next) => (replyDraft = next),
|
|
318
|
+
true,
|
|
319
|
+
)}
|
|
320
|
+
</div>
|
|
321
|
+
{:else}
|
|
322
|
+
<button
|
|
323
|
+
type="button"
|
|
324
|
+
class="thread-button ms-9 flex w-fit items-center gap-1.5"
|
|
325
|
+
onclick={() => {
|
|
326
|
+
replyTo = node.comment.id;
|
|
327
|
+
replyDraft = "";
|
|
328
|
+
}}
|
|
329
|
+
>
|
|
330
|
+
<ArrowBendDownRight class="size-3.5" aria-hidden="true" />{labels.reply}
|
|
331
|
+
</button>
|
|
332
|
+
{/if}
|
|
333
|
+
{/if}
|
|
334
|
+
</li>
|
|
335
|
+
{/each}
|
|
336
|
+
</ol>
|
|
337
|
+
{:else if !onPost}
|
|
338
|
+
<p class="text-[13px] text-muted-foreground">{labels.empty}</p>
|
|
339
|
+
{/if}
|
|
340
|
+
|
|
341
|
+
{#if onPost}
|
|
342
|
+
{@render composer(draft, labels.placeholder, sendRoot, (next) => (draft = next), false)}
|
|
343
|
+
{/if}
|
|
344
|
+
</section>
|
|
345
|
+
|
|
346
|
+
<style>
|
|
347
|
+
.thread-icon {
|
|
348
|
+
display: grid;
|
|
349
|
+
place-items: center;
|
|
350
|
+
width: 1.75rem;
|
|
351
|
+
height: 1.75rem;
|
|
352
|
+
border-radius: var(--radius-md, 0.5rem);
|
|
353
|
+
color: var(--color-muted-foreground);
|
|
354
|
+
outline: none;
|
|
355
|
+
transition: background-color var(--duration-quick, 150ms) var(--ease-smooth-out, ease-out);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.thread-chip {
|
|
359
|
+
display: inline-flex;
|
|
360
|
+
align-items: center;
|
|
361
|
+
gap: 0.25rem;
|
|
362
|
+
height: 1.25rem;
|
|
363
|
+
padding-inline: 0.375rem;
|
|
364
|
+
border-radius: var(--radius-sm, 0.25rem);
|
|
365
|
+
background: var(--color-muted);
|
|
366
|
+
color: var(--color-muted-foreground);
|
|
367
|
+
font-size: 0.75rem;
|
|
368
|
+
outline: none;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
button.thread-chip:focus-visible {
|
|
372
|
+
box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-ring) 50%, transparent);
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
@media (hover: hover) and (pointer: fine) {
|
|
376
|
+
.thread-icon:hover {
|
|
377
|
+
background: var(--color-muted);
|
|
378
|
+
color: var(--color-foreground);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
.thread-icon:focus-visible,
|
|
383
|
+
.thread-button:focus-visible {
|
|
384
|
+
box-shadow: 0 0 0 3px color-mix(in oklab, var(--color-ring) 50%, transparent);
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.thread-button {
|
|
388
|
+
height: 1.75rem;
|
|
389
|
+
padding-inline: 0.75rem;
|
|
390
|
+
border-radius: var(--radius-md, 0.5rem);
|
|
391
|
+
font-size: 0.8125rem;
|
|
392
|
+
font-weight: 500;
|
|
393
|
+
outline: none;
|
|
394
|
+
transition: background-color var(--duration-quick, 150ms) var(--ease-smooth-out, ease-out);
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
@media (hover: hover) and (pointer: fine) {
|
|
398
|
+
.thread-button:hover:not(:disabled) {
|
|
399
|
+
background: var(--color-muted);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
.thread-button:disabled {
|
|
404
|
+
opacity: 0.5;
|
|
405
|
+
pointer-events: none;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
.thread-primary {
|
|
409
|
+
background: var(--color-primary);
|
|
410
|
+
color: var(--color-primary-foreground);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/* An empty draft reads as an outlined button, not a faded fill. */
|
|
414
|
+
.thread-primary:disabled {
|
|
415
|
+
opacity: 1;
|
|
416
|
+
background: transparent;
|
|
417
|
+
box-shadow: inset 0 0 0 1px var(--color-border);
|
|
418
|
+
color: var(--color-muted-foreground);
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
@media (hover: hover) and (pointer: fine) {
|
|
422
|
+
.thread-primary:hover:not(:disabled) {
|
|
423
|
+
background: color-mix(in oklab, var(--color-primary) 90%, transparent);
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
@media (any-pointer: coarse) {
|
|
428
|
+
.thread-button {
|
|
429
|
+
height: 2.5rem;
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
</style>
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { describe, expect, it } from "vite-plus/test";
|
|
2
|
+
import { buildThread, fillCount, resolveThreadLabels, resolvedCount } from "./logic.js";
|
|
3
|
+
import { DEFAULT_THREAD_LABELS, type ThreadComment } from "./types.js";
|
|
4
|
+
|
|
5
|
+
const ada = { kind: "user", name: "Ada" } as const;
|
|
6
|
+
const bot = { kind: "agent", name: "Scribe" } as const;
|
|
7
|
+
|
|
8
|
+
function comment(id: string, at: string, extra: Partial<ThreadComment> = {}): ThreadComment {
|
|
9
|
+
return { id, author: ada, body: id, createdAt: at, ...extra };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
describe("buildThread", () => {
|
|
13
|
+
it("puts replies under their root in time order", () => {
|
|
14
|
+
const nodes = buildThread([
|
|
15
|
+
comment("r2", "2026-10-22T10:05:00Z", { parentId: "a" }),
|
|
16
|
+
comment("a", "2026-10-22T10:00:00Z"),
|
|
17
|
+
comment("b", "2026-10-22T10:02:00Z", { author: bot }),
|
|
18
|
+
comment("r1", "2026-10-22T10:03:00Z", { parentId: "a" }),
|
|
19
|
+
]);
|
|
20
|
+
expect(nodes.map((n) => n.comment.id)).toEqual(["a", "b"]);
|
|
21
|
+
expect(nodes[0].replies.map((r) => r.id)).toEqual(["r1", "r2"]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it("keeps a reply to a reply under the root", () => {
|
|
25
|
+
const nodes = buildThread([
|
|
26
|
+
comment("a", "2026-10-22T10:00:00Z"),
|
|
27
|
+
comment("r1", "2026-10-22T10:01:00Z", { parentId: "a" }),
|
|
28
|
+
comment("r2", "2026-10-22T10:02:00Z", { parentId: "r1" }),
|
|
29
|
+
]);
|
|
30
|
+
expect(nodes).toHaveLength(1);
|
|
31
|
+
expect(nodes[0].replies.map((r) => r.id)).toEqual(["r1", "r2"]);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("turns an orphan reply into a root and survives a parent loop", () => {
|
|
35
|
+
const nodes = buildThread([
|
|
36
|
+
comment("x", "2026-10-22T10:00:00Z", { parentId: "gone" }),
|
|
37
|
+
comment("p", "2026-10-22T10:01:00Z", { parentId: "q" }),
|
|
38
|
+
comment("q", "2026-10-22T10:02:00Z", { parentId: "p" }),
|
|
39
|
+
]);
|
|
40
|
+
expect(nodes.map((n) => n.comment.id)).toContain("x");
|
|
41
|
+
expect(nodes.flatMap((n) => [n.comment.id, ...n.replies.map((r) => r.id)]).sort()).toEqual([
|
|
42
|
+
"p",
|
|
43
|
+
"q",
|
|
44
|
+
"x",
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("sorts a malformed timestamp last", () => {
|
|
49
|
+
const nodes = buildThread([comment("bad", "soon"), comment("ok", "2026-10-22T10:00:00Z")]);
|
|
50
|
+
expect(nodes.map((n) => n.comment.id)).toEqual(["ok", "bad"]);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it("counts resolved roots", () => {
|
|
54
|
+
const nodes = buildThread([
|
|
55
|
+
comment("a", "2026-10-22T10:00:00Z", { resolved: true }),
|
|
56
|
+
comment("b", "2026-10-22T10:01:00Z"),
|
|
57
|
+
]);
|
|
58
|
+
expect(resolvedCount(nodes)).toBe(1);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("labels", () => {
|
|
63
|
+
it("lets a host write French over the English defaults", () => {
|
|
64
|
+
const fr = resolveThreadLabels({
|
|
65
|
+
title: "Activité",
|
|
66
|
+
send: "Commenter",
|
|
67
|
+
showResolved: "Afficher {count} résolus",
|
|
68
|
+
});
|
|
69
|
+
expect(fr.title).toBe("Activité");
|
|
70
|
+
expect(fr.cancel).toBe(DEFAULT_THREAD_LABELS.cancel);
|
|
71
|
+
expect(fillCount(fr.showResolved, 3)).toBe("Afficher 3 résolus");
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type ThreadAuthorKind = "user" | "agent";
|
|
2
|
+
|
|
3
|
+
export type ThreadAuthor = {
|
|
4
|
+
kind: ThreadAuthorKind;
|
|
5
|
+
name: string;
|
|
6
|
+
/** Image URL for a person. The host's own portrait goes through the `avatar` snippet. */
|
|
7
|
+
avatar?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
/** Where on a canvas a comment is pinned: a node and an offset from it, or a point. */
|
|
11
|
+
export type ThreadAnchor = {
|
|
12
|
+
nodeId?: string;
|
|
13
|
+
dx?: number;
|
|
14
|
+
dy?: number;
|
|
15
|
+
x?: number;
|
|
16
|
+
y?: number;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** One comment on any subject. The host resolves the author's name. */
|
|
20
|
+
export type ThreadComment = {
|
|
21
|
+
id: string;
|
|
22
|
+
author: ThreadAuthor;
|
|
23
|
+
/** Plain text, shown as written. Also the fallback when `content` is missing. */
|
|
24
|
+
body: string;
|
|
25
|
+
/** Tiptap JSON. When set, the thread draws it through the editor's renderer instead of `body`. */
|
|
26
|
+
content?: Record<string, unknown>;
|
|
27
|
+
/** ISO timestamp. */
|
|
28
|
+
createdAt: string;
|
|
29
|
+
/** Set when the body changed after posting. */
|
|
30
|
+
edited?: boolean;
|
|
31
|
+
/** The comment this one answers. A reply to a reply sits under the same root. */
|
|
32
|
+
parentId?: string | null;
|
|
33
|
+
/** Only a root carries it: the whole conversation is resolved. */
|
|
34
|
+
resolved?: boolean;
|
|
35
|
+
anchor?: ThreadAnchor | null;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export type ThreadPost = {
|
|
39
|
+
body: string;
|
|
40
|
+
parentId: string | null;
|
|
41
|
+
anchor?: ThreadAnchor | null;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/** A root comment with its replies in time order. */
|
|
45
|
+
export type ThreadNode = {
|
|
46
|
+
comment: ThreadComment;
|
|
47
|
+
replies: ThreadComment[];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type ThreadLabels = {
|
|
51
|
+
title: string;
|
|
52
|
+
empty: string;
|
|
53
|
+
placeholder: string;
|
|
54
|
+
replyPlaceholder: string;
|
|
55
|
+
send: string;
|
|
56
|
+
sending: string;
|
|
57
|
+
reply: string;
|
|
58
|
+
edit: string;
|
|
59
|
+
delete: string;
|
|
60
|
+
edited: string;
|
|
61
|
+
save: string;
|
|
62
|
+
cancel: string;
|
|
63
|
+
resolve: string;
|
|
64
|
+
unresolve: string;
|
|
65
|
+
resolved: string;
|
|
66
|
+
/** Shows `{count}` resolved conversations. */
|
|
67
|
+
showResolved: string;
|
|
68
|
+
hideResolved: string;
|
|
69
|
+
agent: string;
|
|
70
|
+
pinned: string;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export const DEFAULT_THREAD_LABELS: ThreadLabels = {
|
|
74
|
+
title: "Activity",
|
|
75
|
+
empty: "No comments yet",
|
|
76
|
+
placeholder: "Leave a comment",
|
|
77
|
+
replyPlaceholder: "Reply",
|
|
78
|
+
send: "Comment",
|
|
79
|
+
sending: "Sending",
|
|
80
|
+
reply: "Reply",
|
|
81
|
+
edit: "Edit comment",
|
|
82
|
+
delete: "Delete comment",
|
|
83
|
+
edited: "edited",
|
|
84
|
+
save: "Save",
|
|
85
|
+
cancel: "Cancel",
|
|
86
|
+
resolve: "Resolve",
|
|
87
|
+
unresolve: "Reopen",
|
|
88
|
+
resolved: "Resolved",
|
|
89
|
+
showResolved: "Show {count} resolved",
|
|
90
|
+
hideResolved: "Hide resolved",
|
|
91
|
+
agent: "AI",
|
|
92
|
+
pinned: "Pinned",
|
|
93
|
+
};
|