@box/threaded-annotations 3.2.3 → 4.0.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/dist/chunks/messages-view.js +23 -23
- package/dist/chunks/threaded-annotations2.js +61 -67
- package/dist/esm/lib/v2/threaded-annotations-context.js +8 -16
- package/dist/types/lib/v2/stories/shared.d.ts +1 -2
- package/dist/types/lib/v2/threaded-annotations-context.d.ts +0 -12
- package/dist/types/lib/v2/threaded-annotations.d.ts +4 -6
- package/package.json +1 -1
- package/dist/esm/lib/v2/hooks/useScrollToMessage.js +0 -37
- package/dist/types/lib/v2/hooks/useScrollToMessage.d.ts +0 -24
|
@@ -15,26 +15,26 @@ import '../styles/messages-view.css';var u = {
|
|
|
15
15
|
repliesContainer: "_repliesContainer_gor1q_56",
|
|
16
16
|
messagesFade: "_messagesFade_gor1q_62"
|
|
17
17
|
}, d = ({ messages: d, isResolved: f = !1, resolvedBy: p, resolvedAt: m, maxCharacterCount: h, onDelete: g, onThreadDelete: _, onAvatarClick: v, onCopyLink: y, onEdit: b, onEditError: x, onResolve: S, onUnresolve: C, userSelectorProps: w, annotationTarget: T, onAnnotationBadgeClick: E, originalContentDeleted: D }) => {
|
|
18
|
-
let { viewState: O, dispatch: k, isAnnotations: A
|
|
18
|
+
let { viewState: O, dispatch: k, isAnnotations: A } = t(), j = s(null), M = O !== e.Collapsed, N = O === e.Composing, P = d.length > 2, F = P && !M, { handleScroll: I, isOverflowing: L } = a({
|
|
19
19
|
messageCount: d.length,
|
|
20
|
-
containerRef:
|
|
20
|
+
containerRef: j,
|
|
21
21
|
enabled: A,
|
|
22
|
-
isExpanded:
|
|
23
|
-
suppressAutoScroll:
|
|
24
|
-
}),
|
|
25
|
-
if (!
|
|
26
|
-
let
|
|
22
|
+
isExpanded: M,
|
|
23
|
+
suppressAutoScroll: F
|
|
24
|
+
}), R = d[0], z = d.slice(1), B = z.length >= 1, V = z[z.length - 1], H = z.slice(0, -1), U = P && !M;
|
|
25
|
+
if (!R) return null;
|
|
26
|
+
let W = H[H.length - 1]?.author, G = H.length >= 2 ? H[H.length - 2].author : void 0, K = () => k({ type: "EXPAND" });
|
|
27
27
|
return /* @__PURE__ */ l("div", {
|
|
28
|
-
className: o(u.messagesViewWrapper,
|
|
28
|
+
className: o(u.messagesViewWrapper, L && u.overflowing, L && N && u.withEditorBelow),
|
|
29
29
|
children: [/* @__PURE__ */ l("div", {
|
|
30
|
-
ref:
|
|
30
|
+
ref: j,
|
|
31
31
|
className: o(u.messagesView, A && u.scrollable),
|
|
32
|
-
onScroll:
|
|
32
|
+
onScroll: I,
|
|
33
33
|
children: [
|
|
34
34
|
/* @__PURE__ */ c(i, {
|
|
35
|
-
...
|
|
36
|
-
hasReplies:
|
|
37
|
-
showThreadedIndicator:
|
|
35
|
+
...R,
|
|
36
|
+
hasReplies: B,
|
|
37
|
+
showThreadedIndicator: B || f,
|
|
38
38
|
isResolved: f,
|
|
39
39
|
maxCharacterCount: h,
|
|
40
40
|
onDelete: g,
|
|
@@ -51,15 +51,15 @@ import '../styles/messages-view.css';var u = {
|
|
|
51
51
|
onAnnotationBadgeClick: E,
|
|
52
52
|
originalContentDeleted: D
|
|
53
53
|
}),
|
|
54
|
-
|
|
55
|
-
lastUser:
|
|
56
|
-
repliesCount:
|
|
57
|
-
secondLastUser:
|
|
58
|
-
onShowReplies:
|
|
54
|
+
U && W && /* @__PURE__ */ c(r, {
|
|
55
|
+
lastUser: W,
|
|
56
|
+
repliesCount: H.length,
|
|
57
|
+
secondLastUser: G,
|
|
58
|
+
onShowReplies: K
|
|
59
59
|
}),
|
|
60
|
-
|
|
60
|
+
M && H.length > 0 && /* @__PURE__ */ c("div", {
|
|
61
61
|
className: u.repliesContainer,
|
|
62
|
-
children:
|
|
62
|
+
children: H.map((e) => /* @__PURE__ */ c(i, {
|
|
63
63
|
...e,
|
|
64
64
|
showThreadedIndicator: !0,
|
|
65
65
|
isResolved: f,
|
|
@@ -74,8 +74,8 @@ import '../styles/messages-view.css';var u = {
|
|
|
74
74
|
userSelectorProps: w
|
|
75
75
|
}, e.id))
|
|
76
76
|
}),
|
|
77
|
-
|
|
78
|
-
...
|
|
77
|
+
V && /* @__PURE__ */ c(i, {
|
|
78
|
+
...V,
|
|
79
79
|
showThreadedIndicator: f,
|
|
80
80
|
isResolved: f,
|
|
81
81
|
maxCharacterCount: h,
|
|
@@ -93,7 +93,7 @@ import '../styles/messages-view.css';var u = {
|
|
|
93
93
|
createdAt: m
|
|
94
94
|
})
|
|
95
95
|
]
|
|
96
|
-
}),
|
|
96
|
+
}), L && /* @__PURE__ */ c("div", { className: u.messagesFade })]
|
|
97
97
|
});
|
|
98
98
|
};
|
|
99
99
|
export { d as t };
|
|
@@ -2,91 +2,85 @@ import { THREADED_ANNOTATIONS_PORTAL as e } from "../esm/lib/v2/constants.js";
|
|
|
2
2
|
import { MessageEditor as t } from "../esm/lib/components/v2/message-editor/message-editor.js";
|
|
3
3
|
import { ThreadViewState as n, ThreadedAnnotationsProvider as r, useThreadedAnnotationsContext as i } from "../esm/lib/v2/threaded-annotations-context.js";
|
|
4
4
|
import { t as a } from "./messages-view.js";
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import c from "
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
import '../styles/threaded-annotations2.css';var h = {
|
|
5
|
+
import { buildMentionContent as o } from "../esm/lib/v2/utils/build-mention-content.js";
|
|
6
|
+
import s from "clsx";
|
|
7
|
+
import { useCallback as c, useEffect as l, useMemo as u, useRef as d } from "react";
|
|
8
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
9
|
+
import '../styles/threaded-annotations2.css';var m = {
|
|
11
10
|
threadedAnnotations: "_threadedAnnotations_16hhz_1",
|
|
12
11
|
expandable: "_expandable_16hhz_10",
|
|
13
12
|
annotations: "_annotations_16hhz_18",
|
|
14
13
|
highlighted: "_highlighted_16hhz_18"
|
|
15
|
-
},
|
|
16
|
-
let { viewState:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
messages: r,
|
|
20
|
-
scrollToMessageId: F,
|
|
21
|
-
onScrollToMessageComplete: I
|
|
22
|
-
}), u(() => {
|
|
23
|
-
B && !r.some((e) => e.id === B) && z({ type: "CLEAR_EDIT" });
|
|
14
|
+
}, h = ({ messages: r, isResolved: h = !1, resolvedBy: g, resolvedAt: _, maxCharacterCount: v, onDelete: y, onThreadDelete: b, onAvatarClick: x, onCopyLink: S, onEdit: C, onEditError: w, onResolve: T, onUnresolve: E, onPost: D, onPostError: O, userSelectorProps: k, onEditorOpenChange: A, annotationTarget: j, onAnnotationBadgeClick: M, originalContentDeleted: N, isHighlighted: P = !1 }) => {
|
|
15
|
+
let { viewState: F, dispatch: I, editingMessageId: L, replyMention: R, isReplyDisabled: z, isAnnotations: B } = i(), V = d(null), H = F !== n.Collapsed, U = r.length > 2, W = F === n.Collapsed && (U || !z && !h);
|
|
16
|
+
l(() => {
|
|
17
|
+
L && !r.some((e) => e.id === L) && I({ type: "CLEAR_EDIT" });
|
|
24
18
|
}, [
|
|
25
|
-
|
|
19
|
+
L,
|
|
26
20
|
r,
|
|
27
|
-
|
|
28
|
-
]),
|
|
29
|
-
|
|
30
|
-
}, [
|
|
31
|
-
if (!
|
|
21
|
+
I
|
|
22
|
+
]), l(() => {
|
|
23
|
+
A?.(H);
|
|
24
|
+
}, [H, A]), l(() => {
|
|
25
|
+
if (!H) return;
|
|
32
26
|
let t = `[${Object.keys(e)[0]}]`, n = (e) => {
|
|
33
27
|
let n = e.target;
|
|
34
|
-
|
|
28
|
+
V.current?.contains(n) || document.querySelector(t)?.contains(n) || I({ type: "COLLAPSE" });
|
|
35
29
|
};
|
|
36
30
|
return document.addEventListener("mousedown", n), () => document.removeEventListener("mousedown", n);
|
|
37
|
-
}, [
|
|
38
|
-
let
|
|
39
|
-
if (!
|
|
31
|
+
}, [H, I]);
|
|
32
|
+
let G = r.length === 0, K = c(() => I({ type: "CLEAR_MENTION" }), [I]), q = u(() => R ? o(R) : null, [R]), J = c((e) => {
|
|
33
|
+
if (!W) return;
|
|
40
34
|
let t = e.target;
|
|
41
|
-
!e.currentTarget.contains(t) || t.closest("[data-no-expand]") ||
|
|
42
|
-
}, [
|
|
43
|
-
return
|
|
35
|
+
!e.currentTarget.contains(t) || t.closest("[data-no-expand]") || I({ type: "EXPAND" });
|
|
36
|
+
}, [W, I]);
|
|
37
|
+
return B && G ? /* @__PURE__ */ f(t, {
|
|
44
38
|
isFirstAnnotation: !0,
|
|
45
|
-
maxCharacterCount:
|
|
46
|
-
onPost:
|
|
47
|
-
onPostError:
|
|
48
|
-
onPostSuccess:
|
|
49
|
-
userSelectorProps:
|
|
50
|
-
}) : /* @__PURE__ */
|
|
51
|
-
ref:
|
|
52
|
-
className:
|
|
53
|
-
"data-thread-expandable":
|
|
54
|
-
"data-thread-highlighted":
|
|
55
|
-
onClick:
|
|
56
|
-
children: [/* @__PURE__ */
|
|
39
|
+
maxCharacterCount: v,
|
|
40
|
+
onPost: D,
|
|
41
|
+
onPostError: O,
|
|
42
|
+
onPostSuccess: K,
|
|
43
|
+
userSelectorProps: k
|
|
44
|
+
}) : /* @__PURE__ */ p("div", {
|
|
45
|
+
ref: V,
|
|
46
|
+
className: s(m.threadedAnnotations, W && m.expandable, B && m.annotations, P && m.highlighted),
|
|
47
|
+
"data-thread-expandable": W ? !0 : void 0,
|
|
48
|
+
"data-thread-highlighted": P ? !0 : void 0,
|
|
49
|
+
onClick: W ? J : void 0,
|
|
50
|
+
children: [/* @__PURE__ */ f(a, {
|
|
57
51
|
messages: r,
|
|
58
|
-
isResolved:
|
|
59
|
-
resolvedBy:
|
|
60
|
-
resolvedAt:
|
|
61
|
-
maxCharacterCount:
|
|
62
|
-
onDelete:
|
|
63
|
-
onThreadDelete:
|
|
64
|
-
onAvatarClick:
|
|
65
|
-
onCopyLink:
|
|
66
|
-
onEdit:
|
|
67
|
-
onEditError:
|
|
68
|
-
onResolve:
|
|
69
|
-
onUnresolve:
|
|
70
|
-
userSelectorProps:
|
|
71
|
-
annotationTarget:
|
|
72
|
-
onAnnotationBadgeClick:
|
|
73
|
-
originalContentDeleted:
|
|
74
|
-
}),
|
|
75
|
-
initialContent:
|
|
76
|
-
maxCharacterCount:
|
|
77
|
-
onPost:
|
|
78
|
-
onPostError:
|
|
79
|
-
onPostSuccess:
|
|
52
|
+
isResolved: h,
|
|
53
|
+
resolvedBy: g,
|
|
54
|
+
resolvedAt: _,
|
|
55
|
+
maxCharacterCount: v,
|
|
56
|
+
onDelete: y,
|
|
57
|
+
onThreadDelete: b,
|
|
58
|
+
onAvatarClick: x,
|
|
59
|
+
onCopyLink: S,
|
|
60
|
+
onEdit: C,
|
|
61
|
+
onEditError: w,
|
|
62
|
+
onResolve: T,
|
|
63
|
+
onUnresolve: E,
|
|
64
|
+
userSelectorProps: k,
|
|
65
|
+
annotationTarget: j,
|
|
66
|
+
onAnnotationBadgeClick: M,
|
|
67
|
+
originalContentDeleted: N
|
|
68
|
+
}), F === n.Composing && /* @__PURE__ */ f(t, {
|
|
69
|
+
initialContent: q,
|
|
70
|
+
maxCharacterCount: v,
|
|
71
|
+
onPost: D,
|
|
72
|
+
onPostError: O,
|
|
73
|
+
onPostSuccess: K,
|
|
80
74
|
isReply: !0,
|
|
81
|
-
userSelectorProps:
|
|
75
|
+
userSelectorProps: k
|
|
82
76
|
})]
|
|
83
77
|
});
|
|
84
|
-
},
|
|
85
|
-
defaultExpanded: e.messages.length === 0,
|
|
78
|
+
}, g = (e) => /* @__PURE__ */ f(r, {
|
|
79
|
+
defaultExpanded: e.defaultExpanded || e.messages.length === 0,
|
|
86
80
|
isReplyDisabled: e.isReplyDisabled || e.isResolved,
|
|
87
81
|
isEditDisabled: e.isEditDisabled || e.isResolved,
|
|
88
82
|
isAnnotations: e.isAnnotations,
|
|
89
83
|
collapsed: e.collapsed,
|
|
90
|
-
children: /* @__PURE__ */
|
|
84
|
+
children: /* @__PURE__ */ f(h, { ...e })
|
|
91
85
|
});
|
|
92
|
-
export {
|
|
86
|
+
export { g as t };
|
|
@@ -3,15 +3,15 @@ import { jsx as o } from "react/jsx-runtime";
|
|
|
3
3
|
var s = /* @__PURE__ */ function(e) {
|
|
4
4
|
return e.Collapsed = "collapsed", e.RepliesOnly = "repliesOnly", e.Composing = "composing", e;
|
|
5
5
|
}({}), c = /*#__PURE__*/ e(void 0), l = ({ children: e, defaultExpanded: n = !1, isReplyDisabled: s = !1, isEditDisabled: l = !1, collapsed: u = !1, isAnnotations: d = !1 }) => {
|
|
6
|
-
let [f, p] = a(() => n ? s ? "repliesOnly" : "composing" : "collapsed"), [m, h] = a(null), [g, _] = a(null)
|
|
6
|
+
let [f, p] = a(() => n ? s ? "repliesOnly" : "composing" : "collapsed"), [m, h] = a(null), [g, _] = a(null);
|
|
7
7
|
r(() => {
|
|
8
8
|
s ? (p((e) => e === "composing" ? "collapsed" : e), h(null)) : p((e) => e === "repliesOnly" ? "composing" : e);
|
|
9
9
|
}, [s]), r(() => {
|
|
10
10
|
l && _(null);
|
|
11
11
|
}, [l]), r(() => {
|
|
12
|
-
u && (p("collapsed"), h(null), _(null)
|
|
12
|
+
u && (p("collapsed"), h(null), _(null));
|
|
13
13
|
}, [u]);
|
|
14
|
-
let
|
|
14
|
+
let v = t((e) => {
|
|
15
15
|
switch (e.type) {
|
|
16
16
|
case "EXPAND":
|
|
17
17
|
p((e) => e === "collapsed" ? s ? "repliesOnly" : "composing" : e);
|
|
@@ -26,39 +26,31 @@ var s = /* @__PURE__ */ function(e) {
|
|
|
26
26
|
_(null);
|
|
27
27
|
break;
|
|
28
28
|
case "COLLAPSE":
|
|
29
|
-
p("collapsed"), h(null), _(null)
|
|
29
|
+
p("collapsed"), h(null), _(null);
|
|
30
30
|
break;
|
|
31
31
|
case "CLEAR_MENTION":
|
|
32
32
|
h(null);
|
|
33
33
|
break;
|
|
34
|
-
case "SET_SCROLL_TARGET":
|
|
35
|
-
y(e.id), p((e) => e === "collapsed" ? s ? "repliesOnly" : "composing" : e);
|
|
36
|
-
break;
|
|
37
|
-
case "CLEAR_SCROLL_TARGET":
|
|
38
|
-
y(null);
|
|
39
|
-
break;
|
|
40
34
|
}
|
|
41
|
-
}, [s, l]),
|
|
35
|
+
}, [s, l]), y = i(() => ({
|
|
42
36
|
viewState: f,
|
|
43
37
|
replyMention: m,
|
|
44
38
|
editingMessageId: g,
|
|
45
|
-
scrollTargetMessageId: v,
|
|
46
39
|
isAnnotations: d,
|
|
47
40
|
isReplyDisabled: s,
|
|
48
41
|
isEditDisabled: l,
|
|
49
|
-
dispatch:
|
|
42
|
+
dispatch: v
|
|
50
43
|
}), [
|
|
51
44
|
f,
|
|
52
45
|
m,
|
|
53
46
|
g,
|
|
54
|
-
v,
|
|
55
47
|
d,
|
|
56
48
|
s,
|
|
57
49
|
l,
|
|
58
|
-
|
|
50
|
+
v
|
|
59
51
|
]);
|
|
60
52
|
return /* @__PURE__ */ o(c.Provider, {
|
|
61
|
-
value:
|
|
53
|
+
value: y,
|
|
62
54
|
children: e
|
|
63
55
|
});
|
|
64
56
|
}, u = () => {
|
|
@@ -7,13 +7,12 @@ export declare const defaultUserSelectorProps: Omit<import('@box/user-selector')
|
|
|
7
7
|
export declare const DefaultThreadedAnnotations: (props: ThreadedAnnotationsProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
interface InteractiveModuleBaseProps {
|
|
9
9
|
initialMessages?: TextMessageType[];
|
|
10
|
+
defaultExpanded?: boolean;
|
|
10
11
|
isEditDisabled?: boolean;
|
|
11
12
|
isHighlighted?: boolean;
|
|
12
13
|
isReplyDisabled?: boolean;
|
|
13
14
|
maxCharacterCount?: number;
|
|
14
15
|
onCopyLink?: (id: string) => void;
|
|
15
|
-
scrollToMessageId?: string;
|
|
16
|
-
onScrollToMessageComplete?: (messageId: string, found: boolean) => void;
|
|
17
16
|
}
|
|
18
17
|
type InteractiveModuleProps = (InteractiveModuleBaseProps & {
|
|
19
18
|
isAnnotations: true;
|
|
@@ -30,13 +30,6 @@ export type ThreadEvent = {
|
|
|
30
30
|
type: 'COLLAPSE';
|
|
31
31
|
} | {
|
|
32
32
|
type: 'CLEAR_MENTION';
|
|
33
|
-
}
|
|
34
|
-
/** Mark a message as the pending scroll target and expand the thread so hidden replies mount. */
|
|
35
|
-
| {
|
|
36
|
-
type: 'SET_SCROLL_TARGET';
|
|
37
|
-
id: string;
|
|
38
|
-
} | {
|
|
39
|
-
type: 'CLEAR_SCROLL_TARGET';
|
|
40
33
|
};
|
|
41
34
|
export interface ThreadedAnnotationsContextValue {
|
|
42
35
|
viewState: ThreadViewState;
|
|
@@ -46,11 +39,6 @@ export interface ThreadedAnnotationsContextValue {
|
|
|
46
39
|
* `isEditDisabled` or `collapsed` flip true, or when the id disappears from the messages list.
|
|
47
40
|
*/
|
|
48
41
|
editingMessageId: string | null;
|
|
49
|
-
/**
|
|
50
|
-
* Id of the message to scroll into view, or null. Set via SET_SCROLL_TARGET (which also expands
|
|
51
|
-
* the thread). Cleared once the scroll runs, or on COLLAPSE / when `collapsed` flips true.
|
|
52
|
-
*/
|
|
53
|
-
scrollTargetMessageId: string | null;
|
|
54
42
|
/** Whether the component is rendered in annotation mode (scrollable, fixed-height) vs comments mode. */
|
|
55
43
|
isAnnotations: boolean;
|
|
56
44
|
/** When true, globally disables replies (hides reply buttons and blocks editor opening on click). */
|
|
@@ -44,13 +44,11 @@ interface ThreadedAnnotationsBaseProps {
|
|
|
44
44
|
/** When true, collapses the editor and replies panel. */
|
|
45
45
|
collapsed?: boolean;
|
|
46
46
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
47
|
+
* When true, the thread mounts expanded (all replies visible, editor open unless replies are
|
|
48
|
+
* disabled) instead of collapsed. Initial state only — changing it after mount has no effect,
|
|
49
|
+
* and `collapsed` always wins. Threads with no messages always mount expanded.
|
|
50
50
|
*/
|
|
51
|
-
|
|
52
|
-
/** Called after a scroll attempt. `found` is false when `scrollToMessageId` was not in the DOM. */
|
|
53
|
-
onScrollToMessageComplete?: (messageId: string, found: boolean) => void;
|
|
51
|
+
defaultExpanded?: boolean;
|
|
54
52
|
/** When true, applies a visual highlight (border + background tint) to the thread card. Not a focus state. */
|
|
55
53
|
isHighlighted?: boolean;
|
|
56
54
|
}
|
package/package.json
CHANGED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { useThreadedAnnotationsContext as e } from "../threaded-annotations-context.js";
|
|
2
|
-
import { useEffect as t, useLayoutEffect as n } from "react";
|
|
3
|
-
var r = ({ containerRef: r, messages: i, scrollToMessageId: a, onScrollToMessageComplete: o }) => {
|
|
4
|
-
let { scrollTargetMessageId: s, dispatch: c, isAnnotations: l } = e();
|
|
5
|
-
t(() => {
|
|
6
|
-
if (!(l || !a)) {
|
|
7
|
-
if (!i.some((e) => e.id === a)) {
|
|
8
|
-
o?.(a, !1);
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
c({
|
|
12
|
-
type: "SET_SCROLL_TARGET",
|
|
13
|
-
id: a
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
}, [
|
|
17
|
-
l,
|
|
18
|
-
a,
|
|
19
|
-
i,
|
|
20
|
-
c,
|
|
21
|
-
o
|
|
22
|
-
]), n(() => {
|
|
23
|
-
if (l || !s) return;
|
|
24
|
-
let e = r.current?.querySelector(`[data-message-id="${CSS.escape(s)}"]`);
|
|
25
|
-
e?.scrollIntoView({
|
|
26
|
-
behavior: "smooth",
|
|
27
|
-
block: "nearest"
|
|
28
|
-
}), o?.(s, !!e), c({ type: "CLEAR_SCROLL_TARGET" });
|
|
29
|
-
}, [
|
|
30
|
-
l,
|
|
31
|
-
s,
|
|
32
|
-
c,
|
|
33
|
-
o,
|
|
34
|
-
r
|
|
35
|
-
]);
|
|
36
|
-
};
|
|
37
|
-
export { r as useScrollToMessage };
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { RefObject } from 'react';
|
|
2
|
-
import { TextMessageType } from '../types/message-types';
|
|
3
|
-
interface UseScrollToMessageProps {
|
|
4
|
-
/** Scroll container that holds the message elements (`[data-message-id]`). */
|
|
5
|
-
containerRef: RefObject<HTMLElement | null>;
|
|
6
|
-
/** Messages in the thread; used to ignore unknown `scrollToMessageId` values. */
|
|
7
|
-
messages: TextMessageType[];
|
|
8
|
-
/**
|
|
9
|
-
* Id of the message to scroll into view. Setting it expands the thread (so hidden replies
|
|
10
|
-
* mount) and then scrolls the matching element into view. Ignored when not in `messages`.
|
|
11
|
-
* Only active in comments mode (no internal messages scroll); ignored in annotations mode.
|
|
12
|
-
*/
|
|
13
|
-
scrollToMessageId?: string;
|
|
14
|
-
/** Called after a scroll attempt. `found` is false when the id was not in the DOM. */
|
|
15
|
-
onScrollToMessageComplete?: (messageId: string, found: boolean) => void;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Wires the declarative `scrollToMessageId` prop to the thread's scroll behavior in comments
|
|
19
|
-
* mode: registers the target (which expands the thread), then scrolls the matching element
|
|
20
|
-
* into view via the nearest outer scroll container. No-op in annotations mode where the
|
|
21
|
-
* messages list has its own internal scroll.
|
|
22
|
-
*/
|
|
23
|
-
export declare const useScrollToMessage: ({ containerRef, messages, scrollToMessageId, onScrollToMessageComplete, }: UseScrollToMessageProps) => void;
|
|
24
|
-
export {};
|