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