@progress/kendo-react-conversational-ui 14.4.0-develop.4 → 14.4.0-develop.5
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/NOTICE.txt +366 -82
- package/chat/ChatPropsAndState.d.ts +4 -4
- package/chat/Events.d.ts +2 -2
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +3 -3
- package/chat/hooks/useEndlessScroll.d.ts +4 -4
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +108 -108
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
package/chat/components/Chat.mjs
CHANGED
|
@@ -102,7 +102,7 @@ const Je = t.forwardRef((Qe, b) => {
|
|
|
102
102
|
pageSize: dt,
|
|
103
103
|
startIndex: gt,
|
|
104
104
|
endIndex: ft,
|
|
105
|
-
|
|
105
|
+
onLoadMoreMessages: pt,
|
|
106
106
|
pinnedMessages: D,
|
|
107
107
|
repliedToMessages: Be,
|
|
108
108
|
onReferencedMessageClick: ht,
|
|
@@ -177,7 +177,7 @@ const Je = t.forwardRef((Qe, b) => {
|
|
|
177
177
|
pageSize: dt,
|
|
178
178
|
startIndex: gt,
|
|
179
179
|
endIndex: ft,
|
|
180
|
-
|
|
180
|
+
onLoadMoreMessages: pt,
|
|
181
181
|
onReferencedMessageClick: ht,
|
|
182
182
|
viewItemsWrapperRef: i,
|
|
183
183
|
authorId: a
|
|
@@ -564,7 +564,7 @@ Je.propTypes = {
|
|
|
564
564
|
pageSize: o.number,
|
|
565
565
|
startIndex: o.number,
|
|
566
566
|
endIndex: o.number,
|
|
567
|
-
|
|
567
|
+
onLoadMoreMessages: o.func,
|
|
568
568
|
pinnedMessages: o.arrayOf(o.object),
|
|
569
569
|
repliedToMessages: o.arrayOf(o.object),
|
|
570
570
|
onReferencedMessageClick: o.func
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { Message } from '../../api/message.interface.js';
|
|
9
|
-
import {
|
|
9
|
+
import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from '../Events.js';
|
|
10
10
|
import { ScrollMode } from '../ChatPropsAndState.js';
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
/** @hidden */
|
|
@@ -17,7 +17,7 @@ export interface UseEndlessScrollProps {
|
|
|
17
17
|
pageSize?: number;
|
|
18
18
|
startIndex?: number;
|
|
19
19
|
endIndex?: number;
|
|
20
|
-
|
|
20
|
+
onLoadMoreMessages?: (event: ChatLoadMoreMessagesEvent) => void;
|
|
21
21
|
onReferencedMessageClick?: (event: ChatReferencedMessageClickEvent) => void;
|
|
22
22
|
viewItemsWrapperRef: React.RefObject<HTMLDivElement | null>;
|
|
23
23
|
authorId?: string | number;
|
|
@@ -42,8 +42,8 @@ export interface UseEndlessScrollReturn {
|
|
|
42
42
|
* Hook that manages the endless scroll behavior for the Chat component.
|
|
43
43
|
*
|
|
44
44
|
* Built-in mode: messages.length === total — Chat manages rendering internally.
|
|
45
|
-
* Remote mode: messages.length < total — Chat fires
|
|
45
|
+
* Remote mode: messages.length < total — Chat fires onLoadMoreMessages, consumer manages data.
|
|
46
46
|
*
|
|
47
47
|
* @hidden
|
|
48
48
|
*/
|
|
49
|
-
export declare const useEndlessScroll: ({ scrollMode, processedMessages, total, pageSize, startIndex: startIndexProp, endIndex: endIndexProp,
|
|
49
|
+
export declare const useEndlessScroll: ({ scrollMode, processedMessages, total, pageSize, startIndex: startIndexProp, endIndex: endIndexProp, onLoadMoreMessages, onReferencedMessageClick, viewItemsWrapperRef, authorId }: UseEndlessScrollProps) => UseEndlessScrollReturn;
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const tt=require("react"),nt=require("../utils.js");function rt(
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const tt=require("react"),nt=require("../utils.js");function rt(y){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const q in y)if(q!=="default"){const l=Object.getOwnPropertyDescriptor(y,q);Object.defineProperty(n,q,l.get?l:{enumerable:!0,get:()=>y[q]})}}return n.default=y,Object.freeze(n)}const r=rt(tt),ct=50,I=100,ut=({scrollMode:y,processedMessages:n,total:q,pageSize:l=ct,startIndex:G,endIndex:U,onLoadMoreMessages:T,onReferencedMessageClick:_,viewItemsWrapperRef:u,authorId:V})=>{const F=r.useRef(!1),S=y==="endless",e=q!=null?q:n.length,a=S&&n.length===e&&!F.current,f=S&&(n.length<e||F.current);f&&(F.current=!0);const[D,B]=r.useState(-1),[E,O]=r.useState(-1),X=r.useRef(D),C=r.useRef(E);X.current=D,C.current=E;const o=r.useRef(!1),Y=r.useRef(0),v=r.useRef(0),b=r.useRef(!1),L=r.useRef(e),j=r.useRef(V);j.current=V;const k=r.useRef(!1),s=r.useRef(null),$=r.useRef(!1),g=r.useRef(!1),J=r.useRef(!0),N=r.useRef(e);r.useEffect(()=>{if(a){if(F.current){(D===-1||E===-1)&&(B(0),O(n.length));return}if(D===-1||E===-1){const t=Math.max(0,n.length-l),c=n.length;B(t),O(c)}else if(E<n.length){const t=L.current;if(C.current>=t)O(n.length);else if(n.length>t&&n.slice(t).some(i=>{var x;return((x=i.author)==null?void 0:x.id)!==void 0&&String(i.author.id)===String(j.current)})){const i=Math.max(0,n.length-l);B(i),O(n.length),$.current=!0}}L.current=e}},[a,n.length,l,D,E,e]);const d=G!=null?G:0,H=U!=null?U:n.length,P=r.useCallback(()=>{const t=u.current;t&&(Y.current=t.scrollHeight,v.current=t.scrollTop)},[u]),A=r.useCallback(t=>{var h,i,x;const c=(h=u.current)==null?void 0:h.closest(".k-chat"),m=((x=(i=u.current)==null?void 0:i.querySelector(".k-message-pinned"))==null?void 0:x.offsetHeight)||0;nt.scrollToMessageById(t,c,m)},[u]);r.useLayoutEffect(()=>{if(!b.current)return;const t=u.current;if(!t){b.current=!1;return}const c=t.scrollHeight-Y.current;c>0&&(t.scrollTop=v.current+c),b.current=!1,o.current=!1}),r.useLayoutEffect(()=>{if(!$.current)return;const t=u.current;if(!t){$.current=!1;return}E>=n.length&&E>0&&($.current=!1,t.scrollTop=t.scrollHeight-t.clientHeight)});const w=r.useRef(!1);r.useLayoutEffect(()=>{if(!S||w.current)return;const t=u.current;t&&t.querySelector("[data-message-id]")&&(t.scrollTop=t.scrollHeight-t.clientHeight,w.current=!0)}),r.useEffect(()=>{if(!S)return;const t=u.current;if(!t)return;let c=t.scrollTop;const m=()=>{const{scrollTop:h,scrollHeight:i,clientHeight:x}=t,K=h<c,p=h>c;if(c=h,!o.current){if(K&&h<=I){if(a){const R=X.current;if(R>0){const Q=Math.max(0,R-l);b.current=!0,P(),B(Q)}}else if(f&&d>0){o.current=!0;const R=Math.max(0,d-l);b.current=!0,P(),T==null||T({startIndex:R,endIndex:d})}}if(p&&i-h-x<=I){if(a){const R=C.current;if(R<n.length){const Q=Math.min(n.length,R+l);g.current=!0,O(Q)}}else if(f&&H<e){o.current=!0,g.current=!0;const R=Math.min(e,H+l);T==null||T({startIndex:H,endIndex:R})}}}};return t.addEventListener("scroll",m,{passive:!0}),()=>t.removeEventListener("scroll",m)},[S,a,f,u,l,n.length,d,H,e,T]),r.useEffect(()=>{var h;const t=H>=e;if(!f){N.current=e,J.current=t;return}const c=N.current,m=J.current;if(N.current=e,J.current=t,e>c&&!m&&t){const i=n[n.length-1];j.current!==void 0&&((h=i==null?void 0:i.author)==null?void 0:h.id)!==void 0&&String(i.author.id)===String(j.current)&&(k.current=!0,g.current=!0)}},[f,e,H,n]),r.useEffect(()=>{!f||!k.current||(k.current=!1,o.current=!1,requestAnimationFrame(()=>{const t=u.current;t&&(t.scrollTop=t.scrollHeight-t.clientHeight)}))},[f,n,u]),r.useEffect(()=>{if(!f||s.current===null)return;const t=s.current,c=u.current;if(!c)return;c.querySelector(`[data-message-id="${t}"]`)&&(s.current=null,o.current=!1,requestAnimationFrame(()=>{A(t)}))},[f,n,u,A]),r.useEffect(()=>{f&&o.current&&!b.current&&(o.current=!1)},[f,d,H]);const z=r.useMemo(()=>{if(a){const t=Math.max(0,D),c=Math.min(n.length,E);if(t>=c){const m=Math.max(0,n.length-l);return n.slice(m)}return n.slice(t,c)}return n},[a,n,D,E,l]),Z=r.useMemo(()=>S?a?E>=n.length:H>=e:!0,[S,a,E,n.length,H,e]),W=r.useCallback(()=>{if(!S||Z){const t=u.current;t&&t.scrollTo({top:t.scrollHeight-t.clientHeight,behavior:"smooth"});return}if(!o.current){if(a){const t=Math.max(0,n.length-l);B(t),O(n.length),requestAnimationFrame(()=>{const c=u.current;c&&(c.scrollTop=c.scrollHeight-c.clientHeight)})}else if(f){k.current=!0,b.current=!1,o.current=!0;const t=Math.max(0,e-l);T==null||T({startIndex:t,endIndex:e})}}},[S,a,f,Z,n.length,l,e,T,u]),M=r.useCallback(t=>{if(!S)A(t);else if(a){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;const h=n.findIndex(i=>i.id===t||String(i.id)===String(t));if(h>=0){const i=Math.floor(l/2),x=Math.max(0,h-i),K=Math.min(n.length,x+l);o.current=!0,B(x),O(K),requestAnimationFrame(()=>{requestAnimationFrame(()=>{A(t),o.current=!1})})}}}else if(f){const c=u.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;s.current=t,b.current=!1,o.current=!0}}_==null||_({id:t})},[S,a,f,u,n,l,_,A]);return{renderedMessages:z,handleScrollToBottom:W,handleReferencedMessageClick:M,isEndless:S,isOnLastBatch:Z,skipAutoScrollRef:g}};exports.useEndlessScroll=ut;
|
|
@@ -7,179 +7,179 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
9
|
import { scrollToMessageById as tt } from "../utils.mjs";
|
|
10
|
-
const nt = 50,
|
|
10
|
+
const nt = 50, s = 100, ct = ({
|
|
11
11
|
scrollMode: I,
|
|
12
12
|
processedMessages: n,
|
|
13
|
-
total:
|
|
13
|
+
total: C,
|
|
14
14
|
pageSize: i = nt,
|
|
15
|
-
startIndex:
|
|
16
|
-
endIndex:
|
|
17
|
-
|
|
18
|
-
onReferencedMessageClick:
|
|
15
|
+
startIndex: J,
|
|
16
|
+
endIndex: Z,
|
|
17
|
+
onLoadMoreMessages: T,
|
|
18
|
+
onReferencedMessageClick: b,
|
|
19
19
|
viewItemsWrapperRef: u,
|
|
20
|
-
authorId:
|
|
20
|
+
authorId: Y
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
f && (
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
const o = r.useRef(!1),
|
|
27
|
-
|
|
28
|
-
const
|
|
22
|
+
const F = r.useRef(!1), E = I === "endless", l = C != null ? C : n.length, a = E && n.length === l && !F.current, f = E && (n.length < l || F.current);
|
|
23
|
+
f && (F.current = !0);
|
|
24
|
+
const [D, B] = r.useState(-1), [S, A] = r.useState(-1), d = r.useRef(D), j = r.useRef(S);
|
|
25
|
+
d.current = D, j.current = S;
|
|
26
|
+
const o = r.useRef(!1), L = r.useRef(0), v = r.useRef(0), q = r.useRef(!1), g = r.useRef(l), k = r.useRef(Y);
|
|
27
|
+
k.current = Y;
|
|
28
|
+
const _ = r.useRef(!1), $ = r.useRef(null), G = r.useRef(!1), U = r.useRef(!1), K = r.useRef(!0), N = r.useRef(l);
|
|
29
29
|
r.useEffect(() => {
|
|
30
30
|
if (a) {
|
|
31
|
-
if (
|
|
32
|
-
(
|
|
31
|
+
if (F.current) {
|
|
32
|
+
(D === -1 || S === -1) && (B(0), A(n.length));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
35
|
+
if (D === -1 || S === -1) {
|
|
36
36
|
const t = Math.max(0, n.length - i), c = n.length;
|
|
37
|
-
|
|
38
|
-
} else if (
|
|
39
|
-
const t =
|
|
40
|
-
if (
|
|
41
|
-
|
|
37
|
+
B(t), A(c);
|
|
38
|
+
} else if (S < n.length) {
|
|
39
|
+
const t = g.current;
|
|
40
|
+
if (j.current >= t)
|
|
41
|
+
A(n.length);
|
|
42
42
|
else if (n.length > t && n.slice(t).some(
|
|
43
43
|
(e) => {
|
|
44
|
-
var
|
|
45
|
-
return ((
|
|
44
|
+
var x;
|
|
45
|
+
return ((x = e.author) == null ? void 0 : x.id) !== void 0 && String(e.author.id) === String(k.current);
|
|
46
46
|
}
|
|
47
47
|
)) {
|
|
48
48
|
const e = Math.max(0, n.length - i);
|
|
49
|
-
|
|
49
|
+
B(e), A(n.length), G.current = !0;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
g.current = l;
|
|
53
53
|
}
|
|
54
|
-
}, [a, n.length, i,
|
|
55
|
-
const
|
|
54
|
+
}, [a, n.length, i, D, S, l]);
|
|
55
|
+
const O = J != null ? J : 0, H = Z != null ? Z : n.length, P = r.useCallback(() => {
|
|
56
56
|
const t = u.current;
|
|
57
|
-
t && (
|
|
58
|
-
}, [u]),
|
|
57
|
+
t && (L.current = t.scrollHeight, v.current = t.scrollTop);
|
|
58
|
+
}, [u]), y = r.useCallback(
|
|
59
59
|
(t) => {
|
|
60
|
-
var h, e,
|
|
61
|
-
const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"),
|
|
62
|
-
tt(t, c,
|
|
60
|
+
var h, e, x;
|
|
61
|
+
const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"), m = ((x = (e = u.current) == null ? void 0 : e.querySelector(".k-message-pinned")) == null ? void 0 : x.offsetHeight) || 0;
|
|
62
|
+
tt(t, c, m);
|
|
63
63
|
},
|
|
64
64
|
[u]
|
|
65
65
|
);
|
|
66
66
|
r.useLayoutEffect(() => {
|
|
67
|
-
if (!
|
|
67
|
+
if (!q.current)
|
|
68
68
|
return;
|
|
69
69
|
const t = u.current;
|
|
70
70
|
if (!t) {
|
|
71
|
-
|
|
71
|
+
q.current = !1;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const c = t.scrollHeight -
|
|
75
|
-
c > 0 && (t.scrollTop =
|
|
74
|
+
const c = t.scrollHeight - L.current;
|
|
75
|
+
c > 0 && (t.scrollTop = v.current + c), q.current = !1, o.current = !1;
|
|
76
76
|
}), r.useLayoutEffect(() => {
|
|
77
|
-
if (!
|
|
77
|
+
if (!G.current)
|
|
78
78
|
return;
|
|
79
79
|
const t = u.current;
|
|
80
80
|
if (!t) {
|
|
81
|
-
|
|
81
|
+
G.current = !1;
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
S >= n.length && S > 0 && (G.current = !1, t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
85
85
|
});
|
|
86
|
-
const
|
|
86
|
+
const w = r.useRef(!1);
|
|
87
87
|
r.useLayoutEffect(() => {
|
|
88
|
-
if (!
|
|
88
|
+
if (!E || w.current)
|
|
89
89
|
return;
|
|
90
90
|
const t = u.current;
|
|
91
|
-
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight,
|
|
91
|
+
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight, w.current = !0);
|
|
92
92
|
}), r.useEffect(() => {
|
|
93
|
-
if (!
|
|
93
|
+
if (!E)
|
|
94
94
|
return;
|
|
95
95
|
const t = u.current;
|
|
96
96
|
if (!t)
|
|
97
97
|
return;
|
|
98
98
|
let c = t.scrollTop;
|
|
99
|
-
const
|
|
100
|
-
const { scrollTop: h, scrollHeight: e, clientHeight:
|
|
99
|
+
const m = () => {
|
|
100
|
+
const { scrollTop: h, scrollHeight: e, clientHeight: x } = t, V = h < c, p = h > c;
|
|
101
101
|
if (c = h, !o.current) {
|
|
102
|
-
if (
|
|
102
|
+
if (V && h <= s) {
|
|
103
103
|
if (a) {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
104
|
+
const R = d.current;
|
|
105
|
+
if (R > 0) {
|
|
106
|
+
const X = Math.max(0, R - i);
|
|
107
|
+
q.current = !0, P(), B(X);
|
|
108
108
|
}
|
|
109
|
-
} else if (f &&
|
|
109
|
+
} else if (f && O > 0) {
|
|
110
110
|
o.current = !0;
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const R = Math.max(0, O - i);
|
|
112
|
+
q.current = !0, P(), T == null || T({ startIndex: R, endIndex: O });
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
if (p && e - h -
|
|
115
|
+
if (p && e - h - x <= s) {
|
|
116
116
|
if (a) {
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
const R = j.current;
|
|
118
|
+
if (R < n.length) {
|
|
119
|
+
const X = Math.min(n.length, R + i);
|
|
120
|
+
U.current = !0, A(X);
|
|
121
121
|
}
|
|
122
|
-
} else if (f &&
|
|
123
|
-
o.current = !0,
|
|
124
|
-
const
|
|
125
|
-
|
|
122
|
+
} else if (f && H < l) {
|
|
123
|
+
o.current = !0, U.current = !0;
|
|
124
|
+
const R = Math.min(l, H + i);
|
|
125
|
+
T == null || T({ startIndex: H, endIndex: R });
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
return t.addEventListener("scroll",
|
|
130
|
+
return t.addEventListener("scroll", m, { passive: !0 }), () => t.removeEventListener("scroll", m);
|
|
131
131
|
}, [
|
|
132
|
-
|
|
132
|
+
E,
|
|
133
133
|
a,
|
|
134
134
|
f,
|
|
135
135
|
u,
|
|
136
136
|
i,
|
|
137
137
|
n.length,
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
O,
|
|
139
|
+
H,
|
|
140
140
|
l,
|
|
141
|
-
|
|
141
|
+
T
|
|
142
142
|
]), r.useEffect(() => {
|
|
143
143
|
var h;
|
|
144
|
-
const t =
|
|
144
|
+
const t = H >= l;
|
|
145
145
|
if (!f) {
|
|
146
|
-
|
|
146
|
+
N.current = l, K.current = t;
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
const c =
|
|
150
|
-
if (
|
|
149
|
+
const c = N.current, m = K.current;
|
|
150
|
+
if (N.current = l, K.current = t, l > c && !m && t) {
|
|
151
151
|
const e = n[n.length - 1];
|
|
152
|
-
|
|
152
|
+
k.current !== void 0 && ((h = e == null ? void 0 : e.author) == null ? void 0 : h.id) !== void 0 && String(e.author.id) === String(k.current) && (_.current = !0, U.current = !0);
|
|
153
153
|
}
|
|
154
|
-
}, [f, l,
|
|
155
|
-
!f || !
|
|
154
|
+
}, [f, l, H, n]), r.useEffect(() => {
|
|
155
|
+
!f || !_.current || (_.current = !1, o.current = !1, requestAnimationFrame(() => {
|
|
156
156
|
const t = u.current;
|
|
157
157
|
t && (t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
158
158
|
}));
|
|
159
159
|
}, [f, n, u]), r.useEffect(() => {
|
|
160
|
-
if (!f ||
|
|
160
|
+
if (!f || $.current === null)
|
|
161
161
|
return;
|
|
162
|
-
const t =
|
|
162
|
+
const t = $.current, c = u.current;
|
|
163
163
|
if (!c)
|
|
164
164
|
return;
|
|
165
|
-
c.querySelector(`[data-message-id="${t}"]`) && (
|
|
166
|
-
|
|
165
|
+
c.querySelector(`[data-message-id="${t}"]`) && ($.current = null, o.current = !1, requestAnimationFrame(() => {
|
|
166
|
+
y(t);
|
|
167
167
|
}));
|
|
168
|
-
}, [f, n, u,
|
|
169
|
-
f && o.current && !
|
|
170
|
-
}, [f,
|
|
168
|
+
}, [f, n, u, y]), r.useEffect(() => {
|
|
169
|
+
f && o.current && !q.current && (o.current = !1);
|
|
170
|
+
}, [f, O, H]);
|
|
171
171
|
const z = r.useMemo(() => {
|
|
172
172
|
if (a) {
|
|
173
|
-
const t = Math.max(0,
|
|
173
|
+
const t = Math.max(0, D), c = Math.min(n.length, S);
|
|
174
174
|
if (t >= c) {
|
|
175
|
-
const
|
|
176
|
-
return n.slice(
|
|
175
|
+
const m = Math.max(0, n.length - i);
|
|
176
|
+
return n.slice(m);
|
|
177
177
|
}
|
|
178
178
|
return n.slice(t, c);
|
|
179
179
|
}
|
|
180
180
|
return n;
|
|
181
|
-
}, [a, n,
|
|
182
|
-
if (!
|
|
181
|
+
}, [a, n, D, S, i]), Q = r.useMemo(() => E ? a ? S >= n.length : H >= l : !0, [E, a, S, n.length, H, l]), W = r.useCallback(() => {
|
|
182
|
+
if (!E || Q) {
|
|
183
183
|
const t = u.current;
|
|
184
184
|
t && t.scrollTo({ top: t.scrollHeight - t.clientHeight, behavior: "smooth" });
|
|
185
185
|
return;
|
|
@@ -187,34 +187,34 @@ const nt = 50, w = 100, ct = ({
|
|
|
187
187
|
if (!o.current) {
|
|
188
188
|
if (a) {
|
|
189
189
|
const t = Math.max(0, n.length - i);
|
|
190
|
-
|
|
190
|
+
B(t), A(n.length), requestAnimationFrame(() => {
|
|
191
191
|
const c = u.current;
|
|
192
192
|
c && (c.scrollTop = c.scrollHeight - c.clientHeight);
|
|
193
193
|
});
|
|
194
194
|
} else if (f) {
|
|
195
|
-
|
|
195
|
+
_.current = !0, q.current = !1, o.current = !0;
|
|
196
196
|
const t = Math.max(0, l - i);
|
|
197
|
-
|
|
197
|
+
T == null || T({ startIndex: t, endIndex: l });
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}, [
|
|
201
|
-
|
|
201
|
+
E,
|
|
202
202
|
a,
|
|
203
203
|
f,
|
|
204
|
-
|
|
204
|
+
Q,
|
|
205
205
|
n.length,
|
|
206
206
|
i,
|
|
207
207
|
l,
|
|
208
|
-
|
|
208
|
+
T,
|
|
209
209
|
u
|
|
210
210
|
]), M = r.useCallback(
|
|
211
211
|
(t) => {
|
|
212
|
-
if (!
|
|
213
|
-
|
|
212
|
+
if (!E)
|
|
213
|
+
y(t);
|
|
214
214
|
else if (a) {
|
|
215
215
|
const c = u.current;
|
|
216
216
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
217
|
-
|
|
217
|
+
y(t);
|
|
218
218
|
else {
|
|
219
219
|
if (o.current)
|
|
220
220
|
return;
|
|
@@ -222,10 +222,10 @@ const nt = 50, w = 100, ct = ({
|
|
|
222
222
|
(e) => e.id === t || String(e.id) === String(t)
|
|
223
223
|
);
|
|
224
224
|
if (h >= 0) {
|
|
225
|
-
const e = Math.floor(i / 2),
|
|
226
|
-
o.current = !0,
|
|
225
|
+
const e = Math.floor(i / 2), x = Math.max(0, h - e), V = Math.min(n.length, x + i);
|
|
226
|
+
o.current = !0, B(x), A(V), requestAnimationFrame(() => {
|
|
227
227
|
requestAnimationFrame(() => {
|
|
228
|
-
|
|
228
|
+
y(t), o.current = !1;
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
}
|
|
@@ -233,33 +233,33 @@ const nt = 50, w = 100, ct = ({
|
|
|
233
233
|
} else if (f) {
|
|
234
234
|
const c = u.current;
|
|
235
235
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
236
|
-
|
|
236
|
+
y(t);
|
|
237
237
|
else {
|
|
238
238
|
if (o.current)
|
|
239
239
|
return;
|
|
240
|
-
|
|
240
|
+
$.current = t, q.current = !1, o.current = !0;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
b == null || b({ id: t });
|
|
244
244
|
},
|
|
245
245
|
[
|
|
246
|
-
|
|
246
|
+
E,
|
|
247
247
|
a,
|
|
248
248
|
f,
|
|
249
249
|
u,
|
|
250
250
|
n,
|
|
251
251
|
i,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
b,
|
|
253
|
+
y
|
|
254
254
|
]
|
|
255
255
|
);
|
|
256
256
|
return {
|
|
257
257
|
renderedMessages: z,
|
|
258
258
|
handleScrollToBottom: W,
|
|
259
259
|
handleReferencedMessageClick: M,
|
|
260
|
-
isEndless:
|
|
261
|
-
isOnLastBatch:
|
|
262
|
-
skipAutoScrollRef:
|
|
260
|
+
isEndless: E,
|
|
261
|
+
isOnLastBatch: Q,
|
|
262
|
+
skipAutoScrollRef: U
|
|
263
263
|
};
|
|
264
264
|
};
|
|
265
265
|
export {
|