@burdenoff/microfe-planmagnet 2026.930.16 → 2026.930.17

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,25 @@
1
+ export interface MentionComposerProps {
2
+ id: string;
3
+ value: string;
4
+ onChange: (value: string) => void;
5
+ placeholder?: string;
6
+ ariaLabel?: string;
7
+ disabled?: boolean;
8
+ /** Merged with the Textarea's own base styling (e.g. `"min-h-[60px]"` for a reply box). */
9
+ className?: string;
10
+ autoFocus?: boolean;
11
+ workspaceId?: string;
12
+ authToken?: string;
13
+ apiGatewayUrl?: string;
14
+ }
15
+ /** A plain multi-line composer with an @-mention autocomplete overlay. Controlled, like every other composer in
16
+ * this MFE (`value`/`onChange`) — the mention token is spliced into that same string, never a side channel. */
17
+ export declare function MentionComposer({ id, value, onChange, placeholder, ariaLabel, disabled, className, autoFocus, workspaceId, authToken, apiGatewayUrl, }: MentionComposerProps): import("react/jsx-runtime").JSX.Element;
18
+ /** A comment body as displayed text, with `@[Name](actorId)` tokens rendered as highlighted, live-resolved names
19
+ * instead of the raw markup (CWF-13). `actorId` drives the rendering via `PersonName` so a since-renamed member
20
+ * shows their current name, not the one captured when the mention was typed. */
21
+ export declare function MentionText({ text, className }: {
22
+ text: string;
23
+ className?: string;
24
+ }): import("react/jsx-runtime").JSX.Element;
25
+ //# sourceMappingURL=MentionComposer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MentionComposer.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/comments/MentionComposer.tsx"],"names":[],"mappings":"AAwCA,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2FAA2F;IAC3F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;+GAC+G;AAC/G,wBAAgB,eAAe,CAAC,EAC9B,EAAE,EACF,KAAK,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,QAAgB,EAChB,SAAS,EACT,SAAiB,EACjB,WAAW,EACX,SAAS,EACT,aAAa,GACd,EAAE,oBAAoB,2CAiLtB;AAID;;gFAEgF;AAChF,wBAAgB,WAAW,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,2CAwBpF"}
@@ -0,0 +1,148 @@
1
+ import { PersonName as e } from "../people/People.js";
2
+ import { Fragment as t, useEffect as n, useMemo as r, useRef as i, useState as a } from "react";
3
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
4
+ import { Textarea as c } from "@burdenoff/fe-libs/ui";
5
+ import { useWorkspaceDirectory as l } from "@burdenoff/fe-libs/sharing";
6
+ //#region src/planmagnet/comments/MentionComposer.tsx
7
+ var u = 6, d = /(?:^|\s)@([^\s@]{0,40})$/;
8
+ function f(e, t) {
9
+ let n = e.slice(0, t), r = d.exec(n);
10
+ return r ? {
11
+ start: r[0].startsWith("@") ? r.index : r.index + 1,
12
+ query: r[1]
13
+ } : null;
14
+ }
15
+ function p({ id: e, value: t, onChange: d, placeholder: p, ariaLabel: m, disabled: h = !1, className: g, autoFocus: _ = !1, workspaceId: v, authToken: y, apiGatewayUrl: b }) {
16
+ let x = i(null), S = i(null), [C, w] = a(null), [T, E] = a(0), D = l({
17
+ workspaceId: v ?? "",
18
+ authToken: y,
19
+ apiGatewayUrl: b
20
+ }), { search: O, hasMore: k, fetchMore: A } = D;
21
+ n(() => {
22
+ O(C?.query ?? "");
23
+ }, [C?.query, O]), n(() => {
24
+ if (S.current !== null && x.current) {
25
+ let e = S.current;
26
+ S.current = null, x.current.focus(), x.current.setSelectionRange(e, e);
27
+ }
28
+ }, [t]);
29
+ let j = r(() => C ? D.members.slice(0, u) : [], [C, D.members]), M = C !== null && !h, N = (e, t) => {
30
+ w(f(e, t)), E(0);
31
+ }, P = (e) => {
32
+ if (!C) return;
33
+ let n = C.start + 1 + C.query.length, r = `@[${e.name}](${e.id})`, i = `${t.slice(0, C.start)}${r} ${t.slice(n)}`;
34
+ S.current = C.start + r.length + 1, w(null), d(i);
35
+ }, F = `${e}-mentions`, I = M ? j[T] : void 0;
36
+ return /* @__PURE__ */ s("div", {
37
+ className: "relative",
38
+ children: [
39
+ /* @__PURE__ */ o(c, {
40
+ ref: x,
41
+ id: e,
42
+ "aria-label": m,
43
+ className: g,
44
+ placeholder: p,
45
+ value: t,
46
+ disabled: h,
47
+ autoFocus: _,
48
+ "aria-expanded": M,
49
+ "aria-controls": M ? F : void 0,
50
+ "aria-haspopup": "listbox",
51
+ "aria-autocomplete": "list",
52
+ "aria-activedescendant": I ? `${F}-${I.id}` : void 0,
53
+ onChange: (e) => {
54
+ d(e.target.value), N(e.target.value, e.target.selectionStart ?? e.target.value.length);
55
+ },
56
+ onSelect: (e) => {
57
+ let t = e.currentTarget;
58
+ N(t.value, t.selectionStart ?? t.value.length);
59
+ },
60
+ onBlur: () => w(null),
61
+ onKeyDown: (e) => {
62
+ if (!(!M || j.length === 0)) if (e.key === "ArrowDown") e.preventDefault(), E((e) => (e + 1) % j.length);
63
+ else if (e.key === "ArrowUp") e.preventDefault(), E((e) => (e - 1 + j.length) % j.length);
64
+ else if (e.key === "Enter" || e.key === "Tab") {
65
+ let t = j[T] ?? j[0];
66
+ if (!t) return;
67
+ e.preventDefault(), P(t);
68
+ } else e.key === "Escape" && (e.preventDefault(), w(null));
69
+ }
70
+ }),
71
+ M && /* @__PURE__ */ s("div", {
72
+ className: "absolute z-20 mt-1 w-72 overflow-hidden rounded-md border border-border-default bg-bg-surface text-sm shadow-md",
73
+ children: [/* @__PURE__ */ s("div", {
74
+ role: "listbox",
75
+ id: F,
76
+ "aria-label": "Workspace members",
77
+ "data-testid": "mention-suggestions",
78
+ className: "max-h-56 overflow-y-auto p-1",
79
+ children: [
80
+ D.loading && j.length === 0 && /* @__PURE__ */ o("p", {
81
+ className: "px-2 py-1.5 text-xs text-muted-foreground",
82
+ children: "Loading members…"
83
+ }),
84
+ !D.loading && j.length === 0 && /* @__PURE__ */ o("p", {
85
+ className: "px-2 py-1.5 text-xs text-muted-foreground",
86
+ children: "No matching members."
87
+ }),
88
+ j.map((e, t) => /* @__PURE__ */ s("button", {
89
+ type: "button",
90
+ id: `${F}-${e.id}`,
91
+ role: "option",
92
+ "aria-selected": t === T,
93
+ className: `flex w-full items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left ${t === T ? "bg-primary/10 text-primary" : "hover:bg-muted"}`,
94
+ onMouseDown: (t) => {
95
+ t.preventDefault(), P(e);
96
+ },
97
+ onMouseEnter: () => E(t),
98
+ children: [/* @__PURE__ */ o("span", {
99
+ className: "truncate font-medium",
100
+ children: e.name
101
+ }), e.email && /* @__PURE__ */ o("span", {
102
+ className: "shrink-0 truncate text-xs text-muted-foreground",
103
+ children: e.email
104
+ })]
105
+ }, e.id))
106
+ ]
107
+ }), k && /* @__PURE__ */ o("button", {
108
+ type: "button",
109
+ className: "w-full border-t border-border-default px-2 py-1.5 text-left text-xs text-primary hover:bg-muted hover:underline",
110
+ onMouseDown: (e) => {
111
+ e.preventDefault(), A();
112
+ },
113
+ children: "Show more members"
114
+ })]
115
+ }),
116
+ /* @__PURE__ */ o("span", {
117
+ className: "sr-only",
118
+ "aria-live": "polite",
119
+ children: M ? I ? `${I.name} highlighted, ${j.length} member${j.length === 1 ? "" : "s"} matching` : D.loading ? "Loading members" : "No matching members" : ""
120
+ })
121
+ ]
122
+ });
123
+ }
124
+ var m = /@\[([^\]]+)\]\(([^)\s]+)\)/g;
125
+ function h({ text: n, className: r }) {
126
+ let i = [], a = 0;
127
+ for (let e of n.matchAll(m)) {
128
+ let t = e.index ?? 0;
129
+ t > a && i.push(n.slice(a, t)), i.push({
130
+ name: e[1],
131
+ actorId: e[2]
132
+ }), a = t + e[0].length;
133
+ }
134
+ return a < n.length && i.push(n.slice(a)), /* @__PURE__ */ o("p", {
135
+ className: r ?? "text-sm whitespace-pre-wrap break-words",
136
+ children: i.map((n, r) => typeof n == "string" ? /* @__PURE__ */ o(t, { children: n }, r) : /* @__PURE__ */ s("span", {
137
+ className: "rounded bg-primary/10 px-1 py-0.5 font-medium text-primary",
138
+ children: ["@", /* @__PURE__ */ o(e, {
139
+ id: n.actorId,
140
+ className: "text-primary"
141
+ })]
142
+ }, r))
143
+ });
144
+ }
145
+ //#endregion
146
+ export { p as MentionComposer, h as MentionText };
147
+
148
+ //# sourceMappingURL=MentionComposer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MentionComposer.js","names":[],"sources":["../../../src/planmagnet/comments/MentionComposer.tsx"],"sourcesContent":["import { Fragment, useEffect, useMemo, useRef, useState, type KeyboardEvent } from 'react';\nimport { useWorkspaceDirectory, type WorkspaceDirectoryMember } from '@burdenoff/fe-libs/sharing';\nimport { Textarea } from '@burdenoff/fe-libs/ui';\nimport { PersonName } from '../people/People';\n\n/**\n * @-mention support (CWF-13), shared by every comment composer — the top-level \"Add a comment\" box, a reply box\n * and an edit box, on all three surfaces this MFE has comments on (task, project, doc; see CommentThread.tsx).\n *\n * A mention is stored as the literal token `@[Name](actorId)` inside the comment body — the server parses it out\n * of the raw text (`PlanmagnetComment.mentions` / `PlanmagnetWorkItemComment.mentions` in graphql/wspace.graphql\n * are populated FROM this token, read-only). There is no separate \"mention\" API call: typing \"@\", picking someone\n * and posting the comment is the whole mechanism.\n *\n * Suggestions reuse the same workspace directory the assignee picker already calls\n * (`useWorkspaceDirectory`, see `controls/WorkItemControls.tsx`'s `useAssigneeOptions`): one paged list of\n * members, filtered case-insensitively client-side by `.search(query)`. The dropdown is anchored to the\n * composer box itself, not to the caret's pixel position — a caret-coordinate \"mirror div\" measurement is the\n * textbook way to do that, but it is fragile across zoom levels, font loading and line-wrap, and not worth it for\n * a box this short; anchoring to the field is the same trade-off GitHub's and Linear's own comment composers make.\n *\n * Mention delivery: the server records `mentions` but does NOT notify anyone yet (BOFF-7927, see the schema doc\n * comment on `mentions`) — this component only inserts the token and later renders it highlighted\n * (`MentionText`), and never implies a mentioned person was paged, emailed or pushed.\n */\n\nconst MAX_SUGGESTIONS = 6;\n/** `@name` trigger: an \"@\" that starts a word (line start or preceded by whitespace), followed by up to 40\n * non-space, non-\"@\" characters up to the caret. Requiring a word boundary before \"@\" keeps this from firing\n * mid-token on something like an email address (\"ada@example.com\"). */\nconst TRIGGER_PATTERN = /(?:^|\\s)@([^\\s@]{0,40})$/;\n\nfunction findTrigger(text: string, caret: number): { start: number; query: string } | null {\n const head = text.slice(0, caret);\n const match = TRIGGER_PATTERN.exec(head);\n if (!match) return null;\n const start = match[0].startsWith('@') ? match.index : match.index + 1;\n return { start, query: match[1] };\n}\n\nexport interface MentionComposerProps {\n id: string;\n value: string;\n onChange: (value: string) => void;\n placeholder?: string;\n ariaLabel?: string;\n disabled?: boolean;\n /** Merged with the Textarea's own base styling (e.g. `\"min-h-[60px]\"` for a reply box). */\n className?: string;\n autoFocus?: boolean;\n workspaceId?: string;\n authToken?: string;\n apiGatewayUrl?: string;\n}\n\n/** A plain multi-line composer with an @-mention autocomplete overlay. Controlled, like every other composer in\n * this MFE (`value`/`onChange`) — the mention token is spliced into that same string, never a side channel. */\nexport function MentionComposer({\n id,\n value,\n onChange,\n placeholder,\n ariaLabel,\n disabled = false,\n className,\n autoFocus = false,\n workspaceId,\n authToken,\n apiGatewayUrl,\n}: MentionComposerProps) {\n const textareaRef = useRef<HTMLTextAreaElement>(null);\n // Caret position to restore after a mention is spliced in — `value` is controlled by the parent, so the new\n // selection can only be applied once the DOM has the new text (the effect below, keyed on `value`).\n const pendingCaretRef = useRef<number | null>(null);\n const [trigger, setTrigger] = useState<{ start: number; query: string } | null>(null);\n const [highlight, setHighlight] = useState(0);\n\n const directory = useWorkspaceDirectory({\n workspaceId: workspaceId ?? '',\n authToken,\n apiGatewayUrl,\n });\n const { search, hasMore, fetchMore } = directory;\n\n useEffect(() => {\n search(trigger?.query ?? '');\n }, [trigger?.query, search]);\n\n useEffect(() => {\n if (pendingCaretRef.current !== null && textareaRef.current) {\n const pos = pendingCaretRef.current;\n pendingCaretRef.current = null;\n textareaRef.current.focus();\n textareaRef.current.setSelectionRange(pos, pos);\n }\n }, [value]);\n\n const options = useMemo(\n () => (trigger ? directory.members.slice(0, MAX_SUGGESTIONS) : []),\n [trigger, directory.members]\n );\n const open = trigger !== null && !disabled;\n\n // Resets the highlighted option whenever the trigger changes (new \"@query\", or it closed/opened) — done here,\n // synchronously with the same event that changed it, rather than in an effect keyed on `trigger?.query`\n // (react-hooks/set-state-in-effect: a setState called directly in an effect body cascades an extra render).\n const recomputeTrigger = (text: string, caret: number) => {\n setTrigger(findTrigger(text, caret));\n setHighlight(0);\n };\n\n const insertMention = (member: WorkspaceDirectoryMember) => {\n if (!trigger) return;\n const end = trigger.start + 1 + trigger.query.length;\n const token = `@[${member.name}](${member.id})`;\n const next = `${value.slice(0, trigger.start)}${token} ${value.slice(end)}`;\n pendingCaretRef.current = trigger.start + token.length + 1;\n setTrigger(null);\n onChange(next);\n };\n\n const listId = `${id}-mentions`;\n const activeOption = open ? options[highlight] : undefined;\n\n return (\n <div className=\"relative\">\n <Textarea\n ref={textareaRef}\n id={id}\n aria-label={ariaLabel}\n className={className}\n placeholder={placeholder}\n value={value}\n disabled={disabled}\n autoFocus={autoFocus}\n aria-expanded={open}\n aria-controls={open ? listId : undefined}\n aria-haspopup=\"listbox\"\n aria-autocomplete=\"list\"\n aria-activedescendant={activeOption ? `${listId}-${activeOption.id}` : undefined}\n onChange={(e) => {\n onChange(e.target.value);\n recomputeTrigger(e.target.value, e.target.selectionStart ?? e.target.value.length);\n }}\n onSelect={(e) => {\n const el = e.currentTarget;\n recomputeTrigger(el.value, el.selectionStart ?? el.value.length);\n }}\n onBlur={() => setTrigger(null)}\n onKeyDown={(e: KeyboardEvent<HTMLTextAreaElement>) => {\n if (!open || options.length === 0) return;\n if (e.key === 'ArrowDown') {\n e.preventDefault();\n setHighlight((h) => (h + 1) % options.length);\n } else if (e.key === 'ArrowUp') {\n e.preventDefault();\n setHighlight((h) => (h - 1 + options.length) % options.length);\n } else if (e.key === 'Enter' || e.key === 'Tab') {\n // `highlight` can only be stale within the bounds already guarded above (`options.length === 0`\n // returns early); still resolved defensively rather than indexing blind.\n const member = options[highlight] ?? options[0];\n if (!member) return;\n e.preventDefault();\n insertMention(member);\n } else if (e.key === 'Escape') {\n e.preventDefault();\n setTrigger(null);\n }\n }}\n />\n {open && (\n <div className=\"absolute z-20 mt-1 w-72 overflow-hidden rounded-md border border-border-default bg-bg-surface text-sm shadow-md\">\n <div\n role=\"listbox\"\n id={listId}\n aria-label=\"Workspace members\"\n data-testid=\"mention-suggestions\"\n className=\"max-h-56 overflow-y-auto p-1\"\n >\n {directory.loading && options.length === 0 && (\n <p className=\"px-2 py-1.5 text-xs text-muted-foreground\">Loading members…</p>\n )}\n {!directory.loading && options.length === 0 && (\n <p className=\"px-2 py-1.5 text-xs text-muted-foreground\">No matching members.</p>\n )}\n {options.map((member, i) => (\n <button\n key={member.id}\n type=\"button\"\n id={`${listId}-${member.id}`}\n role=\"option\"\n aria-selected={i === highlight}\n className={`flex w-full items-center justify-between gap-2 rounded-sm px-2 py-1.5 text-left ${\n i === highlight ? 'bg-primary/10 text-primary' : 'hover:bg-muted'\n }`}\n // mousedown (not click) + preventDefault: keeps focus (and the caret we're about to restore) on\n // the textarea instead of letting the browser blur it into this button first.\n onMouseDown={(e) => {\n e.preventDefault();\n insertMention(member);\n }}\n onMouseEnter={() => setHighlight(i)}\n >\n <span className=\"truncate font-medium\">{member.name}</span>\n {member.email && (\n <span className=\"shrink-0 truncate text-xs text-muted-foreground\">\n {member.email}\n </span>\n )}\n </button>\n ))}\n </div>\n {\n // The directory loads members a page (50) at a time (`useWorkspaceDirectory`, PAGE_SIZE) and\n // `search()` only filters what's already loaded — someone outside the first page is unmentionable\n // until more is fetched. Mirrors the \"Show more members\" affordance the assignee picker and the\n // roadmap reviewer picker already wire onto this same hook (WorkItemControls' AssigneeSelect,\n // RoadmapReviewPanel).\n hasMore && (\n <button\n type=\"button\"\n className=\"w-full border-t border-border-default px-2 py-1.5 text-left text-xs text-primary hover:bg-muted hover:underline\"\n // Same mousedown/preventDefault trick as the option buttons above: fetchMore() must not blur\n // the textarea (which would close the dropdown via onBlur before the click is handled).\n onMouseDown={(e) => {\n e.preventDefault();\n fetchMore();\n }}\n >\n Show more members\n </button>\n )\n }\n </div>\n )}\n <span className=\"sr-only\" aria-live=\"polite\">\n {open\n ? activeOption\n ? `${activeOption.name} highlighted, ${options.length} member${options.length === 1 ? '' : 's'} matching`\n : directory.loading\n ? 'Loading members'\n : 'No matching members'\n : ''}\n </span>\n </div>\n );\n}\n\nconst MENTION_PATTERN = /@\\[([^\\]]+)\\]\\(([^)\\s]+)\\)/g;\n\n/** A comment body as displayed text, with `@[Name](actorId)` tokens rendered as highlighted, live-resolved names\n * instead of the raw markup (CWF-13). `actorId` drives the rendering via `PersonName` so a since-renamed member\n * shows their current name, not the one captured when the mention was typed. */\nexport function MentionText({ text, className }: { text: string; className?: string }) {\n const parts: Array<string | { name: string; actorId: string }> = [];\n let last = 0;\n for (const match of text.matchAll(MENTION_PATTERN)) {\n const index = match.index ?? 0;\n if (index > last) parts.push(text.slice(last, index));\n parts.push({ name: match[1], actorId: match[2] });\n last = index + match[0].length;\n }\n if (last < text.length) parts.push(text.slice(last));\n\n return (\n <p className={className ?? 'text-sm whitespace-pre-wrap break-words'}>\n {parts.map((part, i) =>\n typeof part === 'string' ? (\n <Fragment key={i}>{part}</Fragment>\n ) : (\n <span key={i} className=\"rounded bg-primary/10 px-1 py-0.5 font-medium text-primary\">\n @<PersonName id={part.actorId} className=\"text-primary\" />\n </span>\n )\n )}\n </p>\n );\n}\n"],"mappings":";;;;;;AA0BA,IAAM,IAAkB,GAIlB,IAAkB;AAExB,SAAS,EAAY,GAAc,GAAwD;CACzF,IAAM,IAAO,EAAK,MAAM,GAAG,EAAM,EAC3B,IAAQ,EAAgB,KAAK,EAAK;AAGxC,QAFK,IAEE;EAAE,OADK,EAAM,GAAG,WAAW,IAAI,GAAG,EAAM,QAAQ,EAAM,QAAQ;EACrD,OAAO,EAAM;EAAI,GAFd;;AAsBrB,SAAgB,EAAgB,EAC9B,OACA,UACA,aACA,gBACA,cACA,cAAW,IACX,cACA,eAAY,IACZ,gBACA,cACA,oBACuB;CACvB,IAAM,IAAc,EAA4B,KAAK,EAG/C,IAAkB,EAAsB,KAAK,EAC7C,CAAC,GAAS,KAAc,EAAkD,KAAK,EAC/E,CAAC,GAAW,KAAgB,EAAS,EAAE,EAEvC,IAAY,EAAsB;EACtC,aAAa,KAAe;EAC5B;EACA;EACD,CAAC,EACI,EAAE,WAAQ,YAAS,iBAAc;AAMvC,CAJA,QAAgB;AACd,IAAO,GAAS,SAAS,GAAG;IAC3B,CAAC,GAAS,OAAO,EAAO,CAAC,EAE5B,QAAgB;AACd,MAAI,EAAgB,YAAY,QAAQ,EAAY,SAAS;GAC3D,IAAM,IAAM,EAAgB;AAG5B,GAFA,EAAgB,UAAU,MAC1B,EAAY,QAAQ,OAAO,EAC3B,EAAY,QAAQ,kBAAkB,GAAK,EAAI;;IAEhD,CAAC,EAAM,CAAC;CAEX,IAAM,IAAU,QACP,IAAU,EAAU,QAAQ,MAAM,GAAG,EAAgB,GAAG,EAAE,EACjE,CAAC,GAAS,EAAU,QAAQ,CAC7B,EACK,IAAO,MAAY,QAAQ,CAAC,GAK5B,KAAoB,GAAc,MAAkB;AAExD,EADA,EA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AY,EAAE,SAAM,gBAAmD;CACrF,IAAM,IAA2D,EAAE,EAC/D,IAAO;AACX,MAAK,IAAM,KAAS,EAAK,SAAS,EAAgB,EAAE;EAClD,IAAM,IAAQ,EAAM,SAAS;AAG7B,EAFI,IAAQ,KAAM,EAAM,KAAK,EAAK,MAAM,GAAM,EAAM,CAAC,EACrD,EAAM,KAAK;GAAE,MAAM,EAAM;GAAI,SAAS,EAAM;GAAI,CAAC,EACjD,IAAO,IAAQ,EAAM,GAAG;;AAI1B,QAFI,IAAO,EAAK,UAAQ,EAAM,KAAK,EAAK,MAAM,EAAK,CAAC,EAGlD,kBAAC,KAAD;EAAG,WAAW,KAAa;YACxB,EAAM,KAAK,GAAM,MAChB,OAAO,KAAS,WACd,kBAAC,GAAD,EAAA,UAAmB,GAAgB,EAApB,EAAoB,GAEnC,kBAAC,QAAD;GAAc,WAAU;aAAxB,CAAqF,KAClF,kBAAC,GAAD;IAAY,IAAI,EAAK;IAAS,WAAU;IAAiB,CAAA,CACrD;KAFI,EAEJ,CAEV;EACC,CAAA"}
@@ -0,0 +1,7 @@
1
+ export declare function ProjectComments({ projectId }: {
2
+ projectId: string;
3
+ }): import("react/jsx-runtime").JSX.Element;
4
+ export declare function DocComments({ docId }: {
5
+ docId: string;
6
+ }): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=TargetComments.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TargetComments.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/comments/TargetComments.tsx"],"names":[],"mappings":"AAoFA,wBAAgB,eAAe,CAAC,EAAE,SAAS,EAAE,EAAE;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,2CAiCnE;AAqED,wBAAgB,WAAW,CAAC,EAAE,KAAK,EAAE,EAAE;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,2CAiCvD"}
@@ -0,0 +1,207 @@
1
+ import { CommentThread as e } from "./CommentThread.js";
2
+ import { useState as t } from "react";
3
+ import { MessageSquare as n } from "lucide-react";
4
+ import { gql as r } from "@apollo/client";
5
+ import { jsx as i, jsxs as a } from "react/jsx-runtime";
6
+ import { Card as o, CardContent as s, CardHeader as c, CardTitle as l } from "@burdenoff/fe-libs/ui";
7
+ //#region src/planmagnet/comments/TargetComments.tsx
8
+ var u = r`
9
+ query ProjectComments($projectId: ID!, $pagination: PlanmagnetPaginationInput) {
10
+ planmagnetProjectComments(projectId: $projectId, pagination: $pagination) {
11
+ totalCount
12
+ pageInfo {
13
+ hasNextPage
14
+ endCursor
15
+ }
16
+ items {
17
+ id
18
+ authorId
19
+ body
20
+ createdAt
21
+ editedAt
22
+ parentId
23
+ status
24
+ resolvedBy
25
+ resolvedAt
26
+ mentions
27
+ replies {
28
+ id
29
+ authorId
30
+ body
31
+ createdAt
32
+ editedAt
33
+ parentId
34
+ status
35
+ resolvedBy
36
+ resolvedAt
37
+ mentions
38
+ }
39
+ }
40
+ }
41
+ }
42
+ `, d = r`
43
+ mutation ProjectCommentAdd($input: PlanmagnetAddProjectCommentInput!) {
44
+ planmagnetAddProjectComment(input: $input) {
45
+ id
46
+ }
47
+ }
48
+ `, f = r`
49
+ mutation ProjectCommentEdit($id: ID!, $body: String!) {
50
+ planmagnetEditProjectComment(id: $id, body: $body) {
51
+ id
52
+ body
53
+ editedAt
54
+ }
55
+ }
56
+ `, p = r`
57
+ mutation ProjectCommentDelete($id: ID!) {
58
+ planmagnetDeleteProjectComment(id: $id)
59
+ }
60
+ `, m = r`
61
+ mutation ProjectCommentResolve($id: ID!, $resolved: Boolean!) {
62
+ planmagnetResolveProjectComment(id: $id, resolved: $resolved) {
63
+ id
64
+ status
65
+ resolvedBy
66
+ resolvedAt
67
+ }
68
+ }
69
+ `;
70
+ function h({ projectId: r }) {
71
+ let [h, g] = t(null);
72
+ return /* @__PURE__ */ a(o, {
73
+ "data-testid": "project-comments",
74
+ children: [/* @__PURE__ */ i(c, { children: /* @__PURE__ */ a(l, {
75
+ className: "flex items-center gap-2",
76
+ children: [
77
+ /* @__PURE__ */ i(n, { className: "h-4 w-4" }),
78
+ "Comments",
79
+ h === null ? "" : ` (${h})`
80
+ ]
81
+ }) }), /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(e, {
82
+ targetNoun: "project",
83
+ idPrefix: `project-comment-${r}`,
84
+ query: {
85
+ document: u,
86
+ dataKey: "planmagnetProjectComments",
87
+ variables: { projectId: r },
88
+ skip: !r
89
+ },
90
+ add: {
91
+ document: d,
92
+ buildVariables: (e, t) => ({ input: {
93
+ projectId: r,
94
+ body: e,
95
+ parentId: t
96
+ } })
97
+ },
98
+ edit: f,
99
+ remove: p,
100
+ resolve: m,
101
+ refetchQueries: ["ProjectComments"],
102
+ onTotalCount: g
103
+ }) })]
104
+ });
105
+ }
106
+ var g = r`
107
+ query DocComments($docId: ID!, $pagination: PlanmagnetPaginationInput) {
108
+ planmagnetDocComments(docId: $docId, pagination: $pagination) {
109
+ totalCount
110
+ pageInfo {
111
+ hasNextPage
112
+ endCursor
113
+ }
114
+ items {
115
+ id
116
+ authorId
117
+ body
118
+ createdAt
119
+ editedAt
120
+ parentId
121
+ status
122
+ resolvedBy
123
+ resolvedAt
124
+ mentions
125
+ replies {
126
+ id
127
+ authorId
128
+ body
129
+ createdAt
130
+ editedAt
131
+ parentId
132
+ status
133
+ resolvedBy
134
+ resolvedAt
135
+ mentions
136
+ }
137
+ }
138
+ }
139
+ }
140
+ `, _ = r`
141
+ mutation DocCommentAdd($input: PlanmagnetAddDocCommentInput!) {
142
+ planmagnetAddDocComment(input: $input) {
143
+ id
144
+ }
145
+ }
146
+ `, v = r`
147
+ mutation DocCommentEdit($id: ID!, $body: String!) {
148
+ planmagnetEditDocComment(id: $id, body: $body) {
149
+ id
150
+ body
151
+ editedAt
152
+ }
153
+ }
154
+ `, y = r`
155
+ mutation DocCommentDelete($id: ID!) {
156
+ planmagnetDeleteDocComment(id: $id)
157
+ }
158
+ `, b = r`
159
+ mutation DocCommentResolve($id: ID!, $resolved: Boolean!) {
160
+ planmagnetResolveDocComment(id: $id, resolved: $resolved) {
161
+ id
162
+ status
163
+ resolvedBy
164
+ resolvedAt
165
+ }
166
+ }
167
+ `;
168
+ function x({ docId: r }) {
169
+ let [u, d] = t(null);
170
+ return /* @__PURE__ */ a(o, {
171
+ "data-testid": "doc-comments",
172
+ children: [/* @__PURE__ */ i(c, { children: /* @__PURE__ */ a(l, {
173
+ className: "flex items-center gap-2",
174
+ children: [
175
+ /* @__PURE__ */ i(n, { className: "h-4 w-4" }),
176
+ "Comments",
177
+ u === null ? "" : ` (${u})`
178
+ ]
179
+ }) }), /* @__PURE__ */ i(s, { children: /* @__PURE__ */ i(e, {
180
+ targetNoun: "doc",
181
+ idPrefix: `doc-comment-${r}`,
182
+ query: {
183
+ document: g,
184
+ dataKey: "planmagnetDocComments",
185
+ variables: { docId: r },
186
+ skip: !r
187
+ },
188
+ add: {
189
+ document: _,
190
+ buildVariables: (e, t) => ({ input: {
191
+ docId: r,
192
+ body: e,
193
+ parentId: t
194
+ } })
195
+ },
196
+ edit: v,
197
+ remove: y,
198
+ resolve: b,
199
+ refetchQueries: ["DocComments"],
200
+ onTotalCount: d
201
+ }) })]
202
+ });
203
+ }
204
+ //#endregion
205
+ export { x as DocComments, h as ProjectComments };
206
+
207
+ //# sourceMappingURL=TargetComments.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TargetComments.js","names":[],"sources":["../../../src/planmagnet/comments/TargetComments.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { Card, CardContent, CardHeader, CardTitle } from '@burdenoff/fe-libs/ui';\nimport { MessageSquare } from 'lucide-react';\nimport { CommentThread } from './CommentThread';\n\n/**\n * Comments on a project or a doc (CWF-12) — the `PlanmagnetComment` type (`targetType` PROJECT | DOC), which\n * means exactly what `PlanmagnetWorkItemComment` means on a work item (see its schema doc comment): same\n * threading (CWF-02), resolution (CWF-14) and mention (CWF-13) behaviour, via the same `CommentThread` engine\n * `WorkItemComments.tsx` uses — only the GraphQL operation names differ per target.\n *\n * A viewer who can read but not write (e.g. a stakeholder-viewer role) sees the thread and gets the same\n * \"Your role can read but not comment.\" refusal `CommentThread` already shows on a FORBIDDEN post — there is no\n * separate read-only banner here; the refusal only appears once they actually try to post.\n */\n\nconst PROJECT_COMMENTS = gql`\n query ProjectComments($projectId: ID!, $pagination: PlanmagnetPaginationInput) {\n planmagnetProjectComments(projectId: $projectId, pagination: $pagination) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n items {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n replies {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n }\n }\n }\n }\n`;\nconst ADD_PROJECT_COMMENT = gql`\n mutation ProjectCommentAdd($input: PlanmagnetAddProjectCommentInput!) {\n planmagnetAddProjectComment(input: $input) {\n id\n }\n }\n`;\nconst EDIT_PROJECT_COMMENT = gql`\n mutation ProjectCommentEdit($id: ID!, $body: String!) {\n planmagnetEditProjectComment(id: $id, body: $body) {\n id\n body\n editedAt\n }\n }\n`;\nconst DELETE_PROJECT_COMMENT = gql`\n mutation ProjectCommentDelete($id: ID!) {\n planmagnetDeleteProjectComment(id: $id)\n }\n`;\nconst RESOLVE_PROJECT_COMMENT = gql`\n mutation ProjectCommentResolve($id: ID!, $resolved: Boolean!) {\n planmagnetResolveProjectComment(id: $id, resolved: $resolved) {\n id\n status\n resolvedBy\n resolvedAt\n }\n }\n`;\n\nexport function ProjectComments({ projectId }: { projectId: string }) {\n const [totalCount, setTotalCount] = useState<number | null>(null);\n return (\n <Card data-testid=\"project-comments\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <MessageSquare className=\"h-4 w-4\" />\n Comments{totalCount !== null ? ` (${totalCount})` : ''}\n </CardTitle>\n </CardHeader>\n <CardContent>\n <CommentThread\n targetNoun=\"project\"\n idPrefix={`project-comment-${projectId}`}\n query={{\n document: PROJECT_COMMENTS,\n dataKey: 'planmagnetProjectComments',\n variables: { projectId },\n skip: !projectId,\n }}\n add={{\n document: ADD_PROJECT_COMMENT,\n buildVariables: (body, parentId) => ({ input: { projectId, body, parentId } }),\n }}\n edit={EDIT_PROJECT_COMMENT}\n remove={DELETE_PROJECT_COMMENT}\n resolve={RESOLVE_PROJECT_COMMENT}\n refetchQueries={['ProjectComments']}\n onTotalCount={setTotalCount}\n />\n </CardContent>\n </Card>\n );\n}\n\nconst DOC_COMMENTS = gql`\n query DocComments($docId: ID!, $pagination: PlanmagnetPaginationInput) {\n planmagnetDocComments(docId: $docId, pagination: $pagination) {\n totalCount\n pageInfo {\n hasNextPage\n endCursor\n }\n items {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n replies {\n id\n authorId\n body\n createdAt\n editedAt\n parentId\n status\n resolvedBy\n resolvedAt\n mentions\n }\n }\n }\n }\n`;\nconst ADD_DOC_COMMENT = gql`\n mutation DocCommentAdd($input: PlanmagnetAddDocCommentInput!) {\n planmagnetAddDocComment(input: $input) {\n id\n }\n }\n`;\nconst EDIT_DOC_COMMENT = gql`\n mutation DocCommentEdit($id: ID!, $body: String!) {\n planmagnetEditDocComment(id: $id, body: $body) {\n id\n body\n editedAt\n }\n }\n`;\nconst DELETE_DOC_COMMENT = gql`\n mutation DocCommentDelete($id: ID!) {\n planmagnetDeleteDocComment(id: $id)\n }\n`;\nconst RESOLVE_DOC_COMMENT = gql`\n mutation DocCommentResolve($id: ID!, $resolved: Boolean!) {\n planmagnetResolveDocComment(id: $id, resolved: $resolved) {\n id\n status\n resolvedBy\n resolvedAt\n }\n }\n`;\n\nexport function DocComments({ docId }: { docId: string }) {\n const [totalCount, setTotalCount] = useState<number | null>(null);\n return (\n <Card data-testid=\"doc-comments\">\n <CardHeader>\n <CardTitle className=\"flex items-center gap-2\">\n <MessageSquare className=\"h-4 w-4\" />\n Comments{totalCount !== null ? ` (${totalCount})` : ''}\n </CardTitle>\n </CardHeader>\n <CardContent>\n <CommentThread\n targetNoun=\"doc\"\n idPrefix={`doc-comment-${docId}`}\n query={{\n document: DOC_COMMENTS,\n dataKey: 'planmagnetDocComments',\n variables: { docId },\n skip: !docId,\n }}\n add={{\n document: ADD_DOC_COMMENT,\n buildVariables: (body, parentId) => ({ input: { docId, body, parentId } }),\n }}\n edit={EDIT_DOC_COMMENT}\n remove={DELETE_DOC_COMMENT}\n resolve={RESOLVE_DOC_COMMENT}\n refetchQueries={['DocComments']}\n onTotalCount={setTotalCount}\n />\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;AAiBA,IAAM,IAAmB,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCtB,IAAsB,CAAG;;;;;;GAOzB,IAAuB,CAAG;;;;;;;;GAS1B,IAAyB,CAAG;;;;GAK5B,IAA0B,CAAG;;;;;;;;;;AAWnC,SAAgB,EAAgB,EAAE,gBAAoC;CACpE,IAAM,CAAC,GAAY,KAAiB,EAAwB,KAAK;AACjE,QACE,kBAAC,GAAD;EAAM,eAAY;YAAlB,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAW,WAAU;aAArB;IACE,kBAAC,GAAD,EAAe,WAAU,WAAY,CAAA;;IAC5B,MAAe,OAA4B,KAArB,KAAK,EAAW;IACrC;MACD,CAAA,EACb,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACE,YAAW;GACX,UAAU,mBAAmB;GAC7B,OAAO;IACL,UAAU;IACV,SAAS;IACT,WAAW,EAAE,cAAW;IACxB,MAAM,CAAC;IACR;GACD,KAAK;IACH,UAAU;IACV,iBAAiB,GAAM,OAAc,EAAE,OAAO;KAAE;KAAW;KAAM;KAAU,EAAE;IAC9E;GACD,MAAM;GACN,QAAQ;GACR,SAAS;GACT,gBAAgB,CAAC,kBAAkB;GACnC,cAAc;GACd,CAAA,EACU,CAAA,CACT;;;AAIX,IAAM,IAAe,CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmClB,IAAkB,CAAG;;;;;;GAOrB,IAAmB,CAAG;;;;;;;;GAStB,IAAqB,CAAG;;;;GAKxB,IAAsB,CAAG;;;;;;;;;;AAW/B,SAAgB,EAAY,EAAE,YAA4B;CACxD,IAAM,CAAC,GAAY,KAAiB,EAAwB,KAAK;AACjE,QACE,kBAAC,GAAD;EAAM,eAAY;YAAlB,CACE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GAAW,WAAU;aAArB;IACE,kBAAC,GAAD,EAAe,WAAU,WAAY,CAAA;;IAC5B,MAAe,OAA4B,KAArB,KAAK,EAAW;IACrC;MACD,CAAA,EACb,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;GACE,YAAW;GACX,UAAU,eAAe;GACzB,OAAO;IACL,UAAU;IACV,SAAS;IACT,WAAW,EAAE,UAAO;IACpB,MAAM,CAAC;IACR;GACD,KAAK;IACH,UAAU;IACV,iBAAiB,GAAM,OAAc,EAAE,OAAO;KAAE;KAAO;KAAM;KAAU,EAAE;IAC1E;GACD,MAAM;GACN,QAAQ;GACR,SAAS;GACT,gBAAgB,CAAC,cAAc;GAC/B,cAAc;GACd,CAAA,EACU,CAAA,CACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"WorkItemComments.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/comments/WorkItemComments.tsx"],"names":[],"mappings":"AAqGA,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,2CAkHtE"}
1
+ {"version":3,"file":"WorkItemComments.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/comments/WorkItemComments.tsx"],"names":[],"mappings":"AAiFA,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,EAAE;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,2CAiCtE"}