@burdenoff/microfe-bigconsole 2026.1122.3 → 2026.1122.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bigconsole/components/dashboard/DashboardCommentsDrawer.d.ts +16 -0
- package/dist/bigconsole/components/dashboard/DashboardCommentsDrawer.js +308 -0
- package/dist/bigconsole/components/dashboard/DashboardPresenceBar.d.ts +8 -0
- package/dist/bigconsole/components/dashboard/DashboardPresenceBar.js +138 -0
- package/dist/bigconsole/components/dashboard/index.d.ts +2 -0
- package/dist/bigconsole/components/dashboard/index.js +3 -1
- package/dist/bigconsole/components/widgets/WidgetWrapper.js +1 -0
- package/dist/bigconsole/components/widgets/comments/WidgetComments.d.ts +13 -0
- package/dist/bigconsole/components/widgets/comments/WidgetComments.js +213 -117
- package/dist/bigconsole/components/widgets/comments/commentMentions.d.ts +58 -0
- package/dist/bigconsole/components/widgets/comments/commentMentions.js +66 -0
- package/dist/bigconsole/hooks/index.d.ts +2 -1
- package/dist/bigconsole/hooks/index.js +1 -0
- package/dist/bigconsole/hooks/useDashboardPresence.d.ts +44 -0
- package/dist/bigconsole/hooks/useDashboardPresence.js +147 -0
- package/dist/bigconsole/hooks/useWidgetComments.d.ts +12 -1
- package/dist/bigconsole/hooks/useWidgetComments.js +25 -13
- package/dist/bigconsole/pages/DashboardBuilderPage.js +88 -64
- package/dist/bigconsole/pages/DashboardViewPage.js +255 -226
- package/dist/generated/wspace-operations.d.ts +35 -0
- package/dist/generated/wspace-operations.js +353 -54
- package/package.json +1 -1
|
@@ -1,78 +1,83 @@
|
|
|
1
1
|
import e from "../../../hooks/useWidgetComments.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { useShareRecipients as t } from "../../../hooks/useShareRecipients.js";
|
|
3
|
+
import { findActiveMentionTrigger as n, insertMention as r, parseCommentMentionNames as i, resolveActiveMentionIds as a, splitTextWithMentions as o } from "./commentMentions.js";
|
|
4
|
+
import { useCallback as s, useEffect as c, useMemo as l, useRef as u, useState as d } from "react";
|
|
5
|
+
import { AtSign as f, Check as p, CornerDownRight as m, Loader2 as h, MessageSquare as g, RotateCcw as _, Send as v, Trash2 as y, X as b } from "lucide-react";
|
|
6
|
+
import { useI18n as x } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
7
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
6
8
|
// src/bigconsole/components/widgets/comments/WidgetComments.tsx
|
|
7
|
-
function
|
|
8
|
-
return e("bigconsole.widget.comments.authorLabel", "User {{id}}", { id: t.slice(0, 6) });
|
|
9
|
+
function w(e, t, n) {
|
|
10
|
+
return n.get(t) || e("bigconsole.widget.comments.authorLabel", "User {{id}}", { id: t.slice(0, 6) });
|
|
9
11
|
}
|
|
10
|
-
function
|
|
12
|
+
function T(e) {
|
|
11
13
|
let t = new Date(e);
|
|
12
14
|
return Number.isNaN(t.getTime()) ? "" : new Intl.DateTimeFormat(void 0, {
|
|
13
15
|
dateStyle: "medium",
|
|
14
16
|
timeStyle: "short"
|
|
15
17
|
}).format(t);
|
|
16
18
|
}
|
|
17
|
-
var
|
|
18
|
-
let { t:
|
|
19
|
-
return /* @__PURE__ */
|
|
19
|
+
var E = ({ comment: e, isReply: t, busy: n, memberNames: r, onResolve: a, onDelete: s, onReply: c }) => {
|
|
20
|
+
let { t: u } = x(), d = !!e.resolvedAt, f = e.content.text ?? e.content.markdown ?? "", h = l(() => i(e.metadata), [e.metadata]), g = l(() => o(f, h), [f, h]);
|
|
21
|
+
return /* @__PURE__ */ S("div", {
|
|
20
22
|
className: t ? "pl-6" : "",
|
|
21
|
-
children: /* @__PURE__ */
|
|
23
|
+
children: /* @__PURE__ */ C("div", {
|
|
22
24
|
className: "rounded-md border border-[var(--color-border-default)] bg-bg-surface p-2.5",
|
|
23
25
|
children: [
|
|
24
|
-
/* @__PURE__ */
|
|
26
|
+
/* @__PURE__ */ C("div", {
|
|
25
27
|
className: "flex items-center justify-between gap-2",
|
|
26
|
-
children: [/* @__PURE__ */
|
|
28
|
+
children: [/* @__PURE__ */ S("span", {
|
|
27
29
|
className: "text-xs font-medium text-text-primary",
|
|
28
|
-
children:
|
|
29
|
-
}), /* @__PURE__ */
|
|
30
|
+
children: w(u, e.authorId, r)
|
|
31
|
+
}), /* @__PURE__ */ S("span", {
|
|
30
32
|
className: "text-[10px] text-text-muted tabular-nums",
|
|
31
|
-
children:
|
|
33
|
+
children: T(e.createdAt)
|
|
32
34
|
})]
|
|
33
35
|
}),
|
|
34
|
-
/* @__PURE__ */
|
|
36
|
+
/* @__PURE__ */ S("p", {
|
|
35
37
|
className: "mt-1 whitespace-pre-wrap break-words text-sm text-text-secondary",
|
|
36
|
-
children:
|
|
38
|
+
children: g.map((e, t) => e.isMention ? /* @__PURE__ */ S("span", {
|
|
39
|
+
className: "rounded bg-bg-sunken px-1 py-0.5 text-xs font-medium text-action-primary-bg",
|
|
40
|
+
children: e.text
|
|
41
|
+
}, t) : /* @__PURE__ */ S("span", { children: e.text }, t))
|
|
37
42
|
}),
|
|
38
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ C("div", {
|
|
39
44
|
className: "mt-1.5 flex items-center gap-2",
|
|
40
45
|
children: [
|
|
41
|
-
|
|
46
|
+
d && /* @__PURE__ */ C("span", {
|
|
42
47
|
className: "inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium bg-status-success-bg text-status-success-text",
|
|
43
48
|
children: [
|
|
44
|
-
/* @__PURE__ */
|
|
49
|
+
/* @__PURE__ */ S(p, { className: "h-3 w-3" }),
|
|
45
50
|
" ",
|
|
46
|
-
|
|
51
|
+
u("bigconsole.widget.comments.resolvedBadge", "Resolved")
|
|
47
52
|
]
|
|
48
53
|
}),
|
|
49
|
-
|
|
54
|
+
c && /* @__PURE__ */ C("button", {
|
|
50
55
|
type: "button",
|
|
51
56
|
disabled: n,
|
|
52
|
-
onClick: () =>
|
|
57
|
+
onClick: () => c(e.id),
|
|
53
58
|
className: "inline-flex items-center gap-1 text-[11px] text-text-muted hover:text-text-primary disabled:opacity-50",
|
|
54
59
|
children: [
|
|
55
|
-
/* @__PURE__ */ m
|
|
60
|
+
/* @__PURE__ */ S(m, { className: "h-3 w-3" }),
|
|
56
61
|
" ",
|
|
57
|
-
|
|
62
|
+
u("bigconsole.widget.comments.reply", "Reply")
|
|
58
63
|
]
|
|
59
64
|
}),
|
|
60
|
-
/* @__PURE__ */
|
|
65
|
+
/* @__PURE__ */ C("button", {
|
|
61
66
|
type: "button",
|
|
62
67
|
disabled: n,
|
|
63
|
-
onClick: () =>
|
|
68
|
+
onClick: () => a(e.id, !d),
|
|
64
69
|
className: "inline-flex items-center gap-1 text-[11px] text-text-muted hover:text-text-primary disabled:opacity-50",
|
|
65
|
-
children: [
|
|
70
|
+
children: [S(d ? _ : p, { className: "h-3 w-3" }), d ? u("bigconsole.widget.comments.reopen", "Reopen") : u("bigconsole.widget.comments.resolve", "Resolve")]
|
|
66
71
|
}),
|
|
67
|
-
/* @__PURE__ */
|
|
72
|
+
/* @__PURE__ */ C("button", {
|
|
68
73
|
type: "button",
|
|
69
74
|
disabled: n,
|
|
70
|
-
onClick: () =>
|
|
75
|
+
onClick: () => s(e.id),
|
|
71
76
|
className: "inline-flex items-center gap-1 text-[11px] text-status-error-text hover:opacity-80 disabled:opacity-50",
|
|
72
77
|
children: [
|
|
73
|
-
/* @__PURE__ */
|
|
78
|
+
/* @__PURE__ */ S(y, { className: "h-3 w-3" }),
|
|
74
79
|
" ",
|
|
75
|
-
|
|
80
|
+
u("bigconsole.widget.comments.delete", "Delete")
|
|
76
81
|
]
|
|
77
82
|
})
|
|
78
83
|
]
|
|
@@ -80,145 +85,236 @@ var v = ({ comment: e, isReply: t, busy: n, onResolve: r, onDelete: i, onReply:
|
|
|
80
85
|
]
|
|
81
86
|
})
|
|
82
87
|
});
|
|
83
|
-
},
|
|
84
|
-
let { t:
|
|
85
|
-
|
|
86
|
-
e
|
|
88
|
+
}, D = ({ placeholder: e, busy: t, autoFocus: i, candidates: o, onSubmit: s, onCancel: c }) => {
|
|
89
|
+
let { t: p } = x(), [m, g] = d(""), [_, y] = d(null), [w, T] = d(() => /* @__PURE__ */ new Map()), E = u(null), D = l(() => {
|
|
90
|
+
if (!_) return [];
|
|
91
|
+
let e = _.query.trim().toLowerCase();
|
|
92
|
+
return o.filter((t) => !e || t.name.toLowerCase().includes(e) || (t.email?.toLowerCase().includes(e) ?? !1)).slice(0, 6);
|
|
93
|
+
}, [o, _]), O = (e, t) => {
|
|
94
|
+
g(e), y(n(e, t));
|
|
95
|
+
}, k = (e) => {
|
|
96
|
+
if (!_) return;
|
|
97
|
+
let { nextText: t, nextCursor: n } = r(m, _, e.name);
|
|
98
|
+
g(t), y(null), T((t) => {
|
|
99
|
+
let n = new Map(t);
|
|
100
|
+
return n.set(e.id, e.name), n;
|
|
101
|
+
}), window.requestAnimationFrame(() => {
|
|
102
|
+
let e = E.current;
|
|
103
|
+
e && (e.focus(), e.setSelectionRange(n, n));
|
|
104
|
+
});
|
|
105
|
+
}, A = () => {
|
|
106
|
+
let e = E.current, t = e?.selectionStart ?? m.length, n = m.slice(0, t), r = m.slice(t), i = n.length > 0 && !/\s$/.test(n) ? " " : "", a = `${n}${i}@${r}`, o = n.length + i.length + 1;
|
|
107
|
+
O(a, o), window.requestAnimationFrame(() => {
|
|
108
|
+
e && (e.focus(), e.setSelectionRange(o, o));
|
|
109
|
+
});
|
|
110
|
+
}, j = async () => {
|
|
111
|
+
let e = m.trim();
|
|
112
|
+
if (!e) return;
|
|
113
|
+
let t = a(e, w);
|
|
114
|
+
await s(e, t, t.map((e) => w.get(e)).filter((e) => !!e)) !== !1 && (g(""), y(null), T(/* @__PURE__ */ new Map()));
|
|
87
115
|
};
|
|
88
|
-
return /* @__PURE__ */
|
|
89
|
-
className: "
|
|
90
|
-
children: [/* @__PURE__ */
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
rows: 2,
|
|
98
|
-
placeholder: e,
|
|
99
|
-
className: "flex-1 resize-none rounded-md border border-[var(--color-border-default)] bg-bg-surface px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-action-primary-bg"
|
|
100
|
-
}), /* @__PURE__ */ h("div", {
|
|
101
|
-
className: "flex flex-col gap-1",
|
|
102
|
-
children: [/* @__PURE__ */ m("button", {
|
|
116
|
+
return /* @__PURE__ */ C("div", {
|
|
117
|
+
className: "relative",
|
|
118
|
+
children: [_ && D.length > 0 && /* @__PURE__ */ S("div", {
|
|
119
|
+
role: "listbox",
|
|
120
|
+
"aria-label": p("bigconsole.widget.comments.mentionPickerAria", "Mention a workspace member"),
|
|
121
|
+
"data-testid": "comment-mention-picker",
|
|
122
|
+
className: "absolute bottom-full left-0 right-0 z-50 mb-1 max-h-40 overflow-auto rounded-md border border-[var(--color-border-default)] bg-bg-surface py-1 shadow-lg",
|
|
123
|
+
children: D.map((e) => /* @__PURE__ */ C("button", {
|
|
103
124
|
type: "button",
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
125
|
+
role: "option",
|
|
126
|
+
"aria-selected": !1,
|
|
127
|
+
"data-testid": "comment-mention-option",
|
|
128
|
+
onMouseDown: (t) => {
|
|
129
|
+
t.preventDefault(), k(e);
|
|
130
|
+
},
|
|
131
|
+
className: "flex w-full items-center justify-between gap-2 px-2.5 py-1.5 text-left text-xs text-text-primary hover:bg-bg-sunken",
|
|
132
|
+
children: [/* @__PURE__ */ S("span", {
|
|
133
|
+
className: "truncate font-medium",
|
|
134
|
+
children: e.name
|
|
135
|
+
}), e.email && /* @__PURE__ */ S("span", {
|
|
136
|
+
className: "truncate text-[10px] text-text-muted",
|
|
137
|
+
children: e.email
|
|
138
|
+
})]
|
|
139
|
+
}, e.id))
|
|
140
|
+
}), /* @__PURE__ */ C("div", {
|
|
141
|
+
className: "flex items-end gap-2",
|
|
142
|
+
children: [/* @__PURE__ */ S("textarea", {
|
|
143
|
+
ref: E,
|
|
144
|
+
autoFocus: i,
|
|
145
|
+
value: m,
|
|
146
|
+
onChange: (e) => O(e.target.value, e.target.selectionStart ?? e.target.value.length),
|
|
147
|
+
onKeyUp: (e) => {
|
|
148
|
+
let t = e.currentTarget;
|
|
149
|
+
y(n(t.value, t.selectionStart ?? t.value.length));
|
|
150
|
+
},
|
|
151
|
+
onKeyDown: (e) => {
|
|
152
|
+
e.stopPropagation(), e.key === "Escape" && _ ? (e.preventDefault(), y(null)) : (e.metaKey || e.ctrlKey) && e.key === "Enter" && (e.preventDefault(), j());
|
|
153
|
+
},
|
|
154
|
+
rows: 2,
|
|
155
|
+
placeholder: e,
|
|
156
|
+
className: "flex-1 resize-none rounded-md border border-[var(--color-border-default)] bg-bg-surface px-2.5 py-1.5 text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:ring-2 focus:ring-action-primary-bg"
|
|
157
|
+
}), /* @__PURE__ */ C("div", {
|
|
158
|
+
className: "flex flex-col gap-1",
|
|
159
|
+
children: [
|
|
160
|
+
o.length > 0 && /* @__PURE__ */ S("button", {
|
|
161
|
+
type: "button",
|
|
162
|
+
onClick: A,
|
|
163
|
+
title: p("bigconsole.widget.comments.mentionTitle", "Mention a teammate (@)"),
|
|
164
|
+
"aria-label": p("bigconsole.widget.comments.mentionTitle", "Mention a teammate (@)"),
|
|
165
|
+
className: "inline-flex items-center justify-center rounded-md border border-[var(--color-border-default)] p-1.5 text-text-muted hover:bg-bg-sunken hover:text-text-primary",
|
|
166
|
+
children: /* @__PURE__ */ S(f, { className: "h-3.5 w-3.5" })
|
|
167
|
+
}),
|
|
168
|
+
/* @__PURE__ */ S("button", {
|
|
169
|
+
type: "button",
|
|
170
|
+
disabled: t || !m.trim(),
|
|
171
|
+
onClick: () => void j(),
|
|
172
|
+
title: p("bigconsole.widget.comments.postTitle", "Post (⌘/Ctrl + Enter)"),
|
|
173
|
+
className: "inline-flex items-center justify-center rounded-md bg-action-primary-bg p-1.5 text-action-primary-text hover:opacity-90 disabled:opacity-50",
|
|
174
|
+
children: t ? /* @__PURE__ */ S(h, { className: "h-4 w-4 animate-spin" }) : /* @__PURE__ */ S(v, { className: "h-4 w-4" })
|
|
175
|
+
}),
|
|
176
|
+
c && /* @__PURE__ */ S("button", {
|
|
177
|
+
type: "button",
|
|
178
|
+
onClick: c,
|
|
179
|
+
className: "inline-flex items-center justify-center rounded-md border border-[var(--color-border-default)] p-1.5 text-text-muted hover:text-text-primary",
|
|
180
|
+
title: p("bigconsole.widget.comments.cancelReplyTitle", "Cancel reply"),
|
|
181
|
+
children: /* @__PURE__ */ S(b, { className: "h-4 w-4" })
|
|
182
|
+
})
|
|
183
|
+
]
|
|
115
184
|
})]
|
|
116
185
|
})]
|
|
117
186
|
});
|
|
118
|
-
},
|
|
119
|
-
let { t:
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
187
|
+
}, O = ({ widgetId: n, widgetTitle: r, onClose: i }) => {
|
|
188
|
+
let { t: a } = x(), { threads: o, count: f, loading: p, error: m, mutating: _, addComment: v, resolveComment: y, deleteComment: w } = e(n), { results: T } = t(!0, ""), [O, k] = d(null), [A, j] = d(!1), M = u(null), N = l(() => T.filter((e) => e.type === "USER").map((e) => ({
|
|
189
|
+
id: e.id,
|
|
190
|
+
name: e.name,
|
|
191
|
+
...e.email ? { email: e.email } : {}
|
|
192
|
+
})), [T]), P = l(() => {
|
|
193
|
+
let e = /* @__PURE__ */ new Map();
|
|
194
|
+
for (let t of N) e.set(t.id, t.name);
|
|
195
|
+
return e;
|
|
196
|
+
}, [N]);
|
|
197
|
+
c(() => {
|
|
198
|
+
if (!A) return;
|
|
199
|
+
let e = M.current;
|
|
123
200
|
e?.scrollTo({
|
|
124
201
|
top: e.scrollHeight,
|
|
125
202
|
behavior: "smooth"
|
|
126
|
-
}),
|
|
127
|
-
}, [
|
|
128
|
-
let
|
|
129
|
-
let
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
203
|
+
}), j(!1);
|
|
204
|
+
}, [A, o]);
|
|
205
|
+
let F = s(async (e, t, i, a) => {
|
|
206
|
+
let o = {
|
|
207
|
+
...a ? { parentCommentId: a } : {},
|
|
208
|
+
...t.length > 0 ? {
|
|
209
|
+
mentionUserIds: t,
|
|
210
|
+
mentionNames: i
|
|
211
|
+
} : {},
|
|
212
|
+
anchor: {
|
|
213
|
+
anchorType: "widget",
|
|
214
|
+
widgetId: n,
|
|
215
|
+
...r ? { widgetTitle: r } : {}
|
|
216
|
+
}
|
|
217
|
+
}, s = await v(e, o);
|
|
218
|
+
return s && (a ? k(null) : j(!0)), s;
|
|
219
|
+
}, [
|
|
220
|
+
v,
|
|
221
|
+
n,
|
|
222
|
+
r
|
|
223
|
+
]);
|
|
224
|
+
return /* @__PURE__ */ C("div", {
|
|
133
225
|
className: "absolute inset-0 z-40 flex flex-col bg-bg-surface/98 backdrop-blur-sm",
|
|
134
226
|
role: "dialog",
|
|
135
|
-
"aria-label":
|
|
227
|
+
"aria-label": a("bigconsole.widget.comments.dialogAriaLabel", "Widget comments"),
|
|
136
228
|
tabIndex: -1,
|
|
137
229
|
onClick: (e) => e.stopPropagation(),
|
|
138
230
|
onKeyDown: (e) => {
|
|
139
|
-
e.key === "Escape" && (e.stopPropagation(),
|
|
231
|
+
e.key === "Escape" && (e.stopPropagation(), i());
|
|
140
232
|
},
|
|
141
233
|
children: [
|
|
142
|
-
/* @__PURE__ */
|
|
234
|
+
/* @__PURE__ */ C("div", {
|
|
143
235
|
className: "flex min-w-0 items-center justify-between gap-2 border-b border-[var(--color-border-subtle)] bg-bg-surface px-3 py-2 sm:px-4",
|
|
144
|
-
children: [/* @__PURE__ */
|
|
236
|
+
children: [/* @__PURE__ */ C("h3", {
|
|
145
237
|
className: "flex min-w-0 items-center gap-2 text-sm font-semibold leading-tight tracking-tight text-text-primary",
|
|
146
238
|
children: [
|
|
147
|
-
/* @__PURE__ */
|
|
239
|
+
/* @__PURE__ */ S(g, {
|
|
148
240
|
"aria-hidden": "true",
|
|
149
241
|
className: "h-icon-sm w-icon-sm shrink-0 text-text-secondary"
|
|
150
242
|
}),
|
|
151
|
-
|
|
152
|
-
/* @__PURE__ */
|
|
243
|
+
a("bigconsole.widget.comments.title", "Comments"),
|
|
244
|
+
/* @__PURE__ */ S("span", {
|
|
153
245
|
className: "rounded-full bg-bg-sunken px-1.5 py-0.5 text-[10px] text-text-secondary tabular-nums",
|
|
154
|
-
children:
|
|
246
|
+
children: f
|
|
155
247
|
})
|
|
156
248
|
]
|
|
157
|
-
}), /* @__PURE__ */
|
|
249
|
+
}), /* @__PURE__ */ S("button", {
|
|
158
250
|
type: "button",
|
|
159
|
-
onClick:
|
|
160
|
-
"aria-label":
|
|
251
|
+
onClick: i,
|
|
252
|
+
"aria-label": a("bigconsole.widget.comments.closeAriaLabel", "Close comments"),
|
|
161
253
|
className: "shrink-0 rounded-button p-1 text-text-muted hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-bg-surface",
|
|
162
|
-
children: /* @__PURE__ */
|
|
254
|
+
children: /* @__PURE__ */ S(b, { className: "h-4 w-4" })
|
|
163
255
|
})]
|
|
164
256
|
}),
|
|
165
|
-
/* @__PURE__ */
|
|
166
|
-
ref:
|
|
257
|
+
/* @__PURE__ */ C("div", {
|
|
258
|
+
ref: M,
|
|
167
259
|
className: "flex-1 space-y-3 overflow-auto p-3",
|
|
168
260
|
children: [
|
|
169
|
-
|
|
261
|
+
p && o.length === 0 && /* @__PURE__ */ S("div", {
|
|
170
262
|
className: "flex items-center justify-center py-8 text-text-muted",
|
|
171
|
-
children: /* @__PURE__ */
|
|
263
|
+
children: /* @__PURE__ */ S(h, { className: "h-5 w-5 animate-spin" })
|
|
172
264
|
}),
|
|
173
|
-
|
|
265
|
+
m && !p && /* @__PURE__ */ S("p", {
|
|
174
266
|
role: "alert",
|
|
175
267
|
className: "rounded-input border border-[var(--color-status-error-border)] bg-status-error-bg-subtle px-2.5 py-2 text-xs text-[var(--color-status-error-text)]",
|
|
176
|
-
children:
|
|
268
|
+
children: a("bigconsole.widget.comments.loadError", "Couldn’t load comments.")
|
|
177
269
|
}),
|
|
178
|
-
!
|
|
270
|
+
!p && !m && o.length === 0 && /* @__PURE__ */ S("p", {
|
|
179
271
|
className: "py-8 text-center text-sm text-text-muted",
|
|
180
|
-
children:
|
|
272
|
+
children: a("bigconsole.widget.comments.empty", "No comments yet. Start the conversation.")
|
|
181
273
|
}),
|
|
182
|
-
|
|
274
|
+
o.map(({ comment: e, replies: t }) => /* @__PURE__ */ C("div", {
|
|
183
275
|
className: "space-y-2",
|
|
184
276
|
children: [
|
|
185
|
-
/* @__PURE__ */
|
|
277
|
+
/* @__PURE__ */ S(E, {
|
|
186
278
|
comment: e,
|
|
187
|
-
busy:
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
279
|
+
busy: _,
|
|
280
|
+
memberNames: P,
|
|
281
|
+
onResolve: (e, t) => void y(e, t),
|
|
282
|
+
onDelete: (e) => void w(e),
|
|
283
|
+
onReply: (e) => k((t) => t === e ? null : e)
|
|
191
284
|
}),
|
|
192
|
-
t.map((e) => /* @__PURE__ */
|
|
285
|
+
t.map((e) => /* @__PURE__ */ S(E, {
|
|
193
286
|
comment: e,
|
|
194
287
|
isReply: !0,
|
|
195
|
-
busy:
|
|
196
|
-
|
|
197
|
-
|
|
288
|
+
busy: _,
|
|
289
|
+
memberNames: P,
|
|
290
|
+
onResolve: (e, t) => void y(e, t),
|
|
291
|
+
onDelete: (e) => void w(e)
|
|
198
292
|
}, e.id)),
|
|
199
|
-
|
|
293
|
+
O === e.id && /* @__PURE__ */ S("div", {
|
|
200
294
|
className: "pl-6",
|
|
201
|
-
children: /* @__PURE__ */
|
|
202
|
-
placeholder:
|
|
203
|
-
busy:
|
|
295
|
+
children: /* @__PURE__ */ S(D, {
|
|
296
|
+
placeholder: a("bigconsole.widget.comments.replyPlaceholder", "Write a reply… (type @ to mention)"),
|
|
297
|
+
busy: _,
|
|
204
298
|
autoFocus: !0,
|
|
205
|
-
|
|
206
|
-
|
|
299
|
+
candidates: N,
|
|
300
|
+
onSubmit: (t, n, r) => F(t, n, r, e.id),
|
|
301
|
+
onCancel: () => k(null)
|
|
207
302
|
})
|
|
208
303
|
})
|
|
209
304
|
]
|
|
210
305
|
}, e.id))
|
|
211
306
|
]
|
|
212
307
|
}),
|
|
213
|
-
/* @__PURE__ */
|
|
308
|
+
/* @__PURE__ */ S("div", {
|
|
214
309
|
className: "border-t border-[var(--color-border-default)] p-3",
|
|
215
|
-
children: /* @__PURE__ */
|
|
216
|
-
placeholder:
|
|
217
|
-
busy:
|
|
218
|
-
|
|
310
|
+
children: /* @__PURE__ */ S(D, {
|
|
311
|
+
placeholder: a("bigconsole.widget.comments.addPlaceholder", "Add a comment… (type @ to mention)"),
|
|
312
|
+
busy: _,
|
|
313
|
+
candidates: N,
|
|
314
|
+
onSubmit: (e, t, n) => F(e, t, n)
|
|
219
315
|
})
|
|
220
316
|
})
|
|
221
317
|
]
|
|
222
318
|
});
|
|
223
319
|
};
|
|
224
|
-
export {
|
|
320
|
+
export { D as CommentComposer, O as WidgetComments, O as default };
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for @mention detection, mention extraction, text segment rendering,
|
|
3
|
+
* and structured inline-anchor metadata on BigConsole EntityComments.
|
|
4
|
+
*/
|
|
5
|
+
export type CommentAnchorType = 'dashboard' | 'widget' | 'region';
|
|
6
|
+
export interface CommentAnchor {
|
|
7
|
+
anchorType: CommentAnchorType;
|
|
8
|
+
widgetId?: string;
|
|
9
|
+
widgetTitle?: string;
|
|
10
|
+
regionLabel?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface MentionCandidate {
|
|
13
|
+
id: string;
|
|
14
|
+
name: string;
|
|
15
|
+
email?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface MentionTriggerMatch {
|
|
18
|
+
/** Character index of the leading `@`. */
|
|
19
|
+
start: number;
|
|
20
|
+
/** Character index of the end of the active token (cursor position). */
|
|
21
|
+
end: number;
|
|
22
|
+
/** Partial query typed after `@`. */
|
|
23
|
+
query: string;
|
|
24
|
+
}
|
|
25
|
+
export interface TextSegment {
|
|
26
|
+
text: string;
|
|
27
|
+
isMention: boolean;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Find an active `@mention` token immediately before `cursorPos`.
|
|
31
|
+
* Matches `@` at string start or after whitespace, followed by up to 40
|
|
32
|
+
* non-newline characters without consecutive spaces.
|
|
33
|
+
*/
|
|
34
|
+
export declare function findActiveMentionTrigger(text: string, cursorPos: number): MentionTriggerMatch | null;
|
|
35
|
+
/**
|
|
36
|
+
* Replace the active `@query` span with `@<displayName> ` and return the new
|
|
37
|
+
* string plus the cursor index immediately after the inserted space.
|
|
38
|
+
*/
|
|
39
|
+
export declare function insertMention(text: string, trigger: MentionTriggerMatch, displayName: string): {
|
|
40
|
+
nextText: string;
|
|
41
|
+
nextCursor: number;
|
|
42
|
+
token: string;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Keep only mentioned user ids whose `@<name>` token still appears in `text`,
|
|
46
|
+
* deduplicated in insertion order.
|
|
47
|
+
*/
|
|
48
|
+
export declare function resolveActiveMentionIds(text: string, selectedMentions: ReadonlyMap<string, string>): string[];
|
|
49
|
+
/**
|
|
50
|
+
* Split comment body text into plain and `@mention` segments for safe React
|
|
51
|
+
* rendering (no HTML injection). Recognises explicit mention names from
|
|
52
|
+
* metadata first, then simple `@handle` tokens.
|
|
53
|
+
*/
|
|
54
|
+
export declare function splitTextWithMentions(text: string, knownMentionNames?: readonly string[]): TextSegment[];
|
|
55
|
+
/** Parse optional inline anchor metadata stored on an EntityComment. */
|
|
56
|
+
export declare function parseCommentAnchor(metadata: unknown): CommentAnchor | null;
|
|
57
|
+
/** Parse optional mention display names stored alongside a comment. */
|
|
58
|
+
export declare function parseCommentMentionNames(metadata: unknown): string[];
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
// src/bigconsole/components/widgets/comments/commentMentions.ts
|
|
2
|
+
function e(e, t) {
|
|
3
|
+
let n = Math.max(0, Math.min(t, e.length)), r = e.slice(0, n), i = /(^|[\s(])@([^\s@\n]{0,40})$/.exec(r);
|
|
4
|
+
if (!i) return null;
|
|
5
|
+
let a = i[2] ?? "";
|
|
6
|
+
return {
|
|
7
|
+
start: n - a.length - 1,
|
|
8
|
+
end: n,
|
|
9
|
+
query: a
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function t(e, t, n) {
|
|
13
|
+
let r = `@${n.trim().replace(/\s+/g, " ")}`, i = e.slice(0, t.start), a = e.slice(t.end), o = a.length === 0 || !a.startsWith(" ") ? `${r} ` : r;
|
|
14
|
+
return {
|
|
15
|
+
nextText: `${i}${o}${a}`,
|
|
16
|
+
nextCursor: i.length + o.length,
|
|
17
|
+
token: r
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function n(e, t) {
|
|
21
|
+
let n = e.toLowerCase(), r = [];
|
|
22
|
+
for (let [e, i] of t.entries()) {
|
|
23
|
+
let t = `@${i.trim().replace(/\s+/g, " ").toLowerCase()}`;
|
|
24
|
+
t.length > 1 && n.includes(t) && !r.includes(e) && r.push(e);
|
|
25
|
+
}
|
|
26
|
+
return r;
|
|
27
|
+
}
|
|
28
|
+
function r(e, t) {
|
|
29
|
+
if (!e) return [];
|
|
30
|
+
let n = [...(t ?? []).map((e) => e.trim().replace(/\s+/g, " ")).filter((e) => e.length > 0).sort((e, t) => t.length - e.length).map((e) => `@${e.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}`), "@[A-Za-z0-9._-]{2,40}"], r = RegExp(`(${n.join("|")})`, "gi"), i = [], a = 0, o;
|
|
31
|
+
for (; (o = r.exec(e)) !== null;) {
|
|
32
|
+
let t = o.index;
|
|
33
|
+
t > 0 && /[A-Za-z0-9._%+-]/.test(e[t - 1] ?? "") || (t > a && i.push({
|
|
34
|
+
text: e.slice(a, t),
|
|
35
|
+
isMention: !1
|
|
36
|
+
}), i.push({
|
|
37
|
+
text: o[0],
|
|
38
|
+
isMention: !0
|
|
39
|
+
}), a = t + o[0].length);
|
|
40
|
+
}
|
|
41
|
+
return a < e.length && i.push({
|
|
42
|
+
text: e.slice(a),
|
|
43
|
+
isMention: !1
|
|
44
|
+
}), i;
|
|
45
|
+
}
|
|
46
|
+
function i(e) {
|
|
47
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
48
|
+
}
|
|
49
|
+
function a(e) {
|
|
50
|
+
if (!i(e)) return null;
|
|
51
|
+
let t = i(e.anchor) ? e.anchor : e, n = t.anchorType;
|
|
52
|
+
if (n !== "dashboard" && n !== "widget" && n !== "region") return null;
|
|
53
|
+
let r = typeof t.widgetId == "string" && t.widgetId.trim() ? t.widgetId.trim() : void 0, a = typeof t.widgetTitle == "string" && t.widgetTitle.trim() ? t.widgetTitle.trim() : void 0, o = typeof t.regionLabel == "string" && t.regionLabel.trim() ? t.regionLabel.trim() : void 0;
|
|
54
|
+
return {
|
|
55
|
+
anchorType: n,
|
|
56
|
+
...r ? { widgetId: r } : {},
|
|
57
|
+
...a ? { widgetTitle: a } : {},
|
|
58
|
+
...o ? { regionLabel: o } : {}
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function o(e) {
|
|
62
|
+
if (!i(e)) return [];
|
|
63
|
+
let t = e.mentionNames;
|
|
64
|
+
return Array.isArray(t) ? t.filter((e) => typeof e == "string" && e.trim().length > 0) : i(t) ? Object.values(t).filter((e) => typeof e == "string" && e.trim().length > 0) : [];
|
|
65
|
+
}
|
|
66
|
+
export { e as findActiveMentionTrigger, t as insertMention, a as parseCommentAnchor, o as parseCommentMentionNames, n as resolveActiveMentionIds, r as splitTextWithMentions };
|
|
@@ -9,7 +9,8 @@ export { useWidgetCatalog, default as useWidgetCatalogDefault } from './useWidge
|
|
|
9
9
|
export type { UseWidgetCatalogParams, UseWidgetCatalogResult } from './useWidgetCatalog';
|
|
10
10
|
export { useAutoRefresh, useWidgetAutoRefresh, formatTimeUntilRefresh, default as useAutoRefreshDefault, } from './useAutoRefresh';
|
|
11
11
|
export { useWidgetOperations, default as useWidgetOperationsDefault } from './useWidgetOperations';
|
|
12
|
-
export { useWidgetComments, WIDGET_COMMENT_ENTITY_TYPE, type WidgetCommentThread, type UseWidgetCommentsResult, default as useWidgetCommentsDefault, } from './useWidgetComments';
|
|
12
|
+
export { useWidgetComments, useDashboardComments, useEntityComments, WIDGET_COMMENT_ENTITY_TYPE, DASHBOARD_COMMENT_ENTITY_TYPE, type AddCommentOptions, type WidgetCommentThread, type UseWidgetCommentsResult, default as useWidgetCommentsDefault, } from './useWidgetComments';
|
|
13
|
+
export { useDashboardPresence, buildPresenceConnectionId, PRESENCE_HEARTBEAT_INTERVAL_MS, PRESENCE_POLL_INTERVAL_MS, PRESENCE_ACTIVE_WINDOW_MS, type DashboardPresenceViewerInfo, type UseDashboardPresenceResult, default as useDashboardPresenceDefault, } from './useDashboardPresence';
|
|
13
14
|
export { useWidgetConfigPersist, type UseWidgetConfigPersistResult, default as useWidgetConfigPersistDefault, } from './useWidgetConfigPersist';
|
|
14
15
|
export { useDashboardOperations, default as useDashboardOperationsDefault, type DashboardListItem, } from './useDashboardOperations';
|
|
15
16
|
export { useWidgetExport, type UseWidgetExportOptions, type UseWidgetExportResult, default as useWidgetExportDefault, } from './useWidgetExport';
|
|
@@ -4,6 +4,7 @@ import "./useWidgetCatalog.js";
|
|
|
4
4
|
import { formatTimeUntilRefresh as n, useWidgetAutoRefresh as r } from "./useAutoRefresh.js";
|
|
5
5
|
import i from "./useWidgetOperations.js";
|
|
6
6
|
import a from "./useWidgetComments.js";
|
|
7
|
+
import "./useDashboardPresence.js";
|
|
7
8
|
import o from "./useWidgetConfigPersist.js";
|
|
8
9
|
import s from "./useDashboardOperations.js";
|
|
9
10
|
import c from "./useWidgetExport.js";
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* useDashboardPresence Hook (BOFF-4144)
|
|
3
|
+
*
|
|
4
|
+
* Wires the live active-viewer roster to `wspace-bigconsole-svc`'s
|
|
5
|
+
* DashboardPresenceProvider (`dashboardPresence`, `heartbeatDashboardPresence`,
|
|
6
|
+
* `leaveDashboardPresence`).
|
|
7
|
+
*
|
|
8
|
+
* Lifecycle:
|
|
9
|
+
* - Generates a stable per-mount `connectionId` matching `^[A-Za-z0-9_.:-]{1,128}$`.
|
|
10
|
+
* - Sends an immediate heartbeat on mount, then every 15s while the tab is visible,
|
|
11
|
+
* and immediately on returning to visible.
|
|
12
|
+
* - Polls `dashboardPresence` every 15s (network-only) so arriving and expiring
|
|
13
|
+
* viewers (server active cutoff: 45s) stay fresh.
|
|
14
|
+
* - Sends a best-effort `leaveDashboardPresence` on unmount and `pagehide`.
|
|
15
|
+
* - Resolves viewer display names strictly within the current workspace via
|
|
16
|
+
* `workspaceMemberIdentities`, falling back cleanly to a short handle.
|
|
17
|
+
*/
|
|
18
|
+
/** Heartbeat cadence matching backend presence.gql (every ~15s; server expires at 45s). */
|
|
19
|
+
export declare const PRESENCE_HEARTBEAT_INTERVAL_MS = 15000;
|
|
20
|
+
/** Roster poll cadence so newly joined or expired viewers appear promptly. */
|
|
21
|
+
export declare const PRESENCE_POLL_INTERVAL_MS = 15000;
|
|
22
|
+
/** Backend active cutoff (45s) exposed for UI copy and tests. */
|
|
23
|
+
export declare const PRESENCE_ACTIVE_WINDOW_MS = 45000;
|
|
24
|
+
export interface DashboardPresenceViewerInfo {
|
|
25
|
+
actorId: string;
|
|
26
|
+
displayName: string;
|
|
27
|
+
email?: string;
|
|
28
|
+
connectionCount: number;
|
|
29
|
+
lastSeenAt: string;
|
|
30
|
+
isCurrentUser: boolean;
|
|
31
|
+
}
|
|
32
|
+
export interface UseDashboardPresenceResult {
|
|
33
|
+
viewers: DashboardPresenceViewerInfo[];
|
|
34
|
+
activeCount: number;
|
|
35
|
+
unavailable: boolean;
|
|
36
|
+
loading: boolean;
|
|
37
|
+
error?: Error;
|
|
38
|
+
connectionId: string;
|
|
39
|
+
refetch: () => void;
|
|
40
|
+
}
|
|
41
|
+
/** Generate a valid presence connectionId (`^[A-Za-z0-9_.:-]{1,128}$`). */
|
|
42
|
+
export declare function buildPresenceConnectionId(): string;
|
|
43
|
+
export declare function useDashboardPresence(dashboardId: string | undefined, enabled?: boolean): UseDashboardPresenceResult;
|
|
44
|
+
export default useDashboardPresence;
|