@progress/kendo-react-conversational-ui 14.4.1-develop.9 → 14.5.0-develop.1
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/api/message.interface.d.ts +3 -3
- package/chat/ChatPropsAndState.d.ts +7 -5
- package/chat/Events.d.ts +3 -3
- package/chat/components/ActionGroup.d.ts +1 -1
- package/chat/components/Chat.d.ts +1 -1
- package/chat/components/ChatContext.d.ts +5 -5
- package/chat/components/NewMessage.d.ts +2 -2
- package/chat/components/SuggestionsGroup.d.ts +1 -1
- package/chat/hooks/useEndlessScroll.d.ts +4 -4
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +160 -160
- package/chat/utils/fieldMapping.d.ts +2 -2
- package/chat/utils/messageSettings.d.ts +2 -2
- package/chat/utils/scroll.d.ts +1 -1
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +8 -8
- package/index.d.ts +8 -8
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
- package/prompt-box/PromptBox.d.ts +1 -1
- package/prompt-box/PromptBoxUploadButton.d.ts +1 -1
- package/prompt-box/interfaces/PromptBoxProps.d.ts +1 -1
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { SVGIcon } from '@progress/kendo-react-common';
|
|
9
|
-
import { Action } from './action.interface
|
|
10
|
-
import { Attachment, AttachmentLayout } from './attachment.interface
|
|
11
|
-
import { User } from './user.interface
|
|
9
|
+
import { Action } from './action.interface';
|
|
10
|
+
import { Attachment, AttachmentLayout } from './attachment.interface';
|
|
11
|
+
import { User } from './user.interface';
|
|
12
12
|
/**
|
|
13
13
|
* Configuration for message status display with optional icon.
|
|
14
14
|
*/
|
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { Message, ChatActionExecuteEvent, ChatSendMessageEvent, ChatResendMessageEvent, PromptBoxMode } from '../index.js';
|
|
9
|
-
import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from './Events
|
|
9
|
+
import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from './Events';
|
|
10
10
|
import { ChatMessageProps, ChatMessageTemplateProps, FileAction, MessageAction } from './components/ChatMessage.js';
|
|
11
11
|
import { ChatSuggestion, SuggestionTemplateProps } from './components/SuggestionsGroup.js';
|
|
12
12
|
import { ButtonProps, SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
13
|
-
import { UploadButtonProps } from '../prompt-box/interfaces/PromptBoxProps
|
|
13
|
+
import { UploadButtonProps } from '../prompt-box/interfaces/PromptBoxProps';
|
|
14
14
|
import { DateMarker } from './ViewItem.js';
|
|
15
15
|
/**
|
|
16
16
|
* Represents the properties available to the `statusTemplate` custom component.
|
|
@@ -666,8 +666,7 @@ export interface ChatProps extends FieldMappingConfig {
|
|
|
666
666
|
/**
|
|
667
667
|
* The total number of messages in the conversation.
|
|
668
668
|
* Used to determine the mode: when `messages.length === total`, the Chat manages rendering
|
|
669
|
-
* internally (built-in mode); when `messages.length < total`, the
|
|
670
|
-
* for the consumer to fetch data (remote mode).
|
|
669
|
+
* internally (built-in mode); when `messages.length < total`, the consumer manages data (remote mode).
|
|
671
670
|
*/
|
|
672
671
|
total?: number;
|
|
673
672
|
/**
|
|
@@ -687,8 +686,11 @@ export interface ChatProps extends FieldMappingConfig {
|
|
|
687
686
|
*/
|
|
688
687
|
endIndex?: number;
|
|
689
688
|
/**
|
|
690
|
-
* Fires
|
|
689
|
+
* Fires in both built-in and remote endless scroll modes when the user scrolls near the edge
|
|
691
690
|
* of the rendered message window.
|
|
691
|
+
* In built-in mode, the Chat manages rendering internally and this callback is informational.
|
|
692
|
+
* In remote mode (`messages.length < total`), the consumer must provide the requested range.
|
|
693
|
+
* The event contains the full range that should be rendered (not just the delta).
|
|
692
694
|
*/
|
|
693
695
|
onLoadMoreMessages?: (event: ChatLoadMoreMessagesEvent) => void;
|
|
694
696
|
/**
|
package/chat/Events.d.ts
CHANGED
|
@@ -59,13 +59,13 @@ export interface ChatToolbarActionExecuteEvent extends BaseEvent<React.Component
|
|
|
59
59
|
}
|
|
60
60
|
/**
|
|
61
61
|
* Arguments for the `onLoadMoreMessages` event of the Chat.
|
|
62
|
-
* Fires in
|
|
62
|
+
* Fires in endless scroll mode when the user scrolls near the edge
|
|
63
63
|
* of the rendered message window.
|
|
64
64
|
*/
|
|
65
65
|
export interface ChatLoadMoreMessagesEvent {
|
|
66
|
-
/** The start index of the
|
|
66
|
+
/** The start index of the full message range that should be rendered (inclusive). */
|
|
67
67
|
startIndex: number;
|
|
68
|
-
/** The end index of the
|
|
68
|
+
/** The end index of the full message range that should be rendered (exclusive). */
|
|
69
69
|
endIndex: number;
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import { ActionGroup as ActionGroupModel } from '../ViewItem.js';
|
|
9
|
-
import { QuickActionsLayoutMode } from '../ChatPropsAndState
|
|
9
|
+
import { QuickActionsLayoutMode } from '../ChatPropsAndState';
|
|
10
10
|
import * as React from 'react';
|
|
11
11
|
/**
|
|
12
12
|
* @hidden
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { ChatProps } from '../ChatPropsAndState
|
|
8
|
+
import { ChatProps } from '../ChatPropsAndState';
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
/**
|
|
11
11
|
* Represents the [KendoReact Chat component](https://www.telerik.com/kendo-react-ui/components/conversational-ui).
|
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { Message } from '../../api/message.interface
|
|
9
|
-
import { User } from '../../api/user.interface
|
|
8
|
+
import { Message } from '../../api/message.interface';
|
|
9
|
+
import { User } from '../../api/user.interface';
|
|
10
10
|
import { FileAction, MessageAction } from './ChatMessage.js';
|
|
11
|
-
import { StatusTemplateProps, UserStatusTemplateProps, ChatFile, FilesLayoutMode, TimestampVisibilityMode } from '../ChatPropsAndState
|
|
11
|
+
import { StatusTemplateProps, UserStatusTemplateProps, ChatFile, FilesLayoutMode, TimestampVisibilityMode } from '../ChatPropsAndState';
|
|
12
12
|
import { SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
13
|
-
import { UploadButtonProps } from '../../prompt-box/interfaces/PromptBoxProps
|
|
14
|
-
import { ChatResendMessageEvent } from '../Events
|
|
13
|
+
import { UploadButtonProps } from '../../prompt-box/interfaces/PromptBoxProps';
|
|
14
|
+
import { ChatResendMessageEvent } from '../Events';
|
|
15
15
|
import * as React from 'react';
|
|
16
16
|
/**
|
|
17
17
|
* @hidden
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { ChatMessageBoxProps, MessageBoxSettings } from '../ChatPropsAndState
|
|
8
|
+
import { ChatMessageBoxProps, MessageBoxSettings } from '../ChatPropsAndState';
|
|
9
9
|
import { MessageAction, FileAction } from './ChatMessage.js';
|
|
10
10
|
import { ButtonProps } from '@progress/kendo-react-buttons';
|
|
11
11
|
import { ChatSuggestion, SuggestionTemplateProps } from './SuggestionsGroup.js';
|
|
12
|
-
import { Message } from '../../api/message.interface
|
|
12
|
+
import { Message } from '../../api/message.interface';
|
|
13
13
|
import * as React from 'react';
|
|
14
14
|
/**
|
|
15
15
|
* @hidden
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { SuggestionsLayoutMode } from '../ChatPropsAndState
|
|
8
|
+
import { SuggestionsLayoutMode } from '../ChatPropsAndState';
|
|
9
9
|
import * as React from 'react';
|
|
10
10
|
/**
|
|
11
11
|
* Represents the rendering options for suggestions in the AI Prompt component.
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { Message } from '../../api/message.interface
|
|
9
|
-
import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from '../Events
|
|
10
|
-
import { ScrollMode } from '../ChatPropsAndState
|
|
8
|
+
import { Message } from '../../api/message.interface';
|
|
9
|
+
import { ChatLoadMoreMessagesEvent, ChatReferencedMessageClickEvent } from '../Events';
|
|
10
|
+
import { ScrollMode } from '../ChatPropsAndState';
|
|
11
11
|
import * as React from 'react';
|
|
12
12
|
/** @hidden */
|
|
13
13
|
export interface UseEndlessScrollProps {
|
|
@@ -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 {
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { Message } from '../../api/message.interface
|
|
9
|
-
import { FieldMappingConfig } from '../ChatPropsAndState
|
|
8
|
+
import { Message } from '../../api/message.interface';
|
|
9
|
+
import { FieldMappingConfig } from '../ChatPropsAndState';
|
|
10
10
|
/**
|
|
11
11
|
* Default field mapping configuration.
|
|
12
12
|
* These are the standard field names expected by the Chat component.
|