@progress/kendo-react-conversational-ui 14.4.1 → 14.5.0-develop.10
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/ai-prompt/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +5 -5
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +6 -6
- package/chat/ChatPropsAndState.d.ts +5 -3
- package/chat/Events.d.ts +3 -3
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +17 -17
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +56 -55
- package/chat/components/Header.js +1 -1
- package/chat/components/Header.mjs +1 -1
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +49 -48
- package/chat/components/Notification.js +1 -1
- package/chat/components/Notification.mjs +1 -1
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +10 -9
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +14 -13
- package/chat/hooks/useEndlessScroll.d.ts +1 -1
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +160 -160
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.js +1 -1
- package/inline-ai-prompt/InlineAIPrompt.mjs +10 -10
- package/inline-ai-prompt/InlineAIPromptInput.js +1 -1
- package/inline-ai-prompt/InlineAIPromptInput.mjs +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +17 -12
- package/prompt-box/FileBox.js +1 -1
- package/prompt-box/FileBox.mjs +21 -20
- package/prompt-box/PromptBox.js +1 -1
- package/prompt-box/PromptBox.mjs +30 -30
|
@@ -6,32 +6,33 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as a from "react";
|
|
9
|
-
import { classNames as
|
|
10
|
-
import { DropDownButton as
|
|
11
|
-
import {
|
|
9
|
+
import { classNames as I, IconWrap as u, getFileExtensionIcon as k } from "@progress/kendo-react-common";
|
|
10
|
+
import { DropDownButton as h } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { downloadIcon as B, moreVerticalIcon as w } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { useLocalization as F } from "@progress/kendo-react-intl";
|
|
13
13
|
import { fileActions as l, messages as E } from "../../../messages/index.mjs";
|
|
14
14
|
import { useChatContext as C } from "../ChatContext.mjs";
|
|
15
15
|
const P = (x) => {
|
|
16
|
-
const { files: c, onFileAction: i, onDownload: r, fileActions:
|
|
16
|
+
const { files: c, onFileAction: i, onDownload: r, fileActions: z } = x, { messageFilesLayout: s = "vertical" } = C(), m = F(), p = z || [{ id: "download", label: "Download", svgIcon: B }], f = (e) => {
|
|
17
17
|
if (e == null)
|
|
18
18
|
return "";
|
|
19
19
|
if (e === 0)
|
|
20
20
|
return "0 B";
|
|
21
21
|
const t = 1024, o = ["B", "KB", "MB", "GB", "TB"], n = Math.floor(Math.log(e) / Math.log(t));
|
|
22
22
|
return `${parseFloat((e / Math.pow(t, n)).toFixed(2))} ${o[n]}`;
|
|
23
|
-
}, g = (e) => "." + e.split(".").pop() || "",
|
|
23
|
+
}, g = (e) => "." + e.split(".").pop() || "", N = (e, t) => {
|
|
24
24
|
var o, n;
|
|
25
25
|
(n = (o = e.syntheticEvent) == null ? void 0 : o.stopPropagation) == null || n.call(o), e.item.id === "download" && (r == null || r([t])), i == null || i(e.item, e, t);
|
|
26
26
|
}, d = (e) => p.length > 0 && /* @__PURE__ */ a.createElement(
|
|
27
|
-
|
|
27
|
+
h,
|
|
28
28
|
{
|
|
29
29
|
fillMode: "flat",
|
|
30
|
+
size: "small",
|
|
30
31
|
svgIcon: w,
|
|
31
32
|
onClick: (t) => {
|
|
32
33
|
t.syntheticEvent.stopPropagation();
|
|
33
34
|
},
|
|
34
|
-
onItemClick: (t) =>
|
|
35
|
+
onItemClick: (t) => N(t, e),
|
|
35
36
|
items: p.map((t) => ({
|
|
36
37
|
id: t.id,
|
|
37
38
|
icon: t.icon,
|
|
@@ -44,14 +45,14 @@ const P = (x) => {
|
|
|
44
45
|
)} ${e.name}`,
|
|
45
46
|
title: `${m.toLanguageString(l, E[l])} ${e.name}`
|
|
46
47
|
}
|
|
47
|
-
),
|
|
48
|
+
), v = a.useCallback(() => I(
|
|
48
49
|
{
|
|
49
50
|
"k-files-wrap": s === "wrap",
|
|
50
51
|
"k-files-vertical": s === "vertical"
|
|
51
52
|
},
|
|
52
53
|
"k-file-box-wrapper"
|
|
53
54
|
), [s]);
|
|
54
|
-
return /* @__PURE__ */ a.createElement("ul", { className:
|
|
55
|
+
return /* @__PURE__ */ a.createElement("ul", { className: v() }, s === "horizontal" ? /* @__PURE__ */ a.createElement("div", { className: "k-files-scroll" }, c.map((e) => /* @__PURE__ */ a.createElement("li", { key: e.name, className: "k-file-box" }, /* @__PURE__ */ a.createElement(u, { size: "xlarge", ...k(g(e.name)) }), /* @__PURE__ */ a.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ a.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ a.createElement("span", { className: "k-file-size" }, f(e.size))), d(e)))) : c.map((e) => /* @__PURE__ */ a.createElement("li", { key: e.name, className: "k-file-box" }, /* @__PURE__ */ a.createElement(u, { size: "xlarge", ...k(g(e.name)) }), /* @__PURE__ */ a.createElement("div", { className: "k-file-info" }, /* @__PURE__ */ a.createElement("span", { className: "k-file-name" }, e.name), /* @__PURE__ */ a.createElement("span", { className: "k-file-size" }, f(e.size))), d(e))));
|
|
55
56
|
};
|
|
56
57
|
export {
|
|
57
58
|
P as default
|
|
@@ -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";const
|
|
8
|
+
"use strict";const p=require("react"),m=require("@progress/kendo-react-common"),g=require("@progress/kendo-react-buttons"),i=require("@progress/kendo-svg-icons"),k=require("@progress/kendo-react-intl"),a=require("../../utils.js");function v(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,c.get?c:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const r=v(p),b=n=>{const{message:e,onUnpin:t,user:c,onReferencedMessageClick:s}=n,l=k.useLocalization(),u=r.useRef(null),d=c&&a.isAuthor(c,e),f=r.useCallback(o=>{o.preventDefault(),o.stopPropagation(),s==null||s(e.id)},[e.id,s]);return r.createElement("div",{ref:u,className:`k-message-reference ${d?"k-message-reference-sender":"k-message-reference-receiver"} k-message-pinned`,onClick:f},r.createElement(m.IconWrap,{icon:i.pinIcon}),r.createElement("div",{className:"k-message-reference-content"},e!=null&&e.isDeleted?c&&a.getDeletedMessageText(a.isAuthor(c,e),l):e==null?void 0:e.text),r.createElement("span",{className:"k-spacer"}),r.createElement(g.Button,{fillMode:"flat",size:"xs",svgIcon:i.xCircleIcon,onClick:o=>{o.stopPropagation(),t==null||t(e)}}))};module.exports=b;
|
|
@@ -8,15 +8,15 @@
|
|
|
8
8
|
import * as t from "react";
|
|
9
9
|
import { IconWrap as f } from "@progress/kendo-react-common";
|
|
10
10
|
import { Button as d } from "@progress/kendo-react-buttons";
|
|
11
|
-
import {
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import { isAuthor as
|
|
14
|
-
const
|
|
15
|
-
const { message: e, onUnpin:
|
|
16
|
-
(
|
|
17
|
-
|
|
11
|
+
import { pinIcon as u, xCircleIcon as g } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as k } from "@progress/kendo-react-intl";
|
|
13
|
+
import { isAuthor as a, getDeletedMessageText as v } from "../../utils.mjs";
|
|
14
|
+
const P = (c) => {
|
|
15
|
+
const { message: e, onUnpin: o, user: r, onReferencedMessageClick: n } = c, i = k(), l = t.useRef(null), m = r && a(r, e), p = t.useCallback(
|
|
16
|
+
(s) => {
|
|
17
|
+
s.preventDefault(), s.stopPropagation(), n == null || n(e.id);
|
|
18
18
|
},
|
|
19
|
-
[e.id,
|
|
19
|
+
[e.id, n]
|
|
20
20
|
);
|
|
21
21
|
return /* @__PURE__ */ t.createElement(
|
|
22
22
|
"div",
|
|
@@ -26,20 +26,21 @@ const C = (c) => {
|
|
|
26
26
|
onClick: p
|
|
27
27
|
},
|
|
28
28
|
/* @__PURE__ */ t.createElement(f, { icon: u }),
|
|
29
|
-
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, e != null && e.isDeleted ?
|
|
29
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, e != null && e.isDeleted ? r && v(a(r, e), i) : e == null ? void 0 : e.text),
|
|
30
30
|
/* @__PURE__ */ t.createElement("span", { className: "k-spacer" }),
|
|
31
31
|
/* @__PURE__ */ t.createElement(
|
|
32
32
|
d,
|
|
33
33
|
{
|
|
34
34
|
fillMode: "flat",
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
size: "xs",
|
|
36
|
+
svgIcon: g,
|
|
37
|
+
onClick: (s) => {
|
|
38
|
+
s.stopPropagation(), o == null || o(e);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
)
|
|
41
42
|
);
|
|
42
43
|
};
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
+
P as default
|
|
45
46
|
};
|
|
@@ -42,7 +42,7 @@ 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 —
|
|
45
|
+
* Remote mode: messages.length < total — consumer manages data.
|
|
46
46
|
*
|
|
47
47
|
* @hidden
|
|
48
48
|
*/
|
|
@@ -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(y){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(y){for(const q in y)if(q!=="default"){const
|
|
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 i=Object.getOwnPropertyDescriptor(y,q);Object.defineProperty(n,q,i.get?i:{enumerable:!0,get:()=>y[q]})}}return n.default=y,Object.freeze(n)}const r=rt(tt),ct=50,L=100,ut=({scrollMode:y,processedMessages:n,total:q,pageSize:i=ct,startIndex:Z,endIndex:d,onLoadMoreMessages:u,onReferencedMessageClick:j,viewItemsWrapperRef:l,authorId:v})=>{const k=r.useRef(!1),x=y==="endless",e=q!=null?q:n.length,E=x&&n.length===e&&!k.current,h=x&&(n.length<e||k.current);h&&(k.current=!0);const[D,B]=r.useState(-1),[m,O]=r.useState(-1),K=r.useRef(D),$=r.useRef(m);K.current=D,$.current=m;const o=r.useRef(!1),P=r.useRef(0),w=r.useRef(0),b=r.useRef(!1),I=r.useRef(e),G=r.useRef(v);G.current=v;const U=r.useRef(!1),C=r.useRef(null),J=r.useRef(!1),N=r.useRef(!1),Q=r.useRef(!0),V=r.useRef(e);r.useEffect(()=>{if(E){if(k.current){(D===-1||m===-1)&&(B(0),O(n.length));return}if(D===-1||m===-1){const t=Math.max(0,n.length-i),c=n.length;B(t),O(c)}else if(m<n.length){const t=I.current;if($.current>=t)O(n.length);else if(n.length>t&&n.slice(t).some(f=>{var a;return((a=f.author)==null?void 0:a.id)!==void 0&&String(f.author.id)===String(G.current)})){const f=Math.max(0,n.length-i);B(f),O(n.length),J.current=!0}}I.current=e}},[E,n.length,i,D,m,e]);const _=Z!=null?Z:0,H=d!=null?d:n.length,g=r.useCallback(()=>{const t=l.current;t&&(P.current=t.scrollHeight,w.current=t.scrollTop)},[l]),A=r.useCallback(t=>{var S,f,a;const c=(S=l.current)==null?void 0:S.closest(".k-chat"),T=((a=(f=l.current)==null?void 0:f.querySelector(".k-message-pinned"))==null?void 0:a.offsetHeight)||0;nt.scrollToMessageById(t,c,T)},[l]);r.useLayoutEffect(()=>{if(!b.current)return;const t=l.current;if(!t){b.current=!1;return}const c=t.scrollHeight-P.current;c>0&&(t.scrollTop=w.current+c),b.current=!1,o.current=!1}),r.useLayoutEffect(()=>{if(!J.current)return;const t=l.current;if(!t){J.current=!1;return}m>=n.length&&m>0&&(J.current=!1,t.scrollTop=t.scrollHeight-t.clientHeight)});const z=r.useRef(!1);r.useLayoutEffect(()=>{if(!x||z.current)return;const t=l.current;t&&t.querySelector("[data-message-id]")&&(t.scrollTop=t.scrollHeight-t.clientHeight,z.current=!0)}),r.useEffect(()=>{if(!x)return;const t=l.current;if(!t)return;let c=t.scrollTop;const T=()=>{const{scrollTop:S,scrollHeight:f,clientHeight:a}=t,Y=S<c,M=S>c;if(c=S,!o.current){if(Y&&S<=L){if(E){const R=K.current;if(R>0){const F=Math.max(0,R-i);b.current=!0,g(),B(F),u==null||u({startIndex:F,endIndex:$.current})}}else if(h&&_>0){o.current=!0;const R=Math.max(0,_-i);b.current=!0,g(),u==null||u({startIndex:R,endIndex:H})}}if(M&&f-S-a<=L){if(E){const R=$.current;if(R<n.length){const F=Math.min(n.length,R+i);N.current=!0,O(F),u==null||u({startIndex:K.current,endIndex:F})}}else if(h&&H<e){o.current=!0,N.current=!0;const R=Math.min(e,H+i);u==null||u({startIndex:_,endIndex:R})}}}};return t.addEventListener("scroll",T,{passive:!0}),()=>t.removeEventListener("scroll",T)},[x,E,h,l,i,n.length,_,H,e,u]),r.useEffect(()=>{var S;const t=H>=e;if(!h){V.current=e,Q.current=t;return}const c=V.current,T=Q.current;if(V.current=e,Q.current=t,e>c&&!T&&t){const f=n[n.length-1];G.current!==void 0&&((S=f==null?void 0:f.author)==null?void 0:S.id)!==void 0&&String(f.author.id)===String(G.current)&&(U.current=!0,N.current=!0)}},[h,e,H,n]),r.useEffect(()=>{!h||!U.current||(U.current=!1,o.current=!1,requestAnimationFrame(()=>{const t=l.current;t&&(t.scrollTop=t.scrollHeight-t.clientHeight)}))},[h,n,l]),r.useEffect(()=>{if(!h||C.current===null)return;const t=C.current,c=l.current;if(!c)return;c.querySelector(`[data-message-id="${t}"]`)&&(C.current=null,o.current=!1,requestAnimationFrame(()=>{A(t)}))},[h,n,l,A]),r.useEffect(()=>{h&&o.current&&!b.current&&(o.current=!1)},[h,_,H]);const W=r.useMemo(()=>{if(E){const t=Math.max(0,D),c=Math.min(n.length,m);if(t>=c){const T=Math.max(0,n.length-i);return n.slice(T)}return n.slice(t,c)}return n},[E,n,D,m,i]),X=r.useMemo(()=>x?E?m>=n.length:H>=e:!0,[x,E,m,n.length,H,e]),s=r.useCallback(()=>{if(!x||X){const t=l.current;t&&t.scrollTo({top:t.scrollHeight-t.clientHeight,behavior:"smooth"});return}if(!o.current){if(E){const t=Math.max(0,n.length-i);B(t),O(n.length),u==null||u({startIndex:t,endIndex:n.length}),requestAnimationFrame(()=>{const c=l.current;c&&(c.scrollTop=c.scrollHeight-c.clientHeight)})}else if(h){U.current=!0,b.current=!1,o.current=!0;const t=Math.max(0,e-i);u==null||u({startIndex:t,endIndex:e})}}},[x,E,h,X,n.length,i,e,u,l]),p=r.useCallback(t=>{if(!x)A(t);else if(E){const c=l.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;const S=n.findIndex(f=>f.id===t||String(f.id)===String(t));if(S>=0){const f=Math.floor(i/2),a=Math.max(0,S-f),Y=Math.min(n.length,a+i);o.current=!0,B(a),O(Y),requestAnimationFrame(()=>{requestAnimationFrame(()=>{A(t),o.current=!1})})}}}else if(h){const c=l.current;if(c==null?void 0:c.querySelector(`[data-message-id="${t}"]`))A(t);else{if(o.current)return;C.current=t,b.current=!1,o.current=!0}}j==null||j({id:t})},[x,E,h,l,n,i,j,A]);return{renderedMessages:W,handleScrollToBottom:s,handleReferencedMessageClick:p,isEndless:x,isOnLastBatch:X,skipAutoScrollRef:N}};exports.useEndlessScroll=ut;
|
|
@@ -7,259 +7,259 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
9
|
import { scrollToMessageById as tt } from "../utils.mjs";
|
|
10
|
-
const nt = 50,
|
|
11
|
-
scrollMode:
|
|
10
|
+
const nt = 50, L = 100, ct = ({
|
|
11
|
+
scrollMode: W,
|
|
12
12
|
processedMessages: n,
|
|
13
|
-
total:
|
|
14
|
-
pageSize:
|
|
15
|
-
startIndex:
|
|
16
|
-
endIndex:
|
|
17
|
-
onLoadMoreMessages:
|
|
18
|
-
onReferencedMessageClick:
|
|
19
|
-
viewItemsWrapperRef:
|
|
20
|
-
authorId:
|
|
13
|
+
total: Z,
|
|
14
|
+
pageSize: e = nt,
|
|
15
|
+
startIndex: j,
|
|
16
|
+
endIndex: K,
|
|
17
|
+
onLoadMoreMessages: u,
|
|
18
|
+
onReferencedMessageClick: F,
|
|
19
|
+
viewItemsWrapperRef: l,
|
|
20
|
+
authorId: v
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
const o = r.useRef(!1),
|
|
27
|
-
|
|
28
|
-
const
|
|
22
|
+
const k = r.useRef(!1), x = W === "endless", i = Z != null ? Z : n.length, S = x && n.length === i && !k.current, h = x && (n.length < i || k.current);
|
|
23
|
+
h && (k.current = !0);
|
|
24
|
+
const [A, a] = r.useState(-1), [m, y] = r.useState(-1), N = r.useRef(A), _ = r.useRef(m);
|
|
25
|
+
N.current = A, _.current = m;
|
|
26
|
+
const o = r.useRef(!1), P = r.useRef(0), w = r.useRef(0), D = r.useRef(!1), I = r.useRef(i), $ = r.useRef(v);
|
|
27
|
+
$.current = v;
|
|
28
|
+
const G = r.useRef(!1), U = r.useRef(null), C = r.useRef(!1), J = r.useRef(!1), Q = r.useRef(!0), V = r.useRef(i);
|
|
29
29
|
r.useEffect(() => {
|
|
30
|
-
if (
|
|
31
|
-
if (
|
|
32
|
-
(
|
|
30
|
+
if (S) {
|
|
31
|
+
if (k.current) {
|
|
32
|
+
(A === -1 || m === -1) && (a(0), y(n.length));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
36
|
-
const t = Math.max(0, n.length -
|
|
37
|
-
|
|
38
|
-
} else if (
|
|
39
|
-
const t =
|
|
40
|
-
if (
|
|
41
|
-
|
|
35
|
+
if (A === -1 || m === -1) {
|
|
36
|
+
const t = Math.max(0, n.length - e), c = n.length;
|
|
37
|
+
a(t), y(c);
|
|
38
|
+
} else if (m < n.length) {
|
|
39
|
+
const t = I.current;
|
|
40
|
+
if (_.current >= t)
|
|
41
|
+
y(n.length);
|
|
42
42
|
else if (n.length > t && n.slice(t).some(
|
|
43
|
-
(
|
|
44
|
-
var
|
|
45
|
-
return ((
|
|
43
|
+
(f) => {
|
|
44
|
+
var H;
|
|
45
|
+
return ((H = f.author) == null ? void 0 : H.id) !== void 0 && String(f.author.id) === String($.current);
|
|
46
46
|
}
|
|
47
47
|
)) {
|
|
48
|
-
const
|
|
49
|
-
|
|
48
|
+
const f = Math.max(0, n.length - e);
|
|
49
|
+
a(f), y(n.length), C.current = !0;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
I.current = i;
|
|
53
53
|
}
|
|
54
|
-
}, [
|
|
55
|
-
const O =
|
|
56
|
-
const t =
|
|
57
|
-
t && (
|
|
58
|
-
}, [
|
|
54
|
+
}, [S, n.length, e, A, m, i]);
|
|
55
|
+
const O = j != null ? j : 0, R = K != null ? K : n.length, d = r.useCallback(() => {
|
|
56
|
+
const t = l.current;
|
|
57
|
+
t && (P.current = t.scrollHeight, w.current = t.scrollTop);
|
|
58
|
+
}, [l]), B = r.useCallback(
|
|
59
59
|
(t) => {
|
|
60
|
-
var
|
|
61
|
-
const c = (
|
|
62
|
-
tt(t, c,
|
|
60
|
+
var E, f, H;
|
|
61
|
+
const c = (E = l.current) == null ? void 0 : E.closest(".k-chat"), T = ((H = (f = l.current) == null ? void 0 : f.querySelector(".k-message-pinned")) == null ? void 0 : H.offsetHeight) || 0;
|
|
62
|
+
tt(t, c, T);
|
|
63
63
|
},
|
|
64
|
-
[
|
|
64
|
+
[l]
|
|
65
65
|
);
|
|
66
66
|
r.useLayoutEffect(() => {
|
|
67
|
-
if (!
|
|
67
|
+
if (!D.current)
|
|
68
68
|
return;
|
|
69
|
-
const t =
|
|
69
|
+
const t = l.current;
|
|
70
70
|
if (!t) {
|
|
71
|
-
|
|
71
|
+
D.current = !1;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const c = t.scrollHeight -
|
|
75
|
-
c > 0 && (t.scrollTop =
|
|
74
|
+
const c = t.scrollHeight - P.current;
|
|
75
|
+
c > 0 && (t.scrollTop = w.current + c), D.current = !1, o.current = !1;
|
|
76
76
|
}), r.useLayoutEffect(() => {
|
|
77
|
-
if (!
|
|
77
|
+
if (!C.current)
|
|
78
78
|
return;
|
|
79
|
-
const t =
|
|
79
|
+
const t = l.current;
|
|
80
80
|
if (!t) {
|
|
81
|
-
|
|
81
|
+
C.current = !1;
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
m >= n.length && m > 0 && (C.current = !1, t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
85
85
|
});
|
|
86
|
-
const
|
|
86
|
+
const z = r.useRef(!1);
|
|
87
87
|
r.useLayoutEffect(() => {
|
|
88
|
-
if (!
|
|
88
|
+
if (!x || z.current)
|
|
89
89
|
return;
|
|
90
|
-
const t =
|
|
91
|
-
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight,
|
|
90
|
+
const t = l.current;
|
|
91
|
+
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight, z.current = !0);
|
|
92
92
|
}), r.useEffect(() => {
|
|
93
|
-
if (!
|
|
93
|
+
if (!x)
|
|
94
94
|
return;
|
|
95
|
-
const t =
|
|
95
|
+
const t = l.current;
|
|
96
96
|
if (!t)
|
|
97
97
|
return;
|
|
98
98
|
let c = t.scrollTop;
|
|
99
|
-
const
|
|
100
|
-
const { scrollTop:
|
|
101
|
-
if (c =
|
|
102
|
-
if (
|
|
103
|
-
if (
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
99
|
+
const T = () => {
|
|
100
|
+
const { scrollTop: E, scrollHeight: f, clientHeight: H } = t, Y = E < c, M = E > c;
|
|
101
|
+
if (c = E, !o.current) {
|
|
102
|
+
if (Y && E <= L) {
|
|
103
|
+
if (S) {
|
|
104
|
+
const q = N.current;
|
|
105
|
+
if (q > 0) {
|
|
106
|
+
const b = Math.max(0, q - e);
|
|
107
|
+
D.current = !0, d(), a(b), u == null || u({ startIndex: b, endIndex: _.current });
|
|
108
108
|
}
|
|
109
|
-
} else if (
|
|
109
|
+
} else if (h && O > 0) {
|
|
110
110
|
o.current = !0;
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const q = Math.max(0, O - e);
|
|
112
|
+
D.current = !0, d(), u == null || u({ startIndex: q, endIndex: R });
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
if (
|
|
116
|
-
if (
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
115
|
+
if (M && f - E - H <= L) {
|
|
116
|
+
if (S) {
|
|
117
|
+
const q = _.current;
|
|
118
|
+
if (q < n.length) {
|
|
119
|
+
const b = Math.min(n.length, q + e);
|
|
120
|
+
J.current = !0, y(b), u == null || u({ startIndex: N.current, endIndex: b });
|
|
121
121
|
}
|
|
122
|
-
} else if (
|
|
123
|
-
o.current = !0,
|
|
124
|
-
const
|
|
125
|
-
|
|
122
|
+
} else if (h && R < i) {
|
|
123
|
+
o.current = !0, J.current = !0;
|
|
124
|
+
const q = Math.min(i, R + e);
|
|
125
|
+
u == null || u({ startIndex: O, endIndex: q });
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
return t.addEventListener("scroll",
|
|
130
|
+
return t.addEventListener("scroll", T, { passive: !0 }), () => t.removeEventListener("scroll", T);
|
|
131
131
|
}, [
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
x,
|
|
133
|
+
S,
|
|
134
|
+
h,
|
|
135
|
+
l,
|
|
136
|
+
e,
|
|
137
137
|
n.length,
|
|
138
138
|
O,
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
139
|
+
R,
|
|
140
|
+
i,
|
|
141
|
+
u
|
|
142
142
|
]), r.useEffect(() => {
|
|
143
|
-
var
|
|
144
|
-
const t =
|
|
145
|
-
if (!
|
|
146
|
-
|
|
143
|
+
var E;
|
|
144
|
+
const t = R >= i;
|
|
145
|
+
if (!h) {
|
|
146
|
+
V.current = i, Q.current = t;
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
const c =
|
|
150
|
-
if (
|
|
151
|
-
const
|
|
152
|
-
|
|
149
|
+
const c = V.current, T = Q.current;
|
|
150
|
+
if (V.current = i, Q.current = t, i > c && !T && t) {
|
|
151
|
+
const f = n[n.length - 1];
|
|
152
|
+
$.current !== void 0 && ((E = f == null ? void 0 : f.author) == null ? void 0 : E.id) !== void 0 && String(f.author.id) === String($.current) && (G.current = !0, J.current = !0);
|
|
153
153
|
}
|
|
154
|
-
}, [
|
|
155
|
-
!
|
|
156
|
-
const t =
|
|
154
|
+
}, [h, i, R, n]), r.useEffect(() => {
|
|
155
|
+
!h || !G.current || (G.current = !1, o.current = !1, requestAnimationFrame(() => {
|
|
156
|
+
const t = l.current;
|
|
157
157
|
t && (t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
158
158
|
}));
|
|
159
|
-
}, [
|
|
160
|
-
if (!
|
|
159
|
+
}, [h, n, l]), r.useEffect(() => {
|
|
160
|
+
if (!h || U.current === null)
|
|
161
161
|
return;
|
|
162
|
-
const t =
|
|
162
|
+
const t = U.current, c = l.current;
|
|
163
163
|
if (!c)
|
|
164
164
|
return;
|
|
165
|
-
c.querySelector(`[data-message-id="${t}"]`) && (
|
|
166
|
-
|
|
165
|
+
c.querySelector(`[data-message-id="${t}"]`) && (U.current = null, o.current = !1, requestAnimationFrame(() => {
|
|
166
|
+
B(t);
|
|
167
167
|
}));
|
|
168
|
-
}, [
|
|
169
|
-
|
|
170
|
-
}, [
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
173
|
-
const t = Math.max(0,
|
|
168
|
+
}, [h, n, l, B]), r.useEffect(() => {
|
|
169
|
+
h && o.current && !D.current && (o.current = !1);
|
|
170
|
+
}, [h, O, R]);
|
|
171
|
+
const g = r.useMemo(() => {
|
|
172
|
+
if (S) {
|
|
173
|
+
const t = Math.max(0, A), c = Math.min(n.length, m);
|
|
174
174
|
if (t >= c) {
|
|
175
|
-
const
|
|
176
|
-
return n.slice(
|
|
175
|
+
const T = Math.max(0, n.length - e);
|
|
176
|
+
return n.slice(T);
|
|
177
177
|
}
|
|
178
178
|
return n.slice(t, c);
|
|
179
179
|
}
|
|
180
180
|
return n;
|
|
181
|
-
}, [
|
|
182
|
-
if (!
|
|
183
|
-
const t =
|
|
181
|
+
}, [S, n, A, m, e]), X = r.useMemo(() => x ? S ? m >= n.length : R >= i : !0, [x, S, m, n.length, R, i]), s = r.useCallback(() => {
|
|
182
|
+
if (!x || X) {
|
|
183
|
+
const t = l.current;
|
|
184
184
|
t && t.scrollTo({ top: t.scrollHeight - t.clientHeight, behavior: "smooth" });
|
|
185
185
|
return;
|
|
186
186
|
}
|
|
187
187
|
if (!o.current) {
|
|
188
|
-
if (
|
|
189
|
-
const t = Math.max(0, n.length -
|
|
190
|
-
|
|
191
|
-
const c =
|
|
188
|
+
if (S) {
|
|
189
|
+
const t = Math.max(0, n.length - e);
|
|
190
|
+
a(t), y(n.length), u == null || u({ startIndex: t, endIndex: n.length }), requestAnimationFrame(() => {
|
|
191
|
+
const c = l.current;
|
|
192
192
|
c && (c.scrollTop = c.scrollHeight - c.clientHeight);
|
|
193
193
|
});
|
|
194
|
-
} else if (
|
|
195
|
-
|
|
196
|
-
const t = Math.max(0,
|
|
197
|
-
|
|
194
|
+
} else if (h) {
|
|
195
|
+
G.current = !0, D.current = !1, o.current = !0;
|
|
196
|
+
const t = Math.max(0, i - e);
|
|
197
|
+
u == null || u({ startIndex: t, endIndex: i });
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}, [
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
201
|
+
x,
|
|
202
|
+
S,
|
|
203
|
+
h,
|
|
204
|
+
X,
|
|
205
205
|
n.length,
|
|
206
|
+
e,
|
|
206
207
|
i,
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
]), M = r.useCallback(
|
|
208
|
+
u,
|
|
209
|
+
l
|
|
210
|
+
]), p = r.useCallback(
|
|
211
211
|
(t) => {
|
|
212
|
-
if (!
|
|
213
|
-
|
|
214
|
-
else if (
|
|
215
|
-
const c =
|
|
212
|
+
if (!x)
|
|
213
|
+
B(t);
|
|
214
|
+
else if (S) {
|
|
215
|
+
const c = l.current;
|
|
216
216
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
217
|
-
|
|
217
|
+
B(t);
|
|
218
218
|
else {
|
|
219
219
|
if (o.current)
|
|
220
220
|
return;
|
|
221
|
-
const
|
|
222
|
-
(
|
|
221
|
+
const E = n.findIndex(
|
|
222
|
+
(f) => f.id === t || String(f.id) === String(t)
|
|
223
223
|
);
|
|
224
|
-
if (
|
|
225
|
-
const
|
|
226
|
-
o.current = !0,
|
|
224
|
+
if (E >= 0) {
|
|
225
|
+
const f = Math.floor(e / 2), H = Math.max(0, E - f), Y = Math.min(n.length, H + e);
|
|
226
|
+
o.current = !0, a(H), y(Y), requestAnimationFrame(() => {
|
|
227
227
|
requestAnimationFrame(() => {
|
|
228
|
-
|
|
228
|
+
B(t), o.current = !1;
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
} else if (
|
|
234
|
-
const c =
|
|
233
|
+
} else if (h) {
|
|
234
|
+
const c = l.current;
|
|
235
235
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
236
|
-
|
|
236
|
+
B(t);
|
|
237
237
|
else {
|
|
238
238
|
if (o.current)
|
|
239
239
|
return;
|
|
240
|
-
|
|
240
|
+
U.current = t, D.current = !1, o.current = !0;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
F == null || F({ id: t });
|
|
244
244
|
},
|
|
245
245
|
[
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
246
|
+
x,
|
|
247
|
+
S,
|
|
248
|
+
h,
|
|
249
|
+
l,
|
|
250
250
|
n,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
e,
|
|
252
|
+
F,
|
|
253
|
+
B
|
|
254
254
|
]
|
|
255
255
|
);
|
|
256
256
|
return {
|
|
257
|
-
renderedMessages:
|
|
258
|
-
handleScrollToBottom:
|
|
259
|
-
handleReferencedMessageClick:
|
|
260
|
-
isEndless:
|
|
261
|
-
isOnLastBatch:
|
|
262
|
-
skipAutoScrollRef:
|
|
257
|
+
renderedMessages: g,
|
|
258
|
+
handleScrollToBottom: s,
|
|
259
|
+
handleReferencedMessageClick: p,
|
|
260
|
+
isEndless: x,
|
|
261
|
+
isOnLastBatch: X,
|
|
262
|
+
skipAutoScrollRef: J
|
|
263
263
|
};
|
|
264
264
|
};
|
|
265
265
|
export {
|