@progress/kendo-react-conversational-ui 12.0.0-develop.10 → 12.0.0-develop.11

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.
@@ -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 g=require("@progress/kendo-react-common"),r=require("prop-types"),Ge=require("react"),Ke=require("../ViewItem.js"),We=require("./ActionGroup.js"),ze=require("./AttachmentGroup.js"),Ye=require("./DateMarker.js"),$e=require("./MessageGroup.js"),Je=require("./NewMessage.js"),Qe=require("./Header.js"),Xe=require("./elements/PinnedMessage.js"),Ze=require("./Notification.js"),et=require("./ChatContext.js"),tt=require("./ChatMessage.js"),nt=require("../../package-metadata.js"),T=require("../../messages/index.js"),st=require("@progress/kendo-react-intl"),Re=require("../utils/fieldMapping.js");function ot(c){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(c){for(const a in c)if(a!=="default"){const y=Object.getOwnPropertyDescriptor(c,a);Object.defineProperty(l,a,y.get?y:{enumerable:!0,get:()=>c[a]})}}return l.default=c,Object.freeze(l)}const e=ot(Ge),rt=50,at=250,lt=50,it=100,F=e.forwardRef((c,l)=>{const{messages:a=[],messageTemplate:y,attachmentTemplate:M,width:be,height:xe,onSendMessage:C,onSuggestionClick:N,onInputValueChange:v,onActionExecute:R,dir:b,messageBox:Ie,placeholder:Le,className:D,message:O=tt.ChatMessage,authorId:u,suggestions:S,suggestionTemplate:we,inputValue:qe,headerTemplate:p,timestampTemplate:B,statusTemplate:P,allowMessageCollapse:_,messageToolbarActions:V,messageContextMenuActions:H,fileActions:U,onUnpin:Ae,messageWidthMode:j,onToolbarAction:G,onContextMenuAction:K,onFileAction:W,onDownload:z,speechToTextConfig:Y,uploadConfig:$,sendButtonConfig:Fe,textField:J,statusField:Q,authorIdField:X,authorNameField:Z,authorImageUrlField:ee,authorImageAltTextField:te,idField:ne,timestampField:se,filesField:oe,attachmentsField:re,replyToIdField:ae,isDeletedField:le,isPinnedField:ie,typingField:ce,suggestedActionsField:ue,...Ne}=c,[d,x]=e.useState(null),[I,ve]=e.useState(!1),[De,de]=e.useState(!1),[me,fe]=e.useState(null),[m,ge]=e.useState(null),L=e.useRef(null),pe=e.useRef(null),i=e.useRef(null),he=e.useRef(null),w=e.useRef(void 0),q=e.useRef(void 0),A=e.useRef(null),Te=e.useRef(""),o=e.useMemo(()=>{if(!a||a.length===0)return[];if(Re.isStandardMessageFormat(a[0]))return a.map(n=>({...n,timestamp:n.timestamp?new Date(n.timestamp):n.timestamp}));const t={textField:J,statusField:Q,authorIdField:X,authorNameField:Z,authorImageUrlField:ee,authorImageAltTextField:te,idField:ne,timestampField:se,filesField:oe,attachmentsField:re,replyToIdField:ae,isDeletedField:le,isPinnedField:ie,typingField:ce,suggestedActionsField:ue};return Re.mapDataArrayToMessages(a,t)},[a,J,Q,X,Z,ee,te,ne,se,oe,re,ae,le,ie,ce,ue]);e.useEffect(()=>{if(u===Te.current&&A.current){ge(A.current);return}if(u&&o.length>0){const t=o.find(s=>s.author&&(s.author.id===u||s.author.id===String(u))),n=(t==null?void 0:t.author)||{id:u};A.current=n,Te.current=u,ge(n)}},[u,o]);const f=e.useMemo(()=>o.length>0?Ke.convertMsgsToViewItems(o):[],[o]),Oe=e.useMemo(()=>!g.validatePackage(nt.packageMetadata,{component:"Chat"}),[]),ye=e.useMemo(()=>o.find(t=>t.isPinned),[o]),Ce=st.useLocalization(),Be=e.useCallback(()=>{clearTimeout(w.current)},[]),Pe=e.useCallback(()=>{w.current=window.setTimeout(()=>{x(null)},0)},[]),k=e.useCallback(t=>{x(t)},[]),_e=e.useCallback(t=>{let n=null;const s=d!==null?d:f.lastSelectionIndex;t.keyCode===g.Keys.up?s===null?n=0:s>0&&(n=s-1):t.keyCode===g.Keys.down?s===null?n=0:s<f.lastSelectionIndex&&(n=s+1):t.keyCode===g.Keys.home?n=0:t.keyCode===g.Keys.end&&(n=f.lastSelectionIndex),n!==null&&(x(n),t.preventDefault())},[d,f]),h=e.useCallback(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight-i.current.clientHeight)},[]),Se=e.useCallback(()=>{if(!i.current)return!0;const{scrollTop:t,scrollHeight:n,clientHeight:s}=i.current;return n-t-s<rt},[]),E=e.useCallback(()=>{Se()&&requestAnimationFrame(()=>{h()})},[Se,h]),ke=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:m,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,m]),Ve=e.useCallback(()=>g.classNames("k-chat",D,{"k-rtl":I}),[D,I]),He=e.useCallback(()=>{const t=f.length-1;return f.map((n,s)=>n.type==="date-marker"?e.createElement(Ye,{item:n,key:n.trackBy,timestampTemplate:B}):n.type==="message-group"?e.createElement($e,{group:n,itemTemplate:y,attachmentTemplate:M,user:m,selectedItemIndex:d,onRequestSelection:k,isLastGroup:s===t,key:n.messages[0].selectionIndex,message:O,allowMessageCollapse:_,messageToolbarActions:V,messageContextMenuActions:H,messageWidthMode:j}):n.type==="attachment-group"?e.createElement(ze,{group:n,itemTemplate:M,onRequestSelection:k,selected:n.selectionIndex===d,isLastGroup:s===t,key:n.selectionIndex}):n.type==="action-group"?e.createElement(We,{group:n,onActionExecute:Ee,onRequestSelection:k,selected:n.selectionIndex===d,key:n.selectionIndex}):null)},[f,B,y,M,m,d,k,O,_,V,H,j,Ee]),Ue=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";ve(!!t)},[b]),e.useEffect(()=>(q.current=window.setTimeout(()=>h(),at),()=>{clearTimeout(q.current)}),[h]),e.useEffect(()=>()=>{clearTimeout(w.current),clearTimeout(q.current)},[]),e.useEffect(()=>{ke()},[o.length,ke]),e.useEffect(()=>{const t=window.setTimeout(()=>{E()},lt);return()=>{clearTimeout(t)}},[o,E]),e.useEffect(()=>{if(S&&S.length>0){const t=window.setTimeout(()=>{E()},it);return()=>{clearTimeout(t)}}},[S,E]);const je=e.useMemo(()=>({replyToMessage:me,setReplyToMessage:fe,messages:o,user:m,internalScrollContainerRef:pe,messageListScrollContainerRef:i,onToolbarAction:G,onContextMenuAction:K,onFileAction:W,setShowCopyNotification:de,onDownload:z,fileActions:U,speechToTextConfig:Y,uploadConfig:$,statusTemplate:P}),[me,fe,o,m,G,K,W,de,z,U,Y,$,P]);return e.createElement(et.default.Provider,{value:je},e.createElement("div",{style:{width:be,height:xe,position:"relative",overflow:"hidden"},onKeyDown:_e,className:Ve(),ref:t=>{L.current=t,pe.current=t,typeof l=="function"?l(t):l&&(l.current=t)},...Ne},p!==void 0&&e.createElement(Qe,null,Ue()),ye&&e.createElement(Xe,{message:ye,onUnpin:Ae,user:m}),e.createElement("div",{className:"k-message-list k-avatars",onBlur:Pe,onFocus:Be,role:"log","aria-label":Ce.toLanguageString(T.ariaLabelMessageList,T.messages[T.ariaLabelMessageList]),"aria-live":"polite",ref:i},e.createElement("div",{className:"k-message-list-content"},He())),e.createElement(Je,{onSendMessage:(t,n)=>{C&&C({message:t,syntheticEvent:n,nativeEvent:n.nativeEvent,target:n.currentTarget})},onSuggestionClick:t=>{N&&N(t)},isDirectionRightToLeft:I,ref:he,placeholder:Le,MessageBox:Ie,suggestions:S,suggestionTemplate:we,inputValue:qe,onInputValueChange:t=>{v&&v(t)},sendButtonConfig:Fe}),Oe&&e.createElement(g.WatermarkOverlay,null),e.createElement(Ze,{show:De,text:Ce.toLanguageString(T.chatCopyNotification,T.messages[T.chatCopyNotification])})))});F.displayName="Chat";F.propTypes={messages:r.arrayOf(r.object),user:r.object,messageTemplate:r.any,attachmentTemplate:r.any,width:r.oneOfType([r.string,r.number]),onSendMessage:r.func,onActionExecute:r.func,dir:r.string,messageBox:r.any};exports.Chat=F;
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;
@@ -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 Ye, Keys as y, classNames as je, WatermarkOverlay as ze } from "@progress/kendo-react-common";
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 Ke } from "../ViewItem.mjs";
12
- import $e from "./ActionGroup.mjs";
13
- import Je from "./AttachmentGroup.mjs";
14
- import Qe from "./DateMarker.mjs";
15
- import Xe from "./MessageGroup.mjs";
16
- import Ze from "./NewMessage.mjs";
17
- import et from "./Header.mjs";
18
- import tt from "./elements/PinnedMessage.mjs";
19
- import nt from "./Notification.mjs";
20
- import ot from "./ChatContext.mjs";
21
- import { ChatMessage as st } from "./ChatMessage.mjs";
22
- import { packageMetadata as rt } from "../../package-metadata.mjs";
23
- import { ariaLabelMessageList as Se, messages as ke, chatCopyNotification as Re } from "../../messages/index.mjs";
24
- import { useLocalization as at } from "@progress/kendo-react-intl";
25
- import { isStandardMessageFormat as lt, mapDataArrayToMessages as it } from "../utils/fieldMapping.mjs";
26
- const ct = 50, ut = 250, mt = 50, ft = 100, xe = e.forwardRef((Me, g) => {
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: b,
29
+ messageTemplate: F,
30
30
  attachmentTemplate: E,
31
- width: Ie,
32
- height: Le,
31
+ width: Le,
32
+ height: we,
33
33
  onSendMessage: p,
34
- onSuggestionClick: A,
35
- onInputValueChange: F,
34
+ onSuggestionClick: b,
35
+ onInputValueChange: A,
36
36
  onActionExecute: S,
37
37
  dir: k,
38
- messageBox: we,
38
+ messageBox: Fe,
39
39
  placeholder: be,
40
- className: N,
41
- message: v = st,
40
+ className: v,
41
+ message: N = lt,
42
42
  authorId: l,
43
43
  suggestions: h,
44
44
  suggestionTemplate: Ae,
45
- inputValue: Fe,
46
- headerTemplate: f,
45
+ inputValue: ve,
46
+ headerTemplate: d,
47
47
  timestampTemplate: D,
48
- statusTemplate: B,
49
- allowMessageCollapse: O,
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: Y,
60
- uploadConfig: j,
61
- sendButtonConfig: ve,
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: ne,
72
- replyToIdField: oe,
73
- isDeletedField: se,
71
+ attachmentsField: se,
72
+ replyToIdField: ne,
73
+ isDeletedField: oe,
74
74
  isPinnedField: re,
75
75
  typingField: ae,
76
76
  suggestedActionsField: le,
77
- ...De
78
- } = Me, [i, R] = e.useState(null), [x, Be] = e.useState(!1), [Oe, ie] = e.useState(!1), [ce, ue] = e.useState(null), [c, me] = e.useState(null), M = e.useRef(null), fe = e.useRef(null), a = e.useRef(null), de = e.useRef(null), I = e.useRef(void 0), L = e.useRef(void 0), w = e.useRef(null), pe = e.useRef(""), s = e.useMemo(() => !m || m.length === 0 ? [] : lt(m[0]) ? m.map((t) => ({
79
- ...t,
80
- timestamp: t.timestamp ? new Date(t.timestamp) : t.timestamp
81
- })) : it(m, {
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: ne,
92
- replyToIdField: oe,
93
- isDeletedField: se,
94
- isPinnedField: re,
95
- typingField: ae,
96
- suggestedActionsField: le
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 && s.length > 0) {
121
- const n = s.find(
122
- (o) => o.author && (o.author.id === l || o.author.id === String(l))
123
- ), t = (n == null ? void 0 : n.author) || { id: l };
124
- w.current = t, pe.current = l, me(t);
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, s]);
127
- const u = e.useMemo(() => s.length > 0 ? Ke(s) : [], [s]), Pe = e.useMemo(() => !Ye(rt, { component: "Chat" }), []), ge = e.useMemo(() => s.find((n) => n.isPinned), [s]), he = at(), _e = e.useCallback(() => {
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
- }, []), He = e.useCallback(() => {
134
+ }, []), Ve = e.useCallback(() => {
130
135
  I.current = window.setTimeout(() => {
131
- R(null);
136
+ M(null);
132
137
  }, 0);
133
- }, []), T = e.useCallback((n) => {
134
- R(n);
135
- }, []), Ue = e.useCallback(
136
- (n) => {
137
- let t = null;
138
- const o = i !== null ? i : u.lastSelectionIndex;
139
- n.keyCode === y.up ? o === null ? t = 0 : o > 0 && (t = o - 1) : n.keyCode === y.down ? o === null ? t = 0 : o < u.lastSelectionIndex && (t = o + 1) : n.keyCode === y.home ? t = 0 : n.keyCode === y.end && (t = u.lastSelectionIndex), t !== null && (R(t), n.preventDefault());
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
- ), d = e.useCallback(() => {
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: n, scrollHeight: t, clientHeight: o } = a.current;
148
- return t - n - o < ct;
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
- d();
156
+ f();
152
157
  });
153
- }, [Te, d]), Ce = e.useCallback(() => {
158
+ }, [Te, f]), Ce = e.useCallback(() => {
154
159
  requestAnimationFrame(() => {
155
- d();
160
+ f();
156
161
  });
157
- }, [d]), ye = e.useCallback(
158
- (n, t, o) => {
162
+ }, [f]), ye = e.useCallback(
163
+ (t, s, n) => {
159
164
  var Ee;
160
165
  if (S && S({
161
- action: { value: n.value, title: n.title, type: n.type },
162
- syntheticEvent: t,
163
- nativeEvent: t.nativeEvent,
164
- target: t.currentTarget
165
- }), !t.isDefaultPrevented()) {
166
- switch (n.type) {
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: n.value,
177
+ text: t.value,
173
178
  timestamp: /* @__PURE__ */ new Date()
174
179
  },
175
- syntheticEvent: t,
176
- nativeEvent: t.nativeEvent,
177
- target: t.currentTarget
180
+ syntheticEvent: s,
181
+ nativeEvent: s.nativeEvent,
182
+ target: s.currentTarget
178
183
  });
179
184
  break;
180
185
  case "call":
181
- window.open("tel:" + n.value);
186
+ window.open("tel:" + t.value);
182
187
  break;
183
188
  case "openUrl":
184
- window.open(n.value);
189
+ window.open(t.value);
185
190
  break;
186
191
  }
187
- (Ee = de.current) == null || Ee.focusInput();
192
+ (Ee = fe.current) == null || Ee.focusInput();
188
193
  }
189
194
  },
190
195
  [S, p, c]
191
- ), Ve = e.useCallback(() => je("k-chat", N, { "k-rtl": x }), [N, x]), Ge = e.useCallback(() => {
192
- const n = u.length - 1;
193
- return u.map((t, o) => t.type === "date-marker" ? /* @__PURE__ */ e.createElement(Qe, { item: t, key: t.trackBy, timestampTemplate: D }) : t.type === "message-group" ? /* @__PURE__ */ e.createElement(
194
- Xe,
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: t,
197
- itemTemplate: b,
201
+ group: s,
202
+ itemTemplate: F,
198
203
  attachmentTemplate: E,
199
204
  user: c,
200
205
  selectedItemIndex: i,
201
206
  onRequestSelection: T,
202
- isLastGroup: o === n,
203
- key: t.messages[0].selectionIndex,
204
- message: v,
205
- allowMessageCollapse: O,
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
- ) : t.type === "attachment-group" ? /* @__PURE__ */ e.createElement(
211
- Je,
215
+ ) : s.type === "attachment-group" ? /* @__PURE__ */ e.createElement(
216
+ Ze,
212
217
  {
213
- group: t,
218
+ group: s,
214
219
  itemTemplate: E,
215
220
  onRequestSelection: T,
216
- selected: t.selectionIndex === i,
217
- isLastGroup: o === n,
218
- key: t.selectionIndex
221
+ selected: s.selectionIndex === i,
222
+ isLastGroup: n === t,
223
+ key: s.selectionIndex
219
224
  }
220
- ) : t.type === "action-group" ? /* @__PURE__ */ e.createElement(
221
- $e,
225
+ ) : s.type === "action-group" ? /* @__PURE__ */ e.createElement(
226
+ Xe,
222
227
  {
223
- group: t,
228
+ group: s,
224
229
  onActionExecute: ye,
225
230
  onRequestSelection: T,
226
- selected: t.selectionIndex === i,
227
- key: t.selectionIndex
231
+ selected: s.selectionIndex === i,
232
+ key: s.selectionIndex
228
233
  }
229
234
  ) : null);
230
235
  }, [
231
236
  u,
232
237
  D,
233
- b,
238
+ F,
234
239
  E,
235
240
  c,
236
241
  i,
237
242
  T,
238
- v,
239
- O,
243
+ N,
244
+ B,
240
245
  P,
241
246
  _,
242
247
  U,
243
248
  ye
244
- ]), qe = e.useCallback(() => f ? typeof f == "function" ? f() : f : null, [f]);
249
+ ]), je = e.useCallback(() => d ? typeof d == "function" ? d() : d : null, [d]);
245
250
  e.useEffect(() => {
246
- const n = k !== void 0 ? k === "rtl" : M.current && getComputedStyle(M.current).direction === "rtl";
247
- Be(!!n);
248
- }, [k]), e.useEffect(() => (L.current = window.setTimeout(() => d(), ut), () => {
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
- }), [d]), e.useEffect(() => () => {
255
+ }), [f]), e.useEffect(() => () => {
251
256
  clearTimeout(I.current), clearTimeout(L.current);
252
257
  }, []), e.useEffect(() => {
253
258
  Ce();
254
- }, [s.length, Ce]), e.useEffect(() => {
255
- const n = window.setTimeout(() => {
259
+ }, [o.length, Ce]), e.useEffect(() => {
260
+ const t = window.setTimeout(() => {
256
261
  C();
257
- }, mt);
262
+ }, ft);
258
263
  return () => {
259
- clearTimeout(n);
264
+ clearTimeout(t);
260
265
  };
261
- }, [s, C]), e.useEffect(() => {
266
+ }, [o, C]), e.useEffect(() => {
262
267
  if (h && h.length > 0) {
263
- const n = window.setTimeout(() => {
268
+ const t = window.setTimeout(() => {
264
269
  C();
265
- }, ft);
270
+ }, pt);
266
271
  return () => {
267
- clearTimeout(n);
272
+ clearTimeout(t);
268
273
  };
269
274
  }
270
275
  }, [h, C]);
271
- const We = e.useMemo(
276
+ const Ye = e.useMemo(
272
277
  () => ({
273
278
  replyToMessage: ce,
274
279
  setReplyToMessage: ue,
275
- messages: s,
280
+ messages: o,
276
281
  user: c,
277
- internalScrollContainerRef: fe,
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: Y,
286
- uploadConfig: j,
287
- statusTemplate: B
290
+ speechToTextConfig: j,
291
+ uploadConfig: Y,
292
+ statusTemplate: O
288
293
  }),
289
294
  [
290
295
  ce,
291
296
  ue,
292
- s,
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
- B
306
+ Y,
307
+ O
303
308
  ]
304
309
  );
305
- return /* @__PURE__ */ e.createElement(ot.Provider, { value: We }, /* @__PURE__ */ e.createElement(
310
+ return /* @__PURE__ */ e.createElement(at.Provider, { value: Ye }, /* @__PURE__ */ e.createElement(
306
311
  "div",
307
312
  {
308
- style: { width: Ie, height: Le, position: "relative", overflow: "hidden" },
309
- onKeyDown: Ue,
310
- className: Ve(),
311
- ref: (n) => {
312
- M.current = n, fe.current = n, typeof g == "function" ? g(n) : g && (g.current = n);
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
- ...De
319
+ ...Oe
315
320
  },
316
- f !== void 0 && /* @__PURE__ */ e.createElement(et, null, qe()),
317
- ge && /* @__PURE__ */ e.createElement(tt, { message: ge, onUnpin: Ne, user: c }),
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: He,
323
- onFocus: _e,
327
+ onBlur: Ve,
328
+ onFocus: Ue,
324
329
  role: "log",
325
330
  "aria-label": he.toLanguageString(
326
- Se,
327
- ke[Se]
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" }, Ge())
337
+ /* @__PURE__ */ e.createElement("div", { className: "k-message-list-content" }, We())
333
338
  ),
334
339
  /* @__PURE__ */ e.createElement(
335
- Ze,
340
+ st,
336
341
  {
337
- onSendMessage: (n, t) => {
342
+ onSendMessage: (t, s) => {
338
343
  p && p({
339
- message: n,
340
- syntheticEvent: t,
341
- nativeEvent: t.nativeEvent,
342
- target: t.currentTarget
344
+ message: t,
345
+ syntheticEvent: s,
346
+ nativeEvent: s.nativeEvent,
347
+ target: s.currentTarget
343
348
  });
344
349
  },
345
- onSuggestionClick: (n) => {
346
- A && A(n);
350
+ onSuggestionClick: (t) => {
351
+ b && b(t);
347
352
  },
348
- isDirectionRightToLeft: x,
349
- ref: de,
353
+ isDirectionRightToLeft: R,
354
+ ref: fe,
350
355
  placeholder: be,
351
- MessageBox: we,
356
+ MessageBox: Fe,
352
357
  suggestions: h,
353
358
  suggestionTemplate: Ae,
354
- inputValue: Fe,
355
- onInputValueChange: (n) => {
356
- F && F(n);
359
+ inputValue: ve,
360
+ onInputValueChange: (t) => {
361
+ A && A(t);
357
362
  },
358
- sendButtonConfig: ve
363
+ sendButtonConfig: De
359
364
  }
360
365
  ),
361
- Pe && /* @__PURE__ */ e.createElement(ze, null),
362
366
  /* @__PURE__ */ e.createElement(
363
- nt,
367
+ rt,
364
368
  {
365
- show: Oe,
369
+ show: Pe,
366
370
  text: he.toLanguageString(
367
371
  Re,
368
- ke[Re]
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";
@@ -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 ue=require("react"),g=require("@progress/kendo-react-common"),J=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),F=require("@progress/kendo-react-intl"),Q=require("@progress/kendo-react-layout"),c=require("../utils.js"),de=require("./ChatContext.js"),me=require("./elements/FileBox.js"),l=require("../../messages/index.js");function fe(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const m=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(i,s,m.get?m:{enumerable:!0,get:()=>r[s]})}}return i.default=r,Object.freeze(i)}const t=fe(ue),L=t.forwardRef((r,i)=>{const{item:s,template:m,onRequestSelection:T,tabIndex:Z=-1,dateFormat:O="g",selected:o,allowMessageCollapse:b,messageToolbarActions:k,messageContextMenuActions:C,isSender:y}=r,{setReplyToMessage:x,messages:P,user:p,internalScrollContainerRef:h,onToolbarAction:D,onContextMenuAction:N,onFileAction:V,onDownload:d,fileActions:B,setShowCopyNotification:I,statusTemplate:S}=de.useChatContext(),[j,A]=t.useState(!1),[$,z]=t.useState(!1),[E,ee]=t.useState(!0),[te,K]=t.useState(!1),u=F.useLocalization(),W=t.useRef({left:0,top:0}),w=t.useCallback(()=>{s!=null&&s.text&&c.copyToClipboard(s.text),I&&(I(!0),setTimeout(()=>{I(!1)},3e3))},[s,I]),R=t.useCallback(e=>{e.stopPropagation(),ee(a=>!a)},[]),se=t.useCallback(()=>{K(!1)},[]),ae=t.useCallback(e=>{(e.key==="Tab"||e.key==="Enter"||e.key===" "||e.key==="ArrowUp"||e.key==="ArrowDown")&&K(!0)},[]),q=t.useRef(null);t.useEffect(()=>{o&&q.current&&q.current.focus()},[o]);const _=t.useCallback(e=>{W.current={left:e.pageX,top:e.pageY},e.preventDefault(),z(!0),A(!0)},[]),U=t.useCallback(()=>{z(!1),A(!1)},[]),M=t.useCallback((e,a)=>!e.isDeleted&&e.text?e.text:c.getDeletedMessageText(a,u),[u]),X=t.useCallback(e=>{var a;(a=e.item)!=null&&a.text&&(e.item.data.id==="copy"&&!s.isDeleted?w():e.item.data.id==="reply"&&x(s),N&&N(e.item.data,e,s)),A(!1)},[s,N,x,w]),Y=t.useCallback(()=>{if(s.replyToId){const e=c.getMessageById(P,s.replyToId);if(e){const a=n=>{n.preventDefault(),n.stopPropagation();const v=h==null?void 0:h.current;c.scrollToMessageById(e.id,v)};return t.createElement("div",{className:g.classNames("k-message-reference",c.isAuthor(p,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:a},t.createElement("div",{className:"k-message-reference-content"},c.convertTextToLinkedContent(M(e,c.isAuthor(p,e)))))}}return null},[s.replyToId,P,p,M,h]),G=t.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],a=C?[...e.map(n=>C.find(ie=>ie.id===n.id)||n),...C.filter(n=>!e.some(v=>v.id===n.id))]:e;return t.createElement(Q.ContextMenu,{onSelect:X,onClose:U,vertical:!0,show:j,offset:W.current},a.map(n=>n.id==="delete"&&!y?null:t.createElement(Q.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[C,X,U,j,y]),H=t.useCallback(()=>s.files&&s.files.length>1?t.createElement("div",{className:"k-chat-download-button-wrapper"},t.createElement(J.Button,{className:"k-chat-download-button",fillMode:"flat",themeColor:"base",svgIcon:f.downloadIcon,onClick:e=>{e.stopPropagation(),d&&d(s.files,s)},"aria-label":u.toLanguageString(l.downloadAllFiles,l.messages[l.downloadAllFiles])},t.createElement("span",{className:"k-button-text"},u.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[s,d,u]),ne=t.useCallback(()=>{if(s.typing)return t.createElement("div",{className:"k-chat-bubble"},t.createElement("div",{className:"k-typing-indicator"},t.createElement("span",null),t.createElement("span",null),t.createElement("span",null)));if(m){const e=m;return t.createElement(e,{item:s})}else if(s.text||s.files&&s.files.length>0)return t.createElement(t.Fragment,null,t.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":b,"k-expanded":b&&E,"k-selected":o,"k-active":$}),onClick:()=>T(o?void 0:s.selectionIndex),onContextMenu:_},t.createElement("div",{className:"k-bubble-content"},t.createElement("span",{className:"k-chat-bubble-text"},!s.isDeleted&&Y(),c.convertTextToLinkedContent(M(s,c.isAuthor(p,s)))),s.files&&t.createElement(me,{files:s.files,message:s,onFileAction:V,onDownload:e=>d==null?void 0:d(e,s),renderInTextarea:!1,fileActions:B}),H()),b&&t.createElement("span",{className:"k-bubble-expandable-indicator",onClick:R,role:"button","aria-label":E?u.toLanguageString(l.collapseMessage,l.messages[l.collapseMessage]):u.toLanguageString(l.expandMessage,l.messages[l.expandMessage]),tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),R(e))}},t.createElement(g.IconWrap,{icon:E?f.chevronUpIcon:f.chevronDownIcon,size:"medium"}))),G());return null},[s,m,b,E,o,_,Y,M,p,V,B,H,R,u,G,d]),le=t.useCallback(()=>{let e=null;return s.timestamp&&(e=t.createElement("time",{className:"k-message-time","aria-hidden":!o},F.provideIntlService({props:r}).formatDate(s.timestamp,O))),e},[s.timestamp,o,O,r]),oe=t.useCallback(()=>{let e=null;return s.status&&o&&(S?e=t.createElement(S,{item:s}):e=t.createElement("span",{className:"k-message-status"},t.createElement(g.IconWrap,{icon:f.checkCircleIcon,size:"xsmall"}),s.status)),e},[s,o,S]),re=t.useCallback(()=>g.classNames({"k-focus":o,"k-message-removed":s.isDeleted},"k-message"),[o,s.isDeleted]),ce=t.useCallback(()=>k&&k.length>0&&t.createElement("div",{className:"k-chat-message-toolbar k-toolbar k-toolbar-md k-toolbar-flat"},k.map(e=>e.id==="delete"&&!y?null:t.createElement(J.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",themeColor:"base",icon:e.icon,svgIcon:e.svgIcon,onClick:a=>{a.stopPropagation(),e.id==="copy"&&!s.isDeleted?w():e.id==="reply"&&x(s),D&&D(e,a,s)},onMouseDown:a=>a.preventDefault()}))),[w,y,s,k,D,x]);return t.createElement("div",{"data-message-id":s.id,className:re(),tabIndex:Z,onMouseDown:se,onKeyDown:ae,onFocus:e=>{te&&T(s.selectionIndex)},ref:e=>{q.current=e,typeof i=="function"?i(e):i&&(i.current=e)}},le(),ne(),oe(),ce())});L.displayName="ChatMessage";class pe extends t.Component{render(){return t.createElement(L,{...this.props})}}F.registerForIntl(pe);exports.ChatMessage=L;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ue=require("react"),g=require("@progress/kendo-react-common"),J=require("@progress/kendo-react-buttons"),f=require("@progress/kendo-svg-icons"),F=require("@progress/kendo-react-intl"),Q=require("@progress/kendo-react-layout"),c=require("../utils.js"),de=require("./ChatContext.js"),me=require("./elements/FileBox.js"),l=require("../../messages/index.js");function fe(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const m=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(i,s,m.get?m:{enumerable:!0,get:()=>r[s]})}}return i.default=r,Object.freeze(i)}const t=fe(ue),L=t.forwardRef((r,i)=>{const{item:s,template:m,onRequestSelection:T,tabIndex:Z=-1,dateFormat:O="g",selected:o,allowMessageCollapse:b,messageToolbarActions:k,messageContextMenuActions:C,isSender:y}=r,{setReplyToMessage:x,messages:P,user:p,internalScrollContainerRef:h,onToolbarAction:D,onContextMenuAction:N,onFileAction:V,onDownload:d,fileActions:B,setShowCopyNotification:I,statusTemplate:S}=de.useChatContext(),[j,A]=t.useState(!1),[$,z]=t.useState(!1),[E,ee]=t.useState(!0),[te,K]=t.useState(!1),u=F.useLocalization(),W=t.useRef({left:0,top:0}),w=t.useCallback(()=>{s!=null&&s.text&&c.copyToClipboard(s.text),I&&(I(!0),setTimeout(()=>{I(!1)},3e3))},[s,I]),R=t.useCallback(e=>{e.stopPropagation(),ee(a=>!a)},[]),se=t.useCallback(()=>{K(!1)},[]),ae=t.useCallback(e=>{(e.key==="Tab"||e.key==="Enter"||e.key===" "||e.key==="ArrowUp"||e.key==="ArrowDown")&&K(!0)},[]),q=t.useRef(null);t.useEffect(()=>{o&&q.current&&q.current.focus()},[o]);const _=t.useCallback(e=>{W.current={left:e.pageX,top:e.pageY},e.preventDefault(),z(!0),A(!0)},[]),U=t.useCallback(()=>{z(!1),A(!1)},[]),M=t.useCallback((e,a)=>!e.isDeleted&&e.text?e.text:c.getDeletedMessageText(a,u),[u]),X=t.useCallback(e=>{var a;(a=e.item)!=null&&a.text&&(e.item.data.id==="copy"&&!s.isDeleted?w():e.item.data.id==="reply"&&x(s),N&&N(e.item.data,e,s)),A(!1)},[s,N,x,w]),Y=t.useCallback(()=>{if(s.replyToId){const e=c.getMessageById(P,s.replyToId);if(e){const a=n=>{n.preventDefault(),n.stopPropagation();const v=h==null?void 0:h.current;c.scrollToMessageById(e.id,v)};return t.createElement("div",{className:g.classNames("k-message-reference",c.isAuthor(p,e)?"k-message-reference-sender":"k-message-reference-receiver"),onClick:a},t.createElement("div",{className:"k-message-reference-content"},c.convertTextToLinkedContent(M(e,c.isAuthor(p,e)))))}}return null},[s.replyToId,P,p,M,h]),G=t.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:f.undoIcon},{id:"copy",label:"Copy",svgIcon:f.copyIcon}],a=C?[...e.map(n=>C.find(ie=>ie.id===n.id)||n),...C.filter(n=>!e.some(v=>v.id===n.id))]:e;return t.createElement(Q.ContextMenu,{onSelect:X,onClose:U,vertical:!0,show:j,offset:W.current},a.map(n=>n.id==="delete"&&!y?null:t.createElement(Q.MenuItem,{key:n.id,text:n.label,icon:n.icon,svgIcon:n.svgIcon,data:n})))},[C,X,U,j,y]),H=t.useCallback(()=>s.files&&s.files.length>1?t.createElement("div",{className:"k-chat-download-button-wrapper"},t.createElement(J.Button,{className:"k-chat-download-button",fillMode:"flat",themeColor:"base",svgIcon:f.downloadIcon,onClick:e=>{e.stopPropagation(),d&&d(s.files,s)},"aria-label":u.toLanguageString(l.downloadAllFiles,l.messages[l.downloadAllFiles])},t.createElement("span",{className:"k-button-text"},u.toLanguageString(l.downloadAll,l.messages[l.downloadAll])))):null,[s,d,u]),ne=t.useCallback(()=>{if(s.typing)return t.createElement("div",{className:"k-bubble k-chat-bubble"},t.createElement("div",{className:"k-typing-indicator"},t.createElement("span",null),t.createElement("span",null),t.createElement("span",null)));if(m){const e=m;return t.createElement(e,{item:s})}else if(s.text||s.files&&s.files.length>0)return t.createElement(t.Fragment,null,t.createElement("div",{className:g.classNames("k-chat-bubble","k-bubble",{"k-bubble-expandable":b,"k-expanded":b&&E,"k-selected":o,"k-active":$}),onClick:()=>T(o?void 0:s.selectionIndex),onContextMenu:_},t.createElement("div",{className:"k-bubble-content"},t.createElement("span",{className:"k-chat-bubble-text"},!s.isDeleted&&Y(),c.convertTextToLinkedContent(M(s,c.isAuthor(p,s)))),s.files&&t.createElement(me,{files:s.files,message:s,onFileAction:V,onDownload:e=>d==null?void 0:d(e,s),renderInTextarea:!1,fileActions:B}),H()),b&&t.createElement("span",{className:"k-bubble-expandable-indicator",onClick:R,role:"button","aria-label":E?u.toLanguageString(l.collapseMessage,l.messages[l.collapseMessage]):u.toLanguageString(l.expandMessage,l.messages[l.expandMessage]),tabIndex:0,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),R(e))}},t.createElement(g.IconWrap,{icon:E?f.chevronUpIcon:f.chevronDownIcon,size:"medium"}))),G());return null},[s,m,b,E,o,_,Y,M,p,V,B,H,R,u,G,d]),le=t.useCallback(()=>{let e=null;return s.timestamp&&(e=t.createElement("time",{className:"k-message-time","aria-hidden":!o},F.provideIntlService({props:r}).formatDate(s.timestamp,O))),e},[s.timestamp,o,O,r]),oe=t.useCallback(()=>{let e=null;return s.status&&o&&(S?e=t.createElement(S,{item:s}):e=t.createElement("span",{className:"k-message-status"},t.createElement(g.IconWrap,{icon:f.checkCircleIcon,size:"xsmall"}),s.status)),e},[s,o,S]),re=t.useCallback(()=>g.classNames({"k-focus":o,"k-message-removed":s.isDeleted},"k-message"),[o,s.isDeleted]),ce=t.useCallback(()=>k&&k.length>0&&t.createElement("div",{className:"k-chat-message-toolbar k-toolbar k-toolbar-md k-toolbar-flat"},k.map(e=>e.id==="delete"&&!y?null:t.createElement(J.Button,{key:e.id,fillMode:"flat",className:"k-toolbar-button",themeColor:"base",icon:e.icon,svgIcon:e.svgIcon,onClick:a=>{a.stopPropagation(),e.id==="copy"&&!s.isDeleted?w():e.id==="reply"&&x(s),D&&D(e,a,s)},onMouseDown:a=>a.preventDefault()}))),[w,y,s,k,D,x]);return t.createElement("div",{"data-message-id":s.id,className:re(),tabIndex:Z,onMouseDown:se,onKeyDown:ae,onFocus:e=>{te&&T(s.selectionIndex)},ref:e=>{q.current=e,typeof i=="function"?i(e):i&&(i.current=e)}},le(),ne(),oe(),ce())});L.displayName="ChatMessage";class pe extends t.Component{render(){return t.createElement(L,{...this.props})}}F.registerForIntl(pe);exports.ChatMessage=L;