@progress/kendo-react-conversational-ui 12.0.0-develop.10 → 12.0.0-develop.12
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/README.md +7 -5
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +179 -174
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +12 -12
- package/chat/utils/fieldMapping.js +1 -1
- package/chat/utils/fieldMapping.mjs +47 -45
- package/chat/utils.js +1 -1
- package/chat/utils.mjs +25 -23
- package/codemods/v12/author-id.js +9 -0
- package/codemods/v12/chat-send-message.js +9 -0
- package/codemods/v12/index.js +9 -0
- package/codemods/v12/message-template.js +9 -0
- package/codemods/v12/send-message.js +9 -0
- package/codemods/v12/show-toolbar.js +9 -0
- package/codemods/v12/toolbar-action-execute.js +9 -0
- package/codemods/v12/toolbar.js +9 -0
- package/codemods/v12/utils.js +9 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +5 -1
- package/index.d.ts +5 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +3 -3
- package/package.json +57 -12
package/README.md
CHANGED
|
@@ -62,15 +62,17 @@ Key features include:
|
|
|
62
62
|
|
|
63
63
|
> This is a KendoReact **premium component** and requires a commercial license or an active trial license.
|
|
64
64
|
|
|
65
|
-
[The KendoReact Chat component](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)
|
|
65
|
+
[The KendoReact Chat component](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui) allows users to engage in real-time conversations with other users, chatbots or AI models.
|
|
66
|
+
|
|
67
|
+
The KendoReact Chat component provides a flexible conversational interface that helps boost user engagement in web applications. It enables seamless real-time communication and supports advanced features, such as AI-powered conversation mode, speech-to-text button, attachments, predefined quick actions for the user. The Chat component is ideal for implementing customer support chatbots, live help desks, virtual assistants for booking or scheduling, interactive FAQ systems, and more.
|
|
66
68
|
|
|
67
69
|
Key features include:
|
|
68
70
|
|
|
69
71
|
- [**Data binding**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/data-binding/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Bind the message list to streaming data from remote services and automated responses.
|
|
70
|
-
- [**
|
|
71
|
-
- [**Message
|
|
72
|
-
- [**Message
|
|
73
|
-
- [**
|
|
72
|
+
- [**AI Service Integration**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/integrations/ai-llm/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Use the Chat component with AI models.
|
|
73
|
+
- [**Message Toolbar & ContextMenu**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/messages/tools/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Add message tools and context menu options to make users' experience more interactive.
|
|
74
|
+
- [**Message Customization & Templates**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/customization/message-templates/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Customize the message bubbles and other Chat features like header, message box, timestamp, suggestions, timestamp, etc.
|
|
75
|
+
- [**Suggestions and quick message actions**](https://www.telerik.com/kendo-react-ui/components/conversationalui/chat/quick-actions/suggestions/?utm_medium=referral&utm_source=npm&utm_campaign=kendo-ui-react-trial-npm-conversational-ui)—Display suggested and quick actions buttons for faster interaction and communication.
|
|
74
76
|
|
|
75
77
|
## React InlineAIPrompt Component
|
|
76
78
|
|
package/chat/components/Chat.js
CHANGED
|
@@ -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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("@progress/kendo-react-common"),a=require("prop-types"),We=require("react"),ze=require("../ViewItem.js"),Ye=require("./ActionGroup.js"),$e=require("./AttachmentGroup.js"),Je=require("./DateMarker.js"),Qe=require("./MessageGroup.js"),Xe=require("./NewMessage.js"),Ze=require("./Header.js"),et=require("./elements/PinnedMessage.js"),tt=require("./Notification.js"),nt=require("./ChatContext.js"),st=require("./ChatMessage.js"),Re=require("../../package-metadata.js"),T=require("../../messages/index.js"),ot=require("@progress/kendo-react-intl"),be=require("../utils/fieldMapping.js");function at(u){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(u){for(const r in u)if(r!=="default"){const y=Object.getOwnPropertyDescriptor(u,r);Object.defineProperty(i,r,y.get?y:{enumerable:!0,get:()=>u[r]})}}return i.default=u,Object.freeze(i)}const e=at(We),rt=50,it=250,lt=50,ct=100,A=e.forwardRef((u,i)=>{const{messages:r=[],messageTemplate:y,attachmentTemplate:M,width:xe,height:Ie,onSendMessage:C,onSuggestionClick:v,onInputValueChange:N,onActionExecute:R,dir:b,messageBox:Le,placeholder:we,className:O,message:D=st.ChatMessage,authorId:d,suggestions:k,suggestionTemplate:qe,inputValue:Fe,headerTemplate:p,timestampTemplate:B,statusTemplate:P,allowMessageCollapse:_,messageToolbarActions:V,messageContextMenuActions:j,fileActions:H,onUnpin:Ae,messageWidthMode:U,onToolbarAction:G,onContextMenuAction:K,onFileAction:W,onDownload:z,speechToTextConfig:Y,uploadConfig:$,sendButtonConfig:ve,textField:J,statusField:Q,authorIdField:X,authorNameField:Z,authorImageUrlField:ee,authorImageAltTextField:te,idField:ne,timestampField:se,filesField:oe,attachmentsField:ae,replyToIdField:re,isDeletedField:ie,isPinnedField:le,typingField:ce,suggestedActionsField:ue,...Ne}=u,[m,x]=e.useState(null),[I,Oe]=e.useState(!1),[De,de]=e.useState(!1),[me,ge]=e.useState(null),[g,fe]=e.useState(null),L=e.useRef(null),pe=e.useRef(null),l=e.useRef(null),he=e.useRef(null),w=e.useRef(void 0),q=e.useRef(void 0),F=e.useRef(null),Te=e.useRef(""),o=e.useMemo(()=>{if(!r||r.length===0)return[];const t={textField:J,statusField:Q,authorIdField:X,authorNameField:Z,authorImageUrlField:ee,authorImageAltTextField:te,idField:ne,timestampField:se,filesField:oe,attachmentsField:ae,replyToIdField:re,isDeletedField:ie,isPinnedField:le,typingField:ce,suggestedActionsField:ue};return!Object.values(t).some(s=>s!==void 0)&&be.isStandardMessageFormat(r[0])?r.map(s=>({...s,timestamp:s.timestamp?new Date(s.timestamp):s.timestamp})):be.mapDataArrayToMessages(r,t)},[r,J,Q,X,Z,ee,te,ne,se,oe,ae,re,ie,le,ce,ue]);e.useEffect(()=>{if(d===Te.current&&F.current){fe(F.current);return}if(d&&o.length>0){const t=o.find(s=>s.author&&(s.author.id===d||s.author.id===String(d))),n=(t==null?void 0:t.author)||{id:d};F.current=n,Te.current=d,fe(n)}},[d,o]);const f=e.useMemo(()=>o.length>0?ze.convertMsgsToViewItems(o):[],[o]),Be=e.useMemo(()=>!c.validatePackage(Re.packageMetadata,{component:"Chat"}),[]),Pe=c.getLicenseMessage(Re.packageMetadata),ye=e.useMemo(()=>o.find(t=>t.isPinned),[o]),Ce=ot.useLocalization(),_e=e.useCallback(()=>{clearTimeout(w.current)},[]),Ve=e.useCallback(()=>{w.current=window.setTimeout(()=>{x(null)},0)},[]),S=e.useCallback(t=>{x(t)},[]),je=e.useCallback(t=>{let n=null;const s=m!==null?m:f.lastSelectionIndex;t.keyCode===c.Keys.up?s===null?n=0:s>0&&(n=s-1):t.keyCode===c.Keys.down?s===null?n=0:s<f.lastSelectionIndex&&(n=s+1):t.keyCode===c.Keys.home?n=0:t.keyCode===c.Keys.end&&(n=f.lastSelectionIndex),n!==null&&(x(n),t.preventDefault())},[m,f]),h=e.useCallback(()=>{l.current&&(l.current.scrollTop=l.current.scrollHeight-l.current.clientHeight)},[]),ke=e.useCallback(()=>{if(!l.current)return!0;const{scrollTop:t,scrollHeight:n,clientHeight:s}=l.current;return n-t-s<rt},[]),E=e.useCallback(()=>{ke()&&requestAnimationFrame(()=>{h()})},[ke,h]),Se=e.useCallback(()=>{requestAnimationFrame(()=>{h()})},[h]),Ee=e.useCallback((t,n,s)=>{var Me;if(R&&R({action:{value:t.value,title:t.title,type:t.type},syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.currentTarget}),!n.isDefaultPrevented()){switch(t.type){case"reply":C&&C({message:{id:"",author:g,text:t.value,timestamp:new Date},syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.currentTarget});break;case"call":window.open("tel:"+t.value);break;case"openUrl":window.open(t.value);break}(Me=he.current)==null||Me.focusInput()}},[R,C,g]),He=e.useCallback(()=>c.classNames("k-chat",O,{"k-rtl":I}),[O,I]),Ue=e.useCallback(()=>{const t=f.length-1;return f.map((n,s)=>n.type==="date-marker"?e.createElement(Je,{item:n,key:n.trackBy,timestampTemplate:B}):n.type==="message-group"?e.createElement(Qe,{group:n,itemTemplate:y,attachmentTemplate:M,user:g,selectedItemIndex:m,onRequestSelection:S,isLastGroup:s===t,key:n.messages[0].selectionIndex,message:D,allowMessageCollapse:_,messageToolbarActions:V,messageContextMenuActions:j,messageWidthMode:U}):n.type==="attachment-group"?e.createElement($e,{group:n,itemTemplate:M,onRequestSelection:S,selected:n.selectionIndex===m,isLastGroup:s===t,key:n.selectionIndex}):n.type==="action-group"?e.createElement(Ye,{group:n,onActionExecute:Ee,onRequestSelection:S,selected:n.selectionIndex===m,key:n.selectionIndex}):null)},[f,B,y,M,g,m,S,D,_,V,j,U,Ee]),Ge=e.useCallback(()=>p?typeof p=="function"?p():p:null,[p]);e.useEffect(()=>{const t=b!==void 0?b==="rtl":L.current&&getComputedStyle(L.current).direction==="rtl";Oe(!!t)},[b]),e.useEffect(()=>(q.current=window.setTimeout(()=>h(),it),()=>{clearTimeout(q.current)}),[h]),e.useEffect(()=>()=>{clearTimeout(w.current),clearTimeout(q.current)},[]),e.useEffect(()=>{Se()},[o.length,Se]),e.useEffect(()=>{const t=window.setTimeout(()=>{E()},lt);return()=>{clearTimeout(t)}},[o,E]),e.useEffect(()=>{if(k&&k.length>0){const t=window.setTimeout(()=>{E()},ct);return()=>{clearTimeout(t)}}},[k,E]);const Ke=e.useMemo(()=>({replyToMessage:me,setReplyToMessage:ge,messages:o,user:g,internalScrollContainerRef:pe,messageListScrollContainerRef:l,onToolbarAction:G,onContextMenuAction:K,onFileAction:W,setShowCopyNotification:de,onDownload:z,fileActions:H,speechToTextConfig:Y,uploadConfig:$,statusTemplate:P}),[me,ge,o,g,G,K,W,de,z,H,Y,$,P]);return e.createElement(nt.default.Provider,{value:Ke},e.createElement("div",{style:{width:xe,height:Ie,position:"relative",overflow:"hidden"},onKeyDown:je,className:He(),ref:t=>{L.current=t,pe.current=t,typeof i=="function"?i(t):i&&(i.current=t)},...Ne},p!==void 0&&e.createElement(Ze,null,Ge()),ye&&e.createElement(et,{message:ye,onUnpin:Ae,user:g}),e.createElement("div",{className:"k-message-list k-avatars",onBlur:Ve,onFocus:_e,role:"log","aria-label":Ce.toLanguageString(T.ariaLabelMessageList,T.messages[T.ariaLabelMessageList]),"aria-live":"polite",ref:l},e.createElement("div",{className:"k-message-list-content"},Ue())),e.createElement(Xe,{onSendMessage:(t,n)=>{C&&C({message:t,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.currentTarget})},onSuggestionClick:t=>{v&&v(t)},isDirectionRightToLeft:I,ref:he,placeholder:we,MessageBox:Le,suggestions:k,suggestionTemplate:qe,inputValue:Fe,onInputValueChange:t=>{N&&N(t)},sendButtonConfig:ve}),e.createElement(tt,{show:De,text:Ce.toLanguageString(T.chatCopyNotification,T.messages[T.chatCopyNotification])}),Be&&e.createElement(c.WatermarkOverlay,{message:Pe})))});A.displayName="Chat";A.propTypes={messages:a.arrayOf(a.object),user:a.object,messageTemplate:a.any,attachmentTemplate:a.any,width:a.oneOfType([a.string,a.number]),onSendMessage:a.func,onActionExecute:a.func,dir:a.string,messageBox:a.any};exports.Chat=A;
|
package/chat/components/Chat.mjs
CHANGED
|
@@ -5,48 +5,48 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { validatePackage as
|
|
8
|
+
import { validatePackage as ze, getLicenseMessage as Ke, Keys as y, classNames as $e, WatermarkOverlay as Je } from "@progress/kendo-react-common";
|
|
9
9
|
import r from "prop-types";
|
|
10
10
|
import * as e from "react";
|
|
11
|
-
import { convertMsgsToViewItems as
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import { ChatMessage as
|
|
22
|
-
import { packageMetadata as
|
|
23
|
-
import { ariaLabelMessageList as
|
|
24
|
-
import { useLocalization as
|
|
25
|
-
import { isStandardMessageFormat as
|
|
26
|
-
const
|
|
11
|
+
import { convertMsgsToViewItems as Qe } from "../ViewItem.mjs";
|
|
12
|
+
import Xe from "./ActionGroup.mjs";
|
|
13
|
+
import Ze from "./AttachmentGroup.mjs";
|
|
14
|
+
import et from "./DateMarker.mjs";
|
|
15
|
+
import tt from "./MessageGroup.mjs";
|
|
16
|
+
import st from "./NewMessage.mjs";
|
|
17
|
+
import nt from "./Header.mjs";
|
|
18
|
+
import ot from "./elements/PinnedMessage.mjs";
|
|
19
|
+
import rt from "./Notification.mjs";
|
|
20
|
+
import at from "./ChatContext.mjs";
|
|
21
|
+
import { ChatMessage as lt } from "./ChatMessage.mjs";
|
|
22
|
+
import { packageMetadata as Se } from "../../package-metadata.mjs";
|
|
23
|
+
import { ariaLabelMessageList as ke, messages as Me, chatCopyNotification as Re } from "../../messages/index.mjs";
|
|
24
|
+
import { useLocalization as it } from "@progress/kendo-react-intl";
|
|
25
|
+
import { isStandardMessageFormat as ct, mapDataArrayToMessages as ut } from "../utils/fieldMapping.mjs";
|
|
26
|
+
const mt = 50, dt = 250, ft = 50, pt = 100, xe = e.forwardRef((Ie, g) => {
|
|
27
27
|
const {
|
|
28
28
|
messages: m = [],
|
|
29
|
-
messageTemplate:
|
|
29
|
+
messageTemplate: F,
|
|
30
30
|
attachmentTemplate: E,
|
|
31
|
-
width:
|
|
32
|
-
height:
|
|
31
|
+
width: Le,
|
|
32
|
+
height: we,
|
|
33
33
|
onSendMessage: p,
|
|
34
|
-
onSuggestionClick:
|
|
35
|
-
onInputValueChange:
|
|
34
|
+
onSuggestionClick: b,
|
|
35
|
+
onInputValueChange: A,
|
|
36
36
|
onActionExecute: S,
|
|
37
37
|
dir: k,
|
|
38
|
-
messageBox:
|
|
38
|
+
messageBox: Fe,
|
|
39
39
|
placeholder: be,
|
|
40
|
-
className:
|
|
41
|
-
message:
|
|
40
|
+
className: v,
|
|
41
|
+
message: N = lt,
|
|
42
42
|
authorId: l,
|
|
43
43
|
suggestions: h,
|
|
44
44
|
suggestionTemplate: Ae,
|
|
45
|
-
inputValue:
|
|
46
|
-
headerTemplate:
|
|
45
|
+
inputValue: ve,
|
|
46
|
+
headerTemplate: d,
|
|
47
47
|
timestampTemplate: D,
|
|
48
|
-
statusTemplate:
|
|
49
|
-
allowMessageCollapse:
|
|
48
|
+
statusTemplate: O,
|
|
49
|
+
allowMessageCollapse: B,
|
|
50
50
|
messageToolbarActions: P,
|
|
51
51
|
messageContextMenuActions: _,
|
|
52
52
|
fileActions: H,
|
|
@@ -56,9 +56,9 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
56
56
|
onContextMenuAction: G,
|
|
57
57
|
onFileAction: q,
|
|
58
58
|
onDownload: W,
|
|
59
|
-
speechToTextConfig:
|
|
60
|
-
uploadConfig:
|
|
61
|
-
sendButtonConfig:
|
|
59
|
+
speechToTextConfig: j,
|
|
60
|
+
uploadConfig: Y,
|
|
61
|
+
sendButtonConfig: De,
|
|
62
62
|
textField: z,
|
|
63
63
|
statusField: K,
|
|
64
64
|
authorIdField: $,
|
|
@@ -68,33 +68,38 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
68
68
|
idField: Z,
|
|
69
69
|
timestampField: ee,
|
|
70
70
|
filesField: te,
|
|
71
|
-
attachmentsField:
|
|
72
|
-
replyToIdField:
|
|
73
|
-
isDeletedField:
|
|
71
|
+
attachmentsField: se,
|
|
72
|
+
replyToIdField: ne,
|
|
73
|
+
isDeletedField: oe,
|
|
74
74
|
isPinnedField: re,
|
|
75
75
|
typingField: ae,
|
|
76
76
|
suggestedActionsField: le,
|
|
77
|
-
...
|
|
78
|
-
} =
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
77
|
+
...Oe
|
|
78
|
+
} = Ie, [i, M] = e.useState(null), [R, Be] = e.useState(!1), [Pe, ie] = e.useState(!1), [ce, ue] = e.useState(null), [c, me] = e.useState(null), x = e.useRef(null), de = e.useRef(null), a = e.useRef(null), fe = e.useRef(null), I = e.useRef(void 0), L = e.useRef(void 0), w = e.useRef(null), pe = e.useRef(""), o = e.useMemo(() => {
|
|
79
|
+
if (!m || m.length === 0)
|
|
80
|
+
return [];
|
|
81
|
+
const t = {
|
|
82
|
+
textField: z,
|
|
83
|
+
statusField: K,
|
|
84
|
+
authorIdField: $,
|
|
85
|
+
authorNameField: J,
|
|
86
|
+
authorImageUrlField: Q,
|
|
87
|
+
authorImageAltTextField: X,
|
|
88
|
+
idField: Z,
|
|
89
|
+
timestampField: ee,
|
|
90
|
+
filesField: te,
|
|
91
|
+
attachmentsField: se,
|
|
92
|
+
replyToIdField: ne,
|
|
93
|
+
isDeletedField: oe,
|
|
94
|
+
isPinnedField: re,
|
|
95
|
+
typingField: ae,
|
|
96
|
+
suggestedActionsField: le
|
|
97
|
+
};
|
|
98
|
+
return !Object.values(t).some((n) => n !== void 0) && ct(m[0]) ? m.map((n) => ({
|
|
99
|
+
...n,
|
|
100
|
+
timestamp: n.timestamp ? new Date(n.timestamp) : n.timestamp
|
|
101
|
+
})) : ut(m, t);
|
|
102
|
+
}, [
|
|
98
103
|
m,
|
|
99
104
|
z,
|
|
100
105
|
K,
|
|
@@ -105,9 +110,9 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
105
110
|
Z,
|
|
106
111
|
ee,
|
|
107
112
|
te,
|
|
113
|
+
se,
|
|
108
114
|
ne,
|
|
109
115
|
oe,
|
|
110
|
-
se,
|
|
111
116
|
re,
|
|
112
117
|
ae,
|
|
113
118
|
le
|
|
@@ -117,164 +122,164 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
117
122
|
me(w.current);
|
|
118
123
|
return;
|
|
119
124
|
}
|
|
120
|
-
if (l &&
|
|
121
|
-
const
|
|
122
|
-
(
|
|
123
|
-
),
|
|
124
|
-
w.current =
|
|
125
|
+
if (l && o.length > 0) {
|
|
126
|
+
const t = o.find(
|
|
127
|
+
(n) => n.author && (n.author.id === l || n.author.id === String(l))
|
|
128
|
+
), s = (t == null ? void 0 : t.author) || { id: l };
|
|
129
|
+
w.current = s, pe.current = l, me(s);
|
|
125
130
|
}
|
|
126
|
-
}, [l,
|
|
127
|
-
const u = e.useMemo(() =>
|
|
131
|
+
}, [l, o]);
|
|
132
|
+
const u = e.useMemo(() => o.length > 0 ? Qe(o) : [], [o]), _e = e.useMemo(() => !ze(Se, { component: "Chat" }), []), He = Ke(Se), ge = e.useMemo(() => o.find((t) => t.isPinned), [o]), he = it(), Ue = e.useCallback(() => {
|
|
128
133
|
clearTimeout(I.current);
|
|
129
|
-
}, []),
|
|
134
|
+
}, []), Ve = e.useCallback(() => {
|
|
130
135
|
I.current = window.setTimeout(() => {
|
|
131
|
-
|
|
136
|
+
M(null);
|
|
132
137
|
}, 0);
|
|
133
|
-
}, []), T = e.useCallback((
|
|
134
|
-
|
|
135
|
-
}, []),
|
|
136
|
-
(
|
|
137
|
-
let
|
|
138
|
-
const
|
|
139
|
-
|
|
138
|
+
}, []), T = e.useCallback((t) => {
|
|
139
|
+
M(t);
|
|
140
|
+
}, []), Ge = e.useCallback(
|
|
141
|
+
(t) => {
|
|
142
|
+
let s = null;
|
|
143
|
+
const n = i !== null ? i : u.lastSelectionIndex;
|
|
144
|
+
t.keyCode === y.up ? n === null ? s = 0 : n > 0 && (s = n - 1) : t.keyCode === y.down ? n === null ? s = 0 : n < u.lastSelectionIndex && (s = n + 1) : t.keyCode === y.home ? s = 0 : t.keyCode === y.end && (s = u.lastSelectionIndex), s !== null && (M(s), t.preventDefault());
|
|
140
145
|
},
|
|
141
146
|
[i, u]
|
|
142
|
-
),
|
|
147
|
+
), f = e.useCallback(() => {
|
|
143
148
|
a.current && (a.current.scrollTop = a.current.scrollHeight - a.current.clientHeight);
|
|
144
149
|
}, []), Te = e.useCallback(() => {
|
|
145
150
|
if (!a.current)
|
|
146
151
|
return !0;
|
|
147
|
-
const { scrollTop:
|
|
148
|
-
return
|
|
152
|
+
const { scrollTop: t, scrollHeight: s, clientHeight: n } = a.current;
|
|
153
|
+
return s - t - n < mt;
|
|
149
154
|
}, []), C = e.useCallback(() => {
|
|
150
155
|
Te() && requestAnimationFrame(() => {
|
|
151
|
-
|
|
156
|
+
f();
|
|
152
157
|
});
|
|
153
|
-
}, [Te,
|
|
158
|
+
}, [Te, f]), Ce = e.useCallback(() => {
|
|
154
159
|
requestAnimationFrame(() => {
|
|
155
|
-
|
|
160
|
+
f();
|
|
156
161
|
});
|
|
157
|
-
}, [
|
|
158
|
-
(
|
|
162
|
+
}, [f]), ye = e.useCallback(
|
|
163
|
+
(t, s, n) => {
|
|
159
164
|
var Ee;
|
|
160
165
|
if (S && S({
|
|
161
|
-
action: { value:
|
|
162
|
-
syntheticEvent:
|
|
163
|
-
nativeEvent:
|
|
164
|
-
target:
|
|
165
|
-
}), !
|
|
166
|
-
switch (
|
|
166
|
+
action: { value: t.value, title: t.title, type: t.type },
|
|
167
|
+
syntheticEvent: s,
|
|
168
|
+
nativeEvent: s.nativeEvent,
|
|
169
|
+
target: s.currentTarget
|
|
170
|
+
}), !s.isDefaultPrevented()) {
|
|
171
|
+
switch (t.type) {
|
|
167
172
|
case "reply":
|
|
168
173
|
p && p({
|
|
169
174
|
message: {
|
|
170
175
|
id: "",
|
|
171
176
|
author: c,
|
|
172
|
-
text:
|
|
177
|
+
text: t.value,
|
|
173
178
|
timestamp: /* @__PURE__ */ new Date()
|
|
174
179
|
},
|
|
175
|
-
syntheticEvent:
|
|
176
|
-
nativeEvent:
|
|
177
|
-
target:
|
|
180
|
+
syntheticEvent: s,
|
|
181
|
+
nativeEvent: s.nativeEvent,
|
|
182
|
+
target: s.currentTarget
|
|
178
183
|
});
|
|
179
184
|
break;
|
|
180
185
|
case "call":
|
|
181
|
-
window.open("tel:" +
|
|
186
|
+
window.open("tel:" + t.value);
|
|
182
187
|
break;
|
|
183
188
|
case "openUrl":
|
|
184
|
-
window.open(
|
|
189
|
+
window.open(t.value);
|
|
185
190
|
break;
|
|
186
191
|
}
|
|
187
|
-
(Ee =
|
|
192
|
+
(Ee = fe.current) == null || Ee.focusInput();
|
|
188
193
|
}
|
|
189
194
|
},
|
|
190
195
|
[S, p, c]
|
|
191
|
-
),
|
|
192
|
-
const
|
|
193
|
-
return u.map((
|
|
194
|
-
|
|
196
|
+
), qe = e.useCallback(() => $e("k-chat", v, { "k-rtl": R }), [v, R]), We = e.useCallback(() => {
|
|
197
|
+
const t = u.length - 1;
|
|
198
|
+
return u.map((s, n) => s.type === "date-marker" ? /* @__PURE__ */ e.createElement(et, { item: s, key: s.trackBy, timestampTemplate: D }) : s.type === "message-group" ? /* @__PURE__ */ e.createElement(
|
|
199
|
+
tt,
|
|
195
200
|
{
|
|
196
|
-
group:
|
|
197
|
-
itemTemplate:
|
|
201
|
+
group: s,
|
|
202
|
+
itemTemplate: F,
|
|
198
203
|
attachmentTemplate: E,
|
|
199
204
|
user: c,
|
|
200
205
|
selectedItemIndex: i,
|
|
201
206
|
onRequestSelection: T,
|
|
202
|
-
isLastGroup:
|
|
203
|
-
key:
|
|
204
|
-
message:
|
|
205
|
-
allowMessageCollapse:
|
|
207
|
+
isLastGroup: n === t,
|
|
208
|
+
key: s.messages[0].selectionIndex,
|
|
209
|
+
message: N,
|
|
210
|
+
allowMessageCollapse: B,
|
|
206
211
|
messageToolbarActions: P,
|
|
207
212
|
messageContextMenuActions: _,
|
|
208
213
|
messageWidthMode: U
|
|
209
214
|
}
|
|
210
|
-
) :
|
|
211
|
-
|
|
215
|
+
) : s.type === "attachment-group" ? /* @__PURE__ */ e.createElement(
|
|
216
|
+
Ze,
|
|
212
217
|
{
|
|
213
|
-
group:
|
|
218
|
+
group: s,
|
|
214
219
|
itemTemplate: E,
|
|
215
220
|
onRequestSelection: T,
|
|
216
|
-
selected:
|
|
217
|
-
isLastGroup:
|
|
218
|
-
key:
|
|
221
|
+
selected: s.selectionIndex === i,
|
|
222
|
+
isLastGroup: n === t,
|
|
223
|
+
key: s.selectionIndex
|
|
219
224
|
}
|
|
220
|
-
) :
|
|
221
|
-
|
|
225
|
+
) : s.type === "action-group" ? /* @__PURE__ */ e.createElement(
|
|
226
|
+
Xe,
|
|
222
227
|
{
|
|
223
|
-
group:
|
|
228
|
+
group: s,
|
|
224
229
|
onActionExecute: ye,
|
|
225
230
|
onRequestSelection: T,
|
|
226
|
-
selected:
|
|
227
|
-
key:
|
|
231
|
+
selected: s.selectionIndex === i,
|
|
232
|
+
key: s.selectionIndex
|
|
228
233
|
}
|
|
229
234
|
) : null);
|
|
230
235
|
}, [
|
|
231
236
|
u,
|
|
232
237
|
D,
|
|
233
|
-
|
|
238
|
+
F,
|
|
234
239
|
E,
|
|
235
240
|
c,
|
|
236
241
|
i,
|
|
237
242
|
T,
|
|
238
|
-
|
|
239
|
-
|
|
243
|
+
N,
|
|
244
|
+
B,
|
|
240
245
|
P,
|
|
241
246
|
_,
|
|
242
247
|
U,
|
|
243
248
|
ye
|
|
244
|
-
]),
|
|
249
|
+
]), je = e.useCallback(() => d ? typeof d == "function" ? d() : d : null, [d]);
|
|
245
250
|
e.useEffect(() => {
|
|
246
|
-
const
|
|
247
|
-
Be(!!
|
|
248
|
-
}, [k]), e.useEffect(() => (L.current = window.setTimeout(() =>
|
|
251
|
+
const t = k !== void 0 ? k === "rtl" : x.current && getComputedStyle(x.current).direction === "rtl";
|
|
252
|
+
Be(!!t);
|
|
253
|
+
}, [k]), e.useEffect(() => (L.current = window.setTimeout(() => f(), dt), () => {
|
|
249
254
|
clearTimeout(L.current);
|
|
250
|
-
}), [
|
|
255
|
+
}), [f]), e.useEffect(() => () => {
|
|
251
256
|
clearTimeout(I.current), clearTimeout(L.current);
|
|
252
257
|
}, []), e.useEffect(() => {
|
|
253
258
|
Ce();
|
|
254
|
-
}, [
|
|
255
|
-
const
|
|
259
|
+
}, [o.length, Ce]), e.useEffect(() => {
|
|
260
|
+
const t = window.setTimeout(() => {
|
|
256
261
|
C();
|
|
257
|
-
},
|
|
262
|
+
}, ft);
|
|
258
263
|
return () => {
|
|
259
|
-
clearTimeout(
|
|
264
|
+
clearTimeout(t);
|
|
260
265
|
};
|
|
261
|
-
}, [
|
|
266
|
+
}, [o, C]), e.useEffect(() => {
|
|
262
267
|
if (h && h.length > 0) {
|
|
263
|
-
const
|
|
268
|
+
const t = window.setTimeout(() => {
|
|
264
269
|
C();
|
|
265
|
-
},
|
|
270
|
+
}, pt);
|
|
266
271
|
return () => {
|
|
267
|
-
clearTimeout(
|
|
272
|
+
clearTimeout(t);
|
|
268
273
|
};
|
|
269
274
|
}
|
|
270
275
|
}, [h, C]);
|
|
271
|
-
const
|
|
276
|
+
const Ye = e.useMemo(
|
|
272
277
|
() => ({
|
|
273
278
|
replyToMessage: ce,
|
|
274
279
|
setReplyToMessage: ue,
|
|
275
|
-
messages:
|
|
280
|
+
messages: o,
|
|
276
281
|
user: c,
|
|
277
|
-
internalScrollContainerRef:
|
|
282
|
+
internalScrollContainerRef: de,
|
|
278
283
|
messageListScrollContainerRef: a,
|
|
279
284
|
onToolbarAction: V,
|
|
280
285
|
onContextMenuAction: G,
|
|
@@ -282,14 +287,14 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
282
287
|
setShowCopyNotification: ie,
|
|
283
288
|
onDownload: W,
|
|
284
289
|
fileActions: H,
|
|
285
|
-
speechToTextConfig:
|
|
286
|
-
uploadConfig:
|
|
287
|
-
statusTemplate:
|
|
290
|
+
speechToTextConfig: j,
|
|
291
|
+
uploadConfig: Y,
|
|
292
|
+
statusTemplate: O
|
|
288
293
|
}),
|
|
289
294
|
[
|
|
290
295
|
ce,
|
|
291
296
|
ue,
|
|
292
|
-
|
|
297
|
+
o,
|
|
293
298
|
c,
|
|
294
299
|
V,
|
|
295
300
|
G,
|
|
@@ -297,78 +302,78 @@ const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
|
|
|
297
302
|
ie,
|
|
298
303
|
W,
|
|
299
304
|
H,
|
|
300
|
-
Y,
|
|
301
305
|
j,
|
|
302
|
-
|
|
306
|
+
Y,
|
|
307
|
+
O
|
|
303
308
|
]
|
|
304
309
|
);
|
|
305
|
-
return /* @__PURE__ */ e.createElement(
|
|
310
|
+
return /* @__PURE__ */ e.createElement(at.Provider, { value: Ye }, /* @__PURE__ */ e.createElement(
|
|
306
311
|
"div",
|
|
307
312
|
{
|
|
308
|
-
style: { width:
|
|
309
|
-
onKeyDown:
|
|
310
|
-
className:
|
|
311
|
-
ref: (
|
|
312
|
-
|
|
313
|
+
style: { width: Le, height: we, position: "relative", overflow: "hidden" },
|
|
314
|
+
onKeyDown: Ge,
|
|
315
|
+
className: qe(),
|
|
316
|
+
ref: (t) => {
|
|
317
|
+
x.current = t, de.current = t, typeof g == "function" ? g(t) : g && (g.current = t);
|
|
313
318
|
},
|
|
314
|
-
...
|
|
319
|
+
...Oe
|
|
315
320
|
},
|
|
316
|
-
|
|
317
|
-
ge && /* @__PURE__ */ e.createElement(
|
|
321
|
+
d !== void 0 && /* @__PURE__ */ e.createElement(nt, null, je()),
|
|
322
|
+
ge && /* @__PURE__ */ e.createElement(ot, { message: ge, onUnpin: Ne, user: c }),
|
|
318
323
|
/* @__PURE__ */ e.createElement(
|
|
319
324
|
"div",
|
|
320
325
|
{
|
|
321
326
|
className: "k-message-list k-avatars",
|
|
322
|
-
onBlur:
|
|
323
|
-
onFocus:
|
|
327
|
+
onBlur: Ve,
|
|
328
|
+
onFocus: Ue,
|
|
324
329
|
role: "log",
|
|
325
330
|
"aria-label": he.toLanguageString(
|
|
326
|
-
|
|
327
|
-
ke
|
|
331
|
+
ke,
|
|
332
|
+
Me[ke]
|
|
328
333
|
),
|
|
329
334
|
"aria-live": "polite",
|
|
330
335
|
ref: a
|
|
331
336
|
},
|
|
332
|
-
/* @__PURE__ */ e.createElement("div", { className: "k-message-list-content" },
|
|
337
|
+
/* @__PURE__ */ e.createElement("div", { className: "k-message-list-content" }, We())
|
|
333
338
|
),
|
|
334
339
|
/* @__PURE__ */ e.createElement(
|
|
335
|
-
|
|
340
|
+
st,
|
|
336
341
|
{
|
|
337
|
-
onSendMessage: (
|
|
342
|
+
onSendMessage: (t, s) => {
|
|
338
343
|
p && p({
|
|
339
|
-
message:
|
|
340
|
-
syntheticEvent:
|
|
341
|
-
nativeEvent:
|
|
342
|
-
target:
|
|
344
|
+
message: t,
|
|
345
|
+
syntheticEvent: s,
|
|
346
|
+
nativeEvent: s.nativeEvent,
|
|
347
|
+
target: s.currentTarget
|
|
343
348
|
});
|
|
344
349
|
},
|
|
345
|
-
onSuggestionClick: (
|
|
346
|
-
|
|
350
|
+
onSuggestionClick: (t) => {
|
|
351
|
+
b && b(t);
|
|
347
352
|
},
|
|
348
|
-
isDirectionRightToLeft:
|
|
349
|
-
ref:
|
|
353
|
+
isDirectionRightToLeft: R,
|
|
354
|
+
ref: fe,
|
|
350
355
|
placeholder: be,
|
|
351
|
-
MessageBox:
|
|
356
|
+
MessageBox: Fe,
|
|
352
357
|
suggestions: h,
|
|
353
358
|
suggestionTemplate: Ae,
|
|
354
|
-
inputValue:
|
|
355
|
-
onInputValueChange: (
|
|
356
|
-
|
|
359
|
+
inputValue: ve,
|
|
360
|
+
onInputValueChange: (t) => {
|
|
361
|
+
A && A(t);
|
|
357
362
|
},
|
|
358
|
-
sendButtonConfig:
|
|
363
|
+
sendButtonConfig: De
|
|
359
364
|
}
|
|
360
365
|
),
|
|
361
|
-
Pe && /* @__PURE__ */ e.createElement(ze, null),
|
|
362
366
|
/* @__PURE__ */ e.createElement(
|
|
363
|
-
|
|
367
|
+
rt,
|
|
364
368
|
{
|
|
365
|
-
show:
|
|
369
|
+
show: Pe,
|
|
366
370
|
text: he.toLanguageString(
|
|
367
371
|
Re,
|
|
368
|
-
|
|
372
|
+
Me[Re]
|
|
369
373
|
)
|
|
370
374
|
}
|
|
371
|
-
)
|
|
375
|
+
),
|
|
376
|
+
_e && /* @__PURE__ */ e.createElement(Je, { message: He })
|
|
372
377
|
));
|
|
373
378
|
});
|
|
374
379
|
xe.displayName = "Chat";
|