@progress/kendo-react-conversational-ui 12.2.1-develop.1 → 12.3.0-develop.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/chat/components/ActionGroup.js +1 -1
  2. package/chat/components/ActionGroup.mjs +55 -34
  3. package/chat/components/Attachment.js +1 -1
  4. package/chat/components/Attachment.mjs +16 -9
  5. package/chat/components/Chat.js +1 -1
  6. package/chat/components/Chat.mjs +359 -278
  7. package/chat/components/ChatMessage.js +1 -1
  8. package/chat/components/ChatMessage.mjs +159 -147
  9. package/chat/components/Header.js +1 -1
  10. package/chat/components/Header.mjs +1 -1
  11. package/chat/components/MessageGroup.js +1 -1
  12. package/chat/components/MessageGroup.mjs +82 -61
  13. package/chat/components/NewMessage.js +1 -1
  14. package/chat/components/NewMessage.mjs +63 -59
  15. package/chat/components/ScrollButtonsWrapper.js +8 -0
  16. package/chat/components/ScrollButtonsWrapper.mjs +58 -0
  17. package/chat/components/SuggestionsGroup.js +1 -1
  18. package/chat/components/SuggestionsGroup.mjs +58 -18
  19. package/chat/components/elements/FileBox.js +1 -1
  20. package/chat/components/elements/FileBox.mjs +31 -37
  21. package/chat/components/elements/PinnedMessage.js +1 -1
  22. package/chat/components/elements/PinnedMessage.mjs +5 -4
  23. package/chat/hooks/useScrollWithButtons.js +8 -0
  24. package/chat/hooks/useScrollWithButtons.mjs +46 -0
  25. package/chat/utils/fieldMapping.js +1 -1
  26. package/chat/utils/fieldMapping.mjs +1 -1
  27. package/chat/utils/messageSettings.js +8 -0
  28. package/chat/utils/messageSettings.mjs +31 -0
  29. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  30. package/index.d.mts +199 -5
  31. package/index.d.ts +199 -5
  32. package/messages/index.js +1 -1
  33. package/messages/index.mjs +26 -22
  34. package/package-metadata.js +1 -1
  35. package/package-metadata.mjs +2 -2
  36. package/package.json +11 -11
@@ -5,84 +5,105 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as e from "react";
9
- import { classNames as G } from "@progress/kendo-react-common";
10
- import { Avatar as L } from "@progress/kendo-react-layout";
11
- import R from "./Attachment.mjs";
12
- import { isAuthor as k } from "../utils.mjs";
13
- import { useLocalization as b } from "@progress/kendo-react-intl";
14
- import { avatarAlt as M, messages as z } from "../../messages/index.mjs";
15
- const B = (x) => {
8
+ import * as t from "react";
9
+ import { classNames as z } from "@progress/kendo-react-common";
10
+ import { Avatar as R } from "@progress/kendo-react-layout";
11
+ import q from "./Attachment.mjs";
12
+ import { isAuthor as x } from "../utils.mjs";
13
+ import { useChatContext as V } from "./ChatContext.mjs";
14
+ import { useLocalization as W } from "@progress/kendo-react-intl";
15
+ import { avatarAlt as S, messages as $ } from "../../messages/index.mjs";
16
+ const O = (N) => {
16
17
  const {
17
18
  group: a,
18
- user: s,
19
- itemTemplate: n,
20
- attachmentTemplate: m,
21
- onRequestSelection: l,
22
- selectedItemIndex: c,
23
- isLastGroup: i,
24
- message: u,
25
- allowMessageCollapse: g,
26
- messageToolbarActions: p,
27
- messageContextMenuActions: d,
28
- messageWidthMode: h = "standard"
29
- } = x, E = b(), r = a.messages.length > 0 && k(s, a.messages[0]), o = !r, I = e.useMemo(
30
- () => G("k-message-group", {
31
- "k-message-group-sender k-no-avatar": r,
32
- "k-message-group-receiver": o,
33
- "k-message-group-full-width": h === "full"
19
+ user: n,
20
+ itemTemplate: l,
21
+ contentTemplate: c,
22
+ attachmentTemplate: i,
23
+ onRequestSelection: u,
24
+ selectedItemIndex: g,
25
+ isLastGroup: p,
26
+ message: d,
27
+ allowMessageCollapse: h,
28
+ messageToolbarActions: f,
29
+ messageContextMenuActions: v,
30
+ fileActions: k,
31
+ messageWidthMode: A = "standard",
32
+ showAvatar: m = !0,
33
+ showUsername: T = !0
34
+ } = N, { userStatusTemplate: E } = V(), w = W(), o = a.messages.length > 0 && x(n, a.messages[0]), { avatarUrl: s, avatarAltText: I, name: C } = a.author, G = t.useMemo(
35
+ () => z("k-message-group", {
36
+ "k-message-group-sender": o,
37
+ "k-message-group-receiver": !o,
38
+ "k-message-group-full-width": A === "full",
39
+ "k-no-avatar": !m || !s
34
40
  }),
35
- [r, o, h]
36
- ), S = () => {
37
- if (!(!o || !f))
38
- return /* @__PURE__ */ e.createElement(L, { type: "image" }, /* @__PURE__ */ e.createElement("img", { src: f, alt: T }));
39
- }, N = e.useMemo(() => {
40
- const w = a.messages.length - 1;
41
- return a.messages.map((t, y) => {
42
- const A = [
43
- /* @__PURE__ */ e.createElement(
44
- u,
41
+ [o, A, m, s]
42
+ ), y = () => {
43
+ if (!m || !s)
44
+ return;
45
+ const r = /* @__PURE__ */ t.createElement(R, { type: "image" }, /* @__PURE__ */ t.createElement("img", { src: s, alt: U }));
46
+ if (E) {
47
+ const e = a.messages[a.messages.length - 1];
48
+ return /* @__PURE__ */ t.createElement("div", { className: "k-chat-user-status-wrapper" }, r, /* @__PURE__ */ t.createElement("div", { className: "k-chat-user-status" }, /* @__PURE__ */ t.createElement(
49
+ E,
50
+ {
51
+ message: "dataItem" in e ? e.dataItem : e
52
+ }
53
+ )));
54
+ }
55
+ return r;
56
+ }, L = t.useMemo(() => {
57
+ const r = a.messages.length - 1;
58
+ return a.messages.map((e, b) => {
59
+ const M = [
60
+ /* @__PURE__ */ t.createElement(
61
+ d,
45
62
  {
46
- item: t,
47
- template: n,
48
- selected: t.selectionIndex === c,
49
- onRequestSelection: l,
50
- tabIndex: y === w && i ? 0 : -1,
51
- key: t.id,
52
- allowMessageCollapse: g,
53
- messageToolbarActions: p,
54
- messageContextMenuActions: d,
55
- isSender: k(s, t)
63
+ item: e,
64
+ template: l,
65
+ contentTemplate: c,
66
+ selected: e.selectionIndex === g,
67
+ onRequestSelection: u,
68
+ tabIndex: b === r && p ? 0 : -1,
69
+ key: e.id,
70
+ allowMessageCollapse: h,
71
+ messageToolbarActions: f,
72
+ messageContextMenuActions: v,
73
+ fileActions: k,
74
+ isSender: x(n, e)
56
75
  }
57
76
  )
58
77
  ];
59
- return t.attachments && t.attachments.length === 1 && A.push(
60
- /* @__PURE__ */ e.createElement(
61
- R,
78
+ return e.attachments && e.attachments.length === 1 && M.push(
79
+ /* @__PURE__ */ t.createElement(
80
+ q,
62
81
  {
63
- item: t.attachments[0],
64
- template: m,
82
+ item: e.attachments[0],
83
+ template: i,
65
84
  selected: !1,
66
- key: `att-${t.attachments[0].content}`
85
+ key: `att-${e.attachments[0].content}`
67
86
  }
68
87
  )
69
- ), A;
88
+ ), M;
70
89
  });
71
90
  }, [
72
91
  a.messages,
73
- u,
74
- n,
75
- c,
92
+ d,
76
93
  l,
77
- i,
94
+ c,
78
95
  g,
96
+ u,
79
97
  p,
80
- d,
81
- s,
82
- m
83
- ]), { avatarUrl: f, avatarAltText: v, name: C } = a.author, T = v !== void 0 ? v : E.toLanguageString(M, z[M]);
84
- return /* @__PURE__ */ e.createElement("div", { className: I }, S(), /* @__PURE__ */ e.createElement("div", { className: "k-message-group-content" }, /* @__PURE__ */ e.createElement("span", { className: "k-message-author" }, C), N));
98
+ h,
99
+ f,
100
+ v,
101
+ k,
102
+ n,
103
+ i
104
+ ]), U = I !== void 0 ? I : w.toLanguageString(S, $[S]);
105
+ return /* @__PURE__ */ t.createElement("div", { className: G }, y(), /* @__PURE__ */ t.createElement("div", { className: "k-message-group-content" }, T && /* @__PURE__ */ t.createElement("span", { className: "k-message-author" }, C), L));
85
106
  };
86
107
  export {
87
- B as default
108
+ O as default
88
109
  };
@@ -5,4 +5,4 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- "use strict";const D=require("@progress/kendo-react-common"),ue=require("react"),I=require("@progress/kendo-react-buttons"),ie=require("@progress/kendo-react-upload"),fe=require("./SuggestionsGroup.js"),ne=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),ge=require("./ChatContext.js"),pe=require("@progress/kendo-react-intl"),se=require("../utils.js"),s=require("../../messages/index.js"),me=require("./elements/FileBox.js");function de(p){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const f in p)if(f!=="default"){const b=Object.getOwnPropertyDescriptor(p,f);Object.defineProperty(k,f,b.get?b:{enumerable:!0,get:()=>p[f]})}}return k.default=p,Object.freeze(k)}const e=de(ue),ae=e.forwardRef((p,k)=>{const{onSendMessage:f,isDirectionRightToLeft:b,placeholder:q,MessageBox:z,suggestions:R,onSuggestionClick:oe,inputValue:S,onInputValueChange:d,suggestionTemplate:le,sendButtonConfig:j,onInputClick:L}=p,{replyToMessage:a,setReplyToMessage:x,user:E,messageListScrollContainerRef:m,speechToTextConfig:y,uploadConfig:o}=ge.useChatContext(),[P]=e.useState(!1),[l,M]=e.useState(void 0),[r,B]=e.useState([]),[K,O]=e.useState(!1),h=e.useRef(null),N=e.useRef(null),c=pe.useLocalization(),g=e.useCallback(()=>{h.current!==null&&h.current.focus()},[]);e.useEffect(()=>{S!==void 0&&S!==l&&(M(S),g())},[S,l,g]),e.useEffect(()=>{a&&g()},[a,g]),e.useLayoutEffect(()=>{K&&(m!=null&&m.current)&&(m.current.scrollTop=m.current.scrollHeight-m.current.clientHeight,O(!1))},[K,m]);const U=e.useCallback(t=>{const n=t.value;M(n),d&&d(n)},[d]),C=e.useMemo(()=>!!(l!=null&&l.trim()||o!==!1&&r.length>0),[l,r.length,o]),w=e.useCallback(t=>{if(t.preventDefault(),f){const n=l;if(C){const u={id:"",author:E,text:n||"",timestamp:new Date,replyToId:a?a.id:void 0,files:r.map(i=>({name:i.name,size:i.size,type:i.extension,rawFile:i.getRawFile?i.getRawFile():i}))};x(null),f(u,t),B([]),M(""),d&&d(""),O(!0)}}},[f,l,E,a,r,x,d,C]),A=e.useCallback(t=>{if(!(t.key==="Enter"&&t.shiftKey))switch(t.key){case"Enter":return t.preventDefault(),w(t);case"Escape":h.current&&h.current.blur();break;default:return}},[w]);e.useImperativeHandle(k,()=>({focusInput:g}),[g]);const H=e.useCallback(t=>{B(n=>n.filter(u=>u.name!==t))},[]),V=e.useCallback(()=>o===!1?null:e.createElement(me,{files:r,onFileRemove:H,renderInTextarea:!0}),[r,H,o]),_=e.useCallback((t,n)=>t.isDeleted?se.getDeletedMessageText(n,c):t.text,[c]),G=e.useCallback(()=>{if(a){const t=se.isAuthor(E,a);return e.createElement("div",{className:D.classNames("k-message-reference",t?"k-message-reference-sender":"k-message-reference-receiver")},e.createElement("div",{className:"k-message-reference-content"},_(a,t)),e.createElement("span",{className:"k-spacer"}),e.createElement(I.Button,{fillMode:"flat",themeColor:"base",svgIcon:F.xIcon,onClick:()=>x(null),"aria-label":c.toLanguageString(s.closeReply,s.messages[s.closeReply])}))}return null},[a,E,_,x,c]),$=e.useCallback(t=>{try{const n=Array.from(t.newState);B(u=>[...u,...n]),g()}catch{}},[g]),J=e.useCallback(()=>{N.current&&o!==!1&&N.current.actionElement.click()},[o]),Q=e.useCallback(t=>{},[]),W=e.useCallback(t=>{const{isFinal:n,alternatives:u}=t;if(u.length>0){const i=u[0];n&&M(T=>(T?`${T} `:"")+i.transcript)}},[]),X=e.useCallback(()=>e.createElement(e.Fragment,null,r.length>0&&V(),a&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},G())),[r.length,a,V,G]),Y=e.useCallback(t=>{t.preventDefault()},[]),Z=e.useCallback(t=>{t.key==="Escape"&&t.currentTarget.blur()},[]),v=e.useMemo(()=>e.createElement(I.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:F.paperPlaneIcon,onClick:w,onMouseDown:Y,onKeyDown:Z,"aria-label":c.toLanguageString(s.newMessageSendButton,s.messages[s.newMessageSendButton]),dir:b?"rtl":void 0,disabled:!C,"aria-disabled":!C,...j}),[w,Y,Z,c,b,C,j]),ee=e.useCallback(()=>{const t=typeof y=="object"?y:void 0,n=typeof o=="object"?o:{},{className:u,...i}=n,T=D.classNames("k-hidden",u),re=o!==!1,ce=y!==!1;return e.createElement(ne.InputSuffix,null,ce&&e.createElement(I.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:Q,onResult:W,...t}),re&&e.createElement(e.Fragment,null,e.createElement(I.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:F.paperclipIcon,onClick:J,"aria-label":c.toLanguageString(s.attachFile,s.messages[s.attachFile])}),e.createElement(ie.Upload,{ref:N,files:r,onAdd:$,multiple:!0,autoUpload:!1,...i,className:T})),e.createElement("span",{className:"k-spacer"}),v)},[y,o,r,Q,W,J,$,c,v]),te=e.useMemo(()=>e.createElement(ne.TextArea,{className:D.classNames("k-message-box","!k-flex-col",{"k-focus":P}),resizable:"none",rows:1,placeholder:q,value:l,onChange:U,onKeyDown:A,onClick:L,prefix:X,suffix:ee,ref:h,"aria-label":c.toLanguageString(s.newMessageMessageInput,s.messages[s.newMessageMessageInput])}),[P,q,l,U,A,L,X,ee,c]);return e.createElement("div",{className:"k-message-box-wrapper"},R&&R.length>0&&e.createElement(fe.SuggestionGroup,{onSuggestionClick:oe,suggestions:R,suggestionTemplate:le}),z?e.createElement(z,{messageInput:te,sendButton:v}):te)});ae.displayName="NewMessage";module.exports=ae;
8
+ "use strict";const D=require("@progress/kendo-react-common"),fe=require("react"),I=require("@progress/kendo-react-buttons"),ge=require("@progress/kendo-react-upload"),pe=require("./SuggestionsGroup.js"),ne=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),de=require("./ChatContext.js"),me=require("@progress/kendo-react-intl"),se=require("../utils.js"),s=require("../../messages/index.js"),ke=require("./elements/FileBox.js");function be(p){const k=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(p){for(const f in p)if(f!=="default"){const b=Object.getOwnPropertyDescriptor(p,f);Object.defineProperty(k,f,b.get?b:{enumerable:!0,get:()=>p[f]})}}return k.default=p,Object.freeze(k)}const e=be(fe),ae=e.forwardRef((p,k)=>{const{onSendMessage:f,isDirectionRightToLeft:b,placeholder:q,MessageBox:z,suggestions:R,onSuggestionClick:oe,inputValue:S,onInputValueChange:m,suggestionTemplate:le,sendButtonConfig:L,onInputClick:j,suggestionsLayout:re,dir:ce}=p,{replyToMessage:a,setReplyToMessage:x,user:E,messageListScrollContainerRef:d,speechToTextConfig:y,uploadConfig:o}=de.useChatContext(),[P]=e.useState(!1),[l,M]=e.useState(void 0),[r,B]=e.useState([]),[K,O]=e.useState(!1),h=e.useRef(null),N=e.useRef(null),c=me.useLocalization(),g=e.useCallback(()=>{h.current!==null&&h.current.focus()},[]);e.useEffect(()=>{S!==void 0&&S!==l&&(M(S),g())},[S,l,g]),e.useEffect(()=>{a&&g()},[a,g]),e.useLayoutEffect(()=>{K&&(d!=null&&d.current)&&(d.current.scrollTop=d.current.scrollHeight-d.current.clientHeight,O(!1))},[K,d]);const U=e.useCallback(t=>{const n=t.value;M(n),m&&m(n)},[m]),C=e.useMemo(()=>!!(l!=null&&l.trim()||o!==!1&&r.length>0),[l,r.length,o]),w=e.useCallback(t=>{if(t.preventDefault(),f){const n=l;if(C){const u={id:"",author:E,text:n||"",timestamp:new Date,replyToId:a?a.id:void 0,files:r.map(i=>({name:i.name,size:i.size,type:i.extension,rawFile:i.getRawFile?i.getRawFile():i}))};x(null),f(u,t),B([]),M(""),m&&m(""),O(!0)}}},[f,l,E,a,r,x,m,C]),A=e.useCallback(t=>{if(!(t.key==="Enter"&&t.shiftKey))switch(t.key){case"Enter":return t.preventDefault(),w(t);case"Escape":h.current&&h.current.blur();break;default:return}},[w]);e.useImperativeHandle(k,()=>({focusInput:g}),[g]);const H=e.useCallback(t=>{B(n=>n.filter(u=>u.name!==t))},[]),V=e.useCallback(()=>o===!1?null:e.createElement(ke,{files:r,onFileRemove:H,renderInTextarea:!0}),[r,H,o]),_=e.useCallback((t,n)=>t.isDeleted?se.getDeletedMessageText(n,c):t.text,[c]),G=e.useCallback(()=>{if(a){const t=se.isAuthor(E,a);return e.createElement("div",{className:D.classNames("k-message-reference",t?"k-message-reference-sender":"k-message-reference-receiver")},e.createElement("div",{className:"k-message-reference-content"},_(a,t)),e.createElement("span",{className:"k-spacer"}),e.createElement(I.Button,{fillMode:"flat",themeColor:"base",svgIcon:F.xIcon,onClick:()=>x(null),"aria-label":c.toLanguageString(s.closeReply,s.messages[s.closeReply])}))}return null},[a,E,_,x,c]),$=e.useCallback(t=>{try{const n=Array.from(t.newState);B(u=>[...u,...n]),g()}catch{}},[g]),J=e.useCallback(()=>{N.current&&o!==!1&&N.current.actionElement.click()},[o]),Q=e.useCallback(t=>{},[]),W=e.useCallback(t=>{const{isFinal:n,alternatives:u}=t;if(u.length>0){const i=u[0];n&&M(T=>(T?`${T} `:"")+i.transcript)}},[]),X=e.useCallback(()=>e.createElement(e.Fragment,null,r.length>0&&V(),a&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},G())),[r.length,a,V,G]),Y=e.useCallback(t=>{t.preventDefault()},[]),Z=e.useCallback(t=>{t.key==="Escape"&&t.currentTarget.blur()},[]),v=e.useMemo(()=>e.createElement(I.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:F.paperPlaneIcon,onClick:w,onMouseDown:Y,onKeyDown:Z,"aria-label":c.toLanguageString(s.newMessageSendButton,s.messages[s.newMessageSendButton]),dir:b?"rtl":void 0,disabled:!C,"aria-disabled":!C,...L}),[w,Y,Z,c,b,C,L]),ee=e.useCallback(()=>{const t=typeof y=="object"?y:void 0,n=typeof o=="object"?o:{},{className:u,...i}=n,T=D.classNames("k-hidden",u),ue=o!==!1,ie=y!==!1;return e.createElement(ne.InputSuffix,null,ie&&e.createElement(I.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:Q,onResult:W,...t}),ue&&e.createElement(e.Fragment,null,e.createElement(I.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:F.paperclipIcon,onClick:J,"aria-label":c.toLanguageString(s.attachFile,s.messages[s.attachFile])}),e.createElement(ge.Upload,{ref:N,files:r,onAdd:$,multiple:!0,autoUpload:!1,...i,className:T})),e.createElement("span",{className:"k-spacer"}),v)},[y,o,r,Q,W,J,$,c,v]),te=e.useMemo(()=>e.createElement(ne.TextArea,{className:D.classNames("k-message-box","!k-flex-col",{"k-focus":P}),resizable:"none",rows:1,placeholder:q,value:l,onChange:U,onKeyDown:A,onClick:j,prefix:X,suffix:ee,ref:h,"aria-label":c.toLanguageString(s.newMessageMessageInput,s.messages[s.newMessageMessageInput])}),[P,q,l,U,A,j,X,ee,c]);return e.createElement("div",{className:"k-message-box-wrapper"},R&&R.length>0&&e.createElement(pe.SuggestionGroup,{onSuggestionClick:oe,suggestions:R,suggestionTemplate:le,suggestionsLayout:re,dir:ce}),z?e.createElement(z,{messageInput:te,sendButton:v}):te)});ae.displayName="NewMessage";module.exports=ae;
@@ -7,43 +7,45 @@
7
7
  */
8
8
  import { classNames as v } from "@progress/kendo-react-common";
9
9
  import * as e from "react";
10
- import { Button as N, SpeechToTextButton as ue } from "@progress/kendo-react-buttons";
11
- import { Upload as ie } from "@progress/kendo-react-upload";
12
- import { SuggestionGroup as fe } from "./SuggestionsGroup.mjs";
13
- import { InputSuffix as me, TextArea as pe } from "@progress/kendo-react-inputs";
14
- import { xIcon as ge, paperPlaneIcon as de, paperclipIcon as ke } from "@progress/kendo-svg-icons";
15
- import { useChatContext as he } from "./ChatContext.mjs";
16
- import { useLocalization as Ce } from "@progress/kendo-react-intl";
17
- import { getDeletedMessageText as be, isAuthor as xe } from "../utils.mjs";
18
- import { closeReply as _, messages as S, newMessageSendButton as ee, attachFile as te, newMessageMessageInput as ne } from "../../messages/index.mjs";
19
- import Ee from "./elements/FileBox.mjs";
20
- const Se = e.forwardRef((se, ae) => {
10
+ import { Button as N, SpeechToTextButton as fe } from "@progress/kendo-react-buttons";
11
+ import { Upload as me } from "@progress/kendo-react-upload";
12
+ import { SuggestionGroup as pe } from "./SuggestionsGroup.mjs";
13
+ import { InputSuffix as ge, TextArea as de } from "@progress/kendo-react-inputs";
14
+ import { xIcon as ke, paperPlaneIcon as he, paperclipIcon as Ce } from "@progress/kendo-svg-icons";
15
+ import { useChatContext as be } from "./ChatContext.mjs";
16
+ import { useLocalization as xe } from "@progress/kendo-react-intl";
17
+ import { getDeletedMessageText as Ee, isAuthor as Se } from "../utils.mjs";
18
+ import { closeReply as _, messages as S, newMessageSendButton as ee, attachFile as te, newMessageMessageInput as se } from "../../messages/index.mjs";
19
+ import ye from "./elements/FileBox.mjs";
20
+ const Te = e.forwardRef((ne, ae) => {
21
21
  const {
22
- onSendMessage: T,
22
+ onSendMessage: y,
23
23
  isDirectionRightToLeft: B,
24
24
  placeholder: F,
25
25
  MessageBox: R,
26
- suggestions: y,
26
+ suggestions: T,
27
27
  onSuggestionClick: oe,
28
28
  inputValue: d,
29
29
  onInputValueChange: m,
30
30
  suggestionTemplate: le,
31
31
  sendButtonConfig: D,
32
- onInputClick: z
33
- } = se, { replyToMessage: s, setReplyToMessage: k, user: h, messageListScrollContainerRef: f, speechToTextConfig: C, uploadConfig: a } = he(), [L] = e.useState(!1), [o, b] = e.useState(void 0), [l, M] = e.useState([]), [K, A] = e.useState(!1), p = e.useRef(null), w = e.useRef(null), r = Ce(), i = e.useCallback(() => {
32
+ onInputClick: L,
33
+ suggestionsLayout: re,
34
+ dir: ce
35
+ } = ne, { replyToMessage: n, setReplyToMessage: k, user: h, messageListScrollContainerRef: f, speechToTextConfig: C, uploadConfig: a } = be(), [z] = e.useState(!1), [o, b] = e.useState(void 0), [l, M] = e.useState([]), [K, A] = e.useState(!1), p = e.useRef(null), w = e.useRef(null), r = xe(), i = e.useCallback(() => {
34
36
  p.current !== null && p.current.focus();
35
37
  }, []);
36
38
  e.useEffect(() => {
37
39
  d !== void 0 && d !== o && (b(d), i());
38
40
  }, [d, o, i]), e.useEffect(() => {
39
- s && i();
40
- }, [s, i]), e.useLayoutEffect(() => {
41
+ n && i();
42
+ }, [n, i]), e.useLayoutEffect(() => {
41
43
  K && (f != null && f.current) && (f.current.scrollTop = f.current.scrollHeight - f.current.clientHeight, A(!1));
42
44
  }, [K, f]);
43
45
  const P = e.useCallback(
44
46
  (t) => {
45
- const n = t.value;
46
- b(n), m && m(n);
47
+ const s = t.value;
48
+ b(s), m && m(s);
47
49
  },
48
50
  [m]
49
51
  ), g = e.useMemo(
@@ -51,15 +53,15 @@ const Se = e.forwardRef((se, ae) => {
51
53
  [o, l.length, a]
52
54
  ), x = e.useCallback(
53
55
  (t) => {
54
- if (t.preventDefault(), T) {
55
- const n = o;
56
+ if (t.preventDefault(), y) {
57
+ const s = o;
56
58
  if (g) {
57
59
  const c = {
58
60
  id: "",
59
61
  author: h,
60
- text: n || "",
62
+ text: s || "",
61
63
  timestamp: /* @__PURE__ */ new Date(),
62
- replyToId: s ? s.id : void 0,
64
+ replyToId: n ? n.id : void 0,
63
65
  files: l.map((u) => ({
64
66
  name: u.name,
65
67
  size: u.size,
@@ -67,15 +69,15 @@ const Se = e.forwardRef((se, ae) => {
67
69
  rawFile: u.getRawFile ? u.getRawFile() : u
68
70
  }))
69
71
  };
70
- k(null), T(c, t), M([]), b(""), m && m(""), A(!0);
72
+ k(null), y(c, t), M([]), b(""), m && m(""), A(!0);
71
73
  }
72
74
  }
73
75
  },
74
76
  [
75
- T,
77
+ y,
76
78
  o,
77
79
  h,
78
- s,
80
+ n,
79
81
  l,
80
82
  k,
81
83
  m,
@@ -104,13 +106,13 @@ const Se = e.forwardRef((se, ae) => {
104
106
  [i]
105
107
  );
106
108
  const H = e.useCallback((t) => {
107
- M((n) => n.filter((c) => c.name !== t));
108
- }, []), V = e.useCallback(() => a === !1 ? null : /* @__PURE__ */ e.createElement(Ee, { files: l, onFileRemove: H, renderInTextarea: !0 }), [l, H, a]), j = e.useCallback(
109
- (t, n) => t.isDeleted ? be(n, r) : t.text,
109
+ M((s) => s.filter((c) => c.name !== t));
110
+ }, []), V = e.useCallback(() => a === !1 ? null : /* @__PURE__ */ e.createElement(ye, { files: l, onFileRemove: H, renderInTextarea: !0 }), [l, H, a]), j = e.useCallback(
111
+ (t, s) => t.isDeleted ? Ee(s, r) : t.text,
110
112
  [r]
111
113
  ), G = e.useCallback(() => {
112
- if (s) {
113
- const t = xe(h, s);
114
+ if (n) {
115
+ const t = Se(h, n);
114
116
  return /* @__PURE__ */ e.createElement(
115
117
  "div",
116
118
  {
@@ -119,14 +121,14 @@ const Se = e.forwardRef((se, ae) => {
119
121
  t ? "k-message-reference-sender" : "k-message-reference-receiver"
120
122
  )
121
123
  },
122
- /* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" }, j(s, t)),
124
+ /* @__PURE__ */ e.createElement("div", { className: "k-message-reference-content" }, j(n, t)),
123
125
  /* @__PURE__ */ e.createElement("span", { className: "k-spacer" }),
124
126
  /* @__PURE__ */ e.createElement(
125
127
  N,
126
128
  {
127
129
  fillMode: "flat",
128
130
  themeColor: "base",
129
- svgIcon: ge,
131
+ svgIcon: ke,
130
132
  onClick: () => k(null),
131
133
  "aria-label": r.toLanguageString(_, S[_])
132
134
  }
@@ -134,11 +136,11 @@ const Se = e.forwardRef((se, ae) => {
134
136
  );
135
137
  }
136
138
  return null;
137
- }, [s, h, j, k, r]), $ = e.useCallback(
139
+ }, [n, h, j, k, r]), $ = e.useCallback(
138
140
  (t) => {
139
141
  try {
140
- const n = Array.from(t.newState);
141
- M((c) => [...c, ...n]), i();
142
+ const s = Array.from(t.newState);
143
+ M((c) => [...c, ...s]), i();
142
144
  } catch {
143
145
  }
144
146
  },
@@ -147,12 +149,12 @@ const Se = e.forwardRef((se, ae) => {
147
149
  w.current && a !== !1 && w.current.actionElement.click();
148
150
  }, [a]), J = e.useCallback((t) => {
149
151
  }, []), O = e.useCallback((t) => {
150
- const { isFinal: n, alternatives: c } = t;
152
+ const { isFinal: s, alternatives: c } = t;
151
153
  if (c.length > 0) {
152
154
  const u = c[0];
153
- n && b((E) => (E ? `${E} ` : "") + u.transcript);
155
+ s && b((E) => (E ? `${E} ` : "") + u.transcript);
154
156
  }
155
- }, []), Q = e.useCallback(() => /* @__PURE__ */ e.createElement(e.Fragment, null, l.length > 0 && V(), s && /* @__PURE__ */ e.createElement("span", { className: "k-input-prefix k-input-prefix-horizontal" }, G())), [l.length, s, V, G]), W = e.useCallback((t) => {
157
+ }, []), Q = e.useCallback(() => /* @__PURE__ */ e.createElement(e.Fragment, null, l.length > 0 && V(), n && /* @__PURE__ */ e.createElement("span", { className: "k-input-prefix k-input-prefix-horizontal" }, G())), [l.length, n, V, G]), W = e.useCallback((t) => {
156
158
  t.preventDefault();
157
159
  }, []), X = e.useCallback((t) => {
158
160
  t.key === "Escape" && t.currentTarget.blur();
@@ -165,7 +167,7 @@ const Se = e.forwardRef((se, ae) => {
165
167
  themeColor: "primary",
166
168
  className: "k-chat-send",
167
169
  icon: "paper-plane",
168
- svgIcon: de,
170
+ svgIcon: he,
169
171
  onClick: x,
170
172
  onMouseDown: W,
171
173
  onKeyDown: X,
@@ -186,9 +188,9 @@ const Se = e.forwardRef((se, ae) => {
186
188
  D
187
189
  ]
188
190
  ), Y = e.useCallback(() => {
189
- const t = typeof C == "object" ? C : void 0, n = typeof a == "object" ? a : {}, { className: c, ...u } = n, E = v("k-hidden", c), re = a !== !1, ce = C !== !1;
190
- return /* @__PURE__ */ e.createElement(me, null, ce && /* @__PURE__ */ e.createElement(
191
- ue,
191
+ const t = typeof C == "object" ? C : void 0, s = typeof a == "object" ? a : {}, { className: c, ...u } = s, E = v("k-hidden", c), ue = a !== !1, ie = C !== !1;
192
+ return /* @__PURE__ */ e.createElement(ge, null, ie && /* @__PURE__ */ e.createElement(
193
+ fe,
192
194
  {
193
195
  fillMode: "clear",
194
196
  themeColor: "base",
@@ -196,18 +198,18 @@ const Se = e.forwardRef((se, ae) => {
196
198
  onResult: O,
197
199
  ...t
198
200
  }
199
- ), re && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
201
+ ), ue && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(
200
202
  N,
201
203
  {
202
204
  key: "attach-file",
203
205
  fillMode: "clear",
204
206
  themeColor: "base",
205
- svgIcon: ke,
207
+ svgIcon: Ce,
206
208
  onClick: q,
207
209
  "aria-label": r.toLanguageString(te, S[te])
208
210
  }
209
211
  ), /* @__PURE__ */ e.createElement(
210
- ie,
212
+ me,
211
213
  {
212
214
  ref: w,
213
215
  files: l,
@@ -230,47 +232,49 @@ const Se = e.forwardRef((se, ae) => {
230
232
  I
231
233
  ]), Z = e.useMemo(
232
234
  () => /* @__PURE__ */ e.createElement(
233
- pe,
235
+ de,
234
236
  {
235
- className: v("k-message-box", "!k-flex-col", { "k-focus": L }),
237
+ className: v("k-message-box", "!k-flex-col", { "k-focus": z }),
236
238
  resizable: "none",
237
239
  rows: 1,
238
240
  placeholder: F,
239
241
  value: o,
240
242
  onChange: P,
241
243
  onKeyDown: U,
242
- onClick: z,
244
+ onClick: L,
243
245
  prefix: Q,
244
246
  suffix: Y,
245
247
  ref: p,
246
248
  "aria-label": r.toLanguageString(
247
- ne,
248
- S[ne]
249
+ se,
250
+ S[se]
249
251
  )
250
252
  }
251
253
  ),
252
254
  [
253
- L,
255
+ z,
254
256
  F,
255
257
  o,
256
258
  P,
257
259
  U,
258
- z,
260
+ L,
259
261
  Q,
260
262
  Y,
261
263
  r
262
264
  ]
263
265
  );
264
- return /* @__PURE__ */ e.createElement("div", { className: "k-message-box-wrapper" }, y && y.length > 0 && /* @__PURE__ */ e.createElement(
265
- fe,
266
+ return /* @__PURE__ */ e.createElement("div", { className: "k-message-box-wrapper" }, T && T.length > 0 && /* @__PURE__ */ e.createElement(
267
+ pe,
266
268
  {
267
269
  onSuggestionClick: oe,
268
- suggestions: y,
269
- suggestionTemplate: le
270
+ suggestions: T,
271
+ suggestionTemplate: le,
272
+ suggestionsLayout: re,
273
+ dir: ce
270
274
  }
271
275
  ), R ? /* @__PURE__ */ e.createElement(R, { messageInput: Z, sendButton: I }) : Z);
272
276
  });
273
- Se.displayName = "NewMessage";
277
+ Te.displayName = "NewMessage";
274
278
  export {
275
- Se as default
279
+ Te as default
276
280
  };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),m=require("@progress/kendo-react-buttons"),r=require("@progress/kendo-svg-icons"),v=require("@progress/kendo-react-intl"),n=require("../../messages/index.js");function L(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const o in t)if(o!=="default"){const l=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(e,o,l.get?l:{enumerable:!0,get:()=>t[o]})}}return e.default=t,Object.freeze(e)}const c=L(p),h=({visible:t,dir:e,canScrollLeft:o,canScrollRight:l,onScrollLeft:b,onScrollRight:f,children:s})=>{const a=v.useLocalization();if(!t)return s;const i=a.toLanguageString(n.scrollLeft,n.messages[n.scrollLeft]),u=a.toLanguageString(n.scrollRight,n.messages[n.scrollRight]),g=e!=="rtl"?i:u,d=e!=="rtl"?u:i;return c.createElement("div",{className:"k-suggestion-scrollwrap"},c.createElement(m.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:e==="rtl"?r.chevronRightIcon:r.chevronLeftIcon,onClick:b,disabled:!o,className:"k-icon-button","aria-label":g,title:g}),s,c.createElement(m.Button,{fillMode:"solid",themeColor:"base",size:"medium",rounded:"medium",svgIcon:e==="rtl"?r.chevronLeftIcon:r.chevronRightIcon,onClick:f,disabled:!l,className:"k-icon-button","aria-label":d,title:d}))};exports.ScrollButtonsWrapper=h;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import * as o from "react";
9
+ import { Button as n } from "@progress/kendo-react-buttons";
10
+ import { chevronRightIcon as c, chevronLeftIcon as m } from "@progress/kendo-svg-icons";
11
+ import { useLocalization as h } from "@progress/kendo-react-intl";
12
+ import { scrollLeft as u, messages as g, scrollRight as d } from "../../messages/index.mjs";
13
+ const R = ({
14
+ visible: b,
15
+ dir: e,
16
+ canScrollLeft: f,
17
+ canScrollRight: p,
18
+ onScrollLeft: L,
19
+ onScrollRight: v,
20
+ children: t
21
+ }) => {
22
+ const l = h();
23
+ if (!b)
24
+ return t;
25
+ const r = l.toLanguageString(u, g[u]), a = l.toLanguageString(d, g[d]), s = e !== "rtl" ? r : a, i = e !== "rtl" ? a : r;
26
+ return /* @__PURE__ */ o.createElement("div", { className: "k-suggestion-scrollwrap" }, /* @__PURE__ */ o.createElement(
27
+ n,
28
+ {
29
+ fillMode: "solid",
30
+ themeColor: "base",
31
+ size: "medium",
32
+ rounded: "medium",
33
+ svgIcon: e === "rtl" ? c : m,
34
+ onClick: L,
35
+ disabled: !f,
36
+ className: "k-icon-button",
37
+ "aria-label": s,
38
+ title: s
39
+ }
40
+ ), t, /* @__PURE__ */ o.createElement(
41
+ n,
42
+ {
43
+ fillMode: "solid",
44
+ themeColor: "base",
45
+ size: "medium",
46
+ rounded: "medium",
47
+ svgIcon: e === "rtl" ? m : c,
48
+ onClick: v,
49
+ disabled: !p,
50
+ className: "k-icon-button",
51
+ "aria-label": i,
52
+ title: i
53
+ }
54
+ ));
55
+ };
56
+ export {
57
+ R as ScrollButtonsWrapper
58
+ };
@@ -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 i=require("react"),b=require("@progress/kendo-react-common");function p(r){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const l=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(a,t,l.get?l:{enumerable:!0,get:()=>r[t]})}}return a.default=r,Object.freeze(a)}const c=p(i),u=r=>{const{suggestions:a,onSuggestionClick:t,suggestionsView:l,suggestionTemplate:n}=r,o=c.useCallback((e,d)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t==null||t(d))},[t]),s=c.useCallback(()=>a.map(e=>n?c.createElement(n,{key:e.id,suggestion:e,onClick:()=>{t==null||t(e)}}):c.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(t==null?void 0:t(e)),onKeyDown:d=>!e.disabled&&o(d,e),key:e.id,title:e.description,className:b.classNames(l==="classic"?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[a,n,t,l,o]);return!a||a.length===0?null:l==="classic"?s():c.createElement("div",{role:"group",className:"k-suggestion-group"},s())};exports.SuggestionGroup=u;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("react"),p=require("@progress/kendo-react-common"),h=require("./ScrollButtonsWrapper.js"),D=require("../hooks/useScrollWithButtons.js");function O(r){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(l,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return l.default=r,Object.freeze(l)}const o=O(R),g=r=>{const{suggestions:l,onSuggestionClick:t,suggestionsView:s,suggestionTemplate:c,suggestionsLayout:a,dir:i}=r,u=o.useRef(null),{canScrollLeft:f,canScrollRight:m,scrollLeft:y,scrollRight:S}=D.useScrollWithButtons(u,{enabled:a==="scrollbuttons",dir:i,itemsDependency:l}),d=o.useCallback((e,n)=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),t==null||t(n))},[t]),b=o.useCallback(()=>l.map(e=>c?o.createElement(c,{key:e.id,suggestion:e,onClick:()=>{t==null||t(e)}}):o.createElement("span",{role:"button",tabIndex:e.disabled?-1:0,"aria-label":e.description,"aria-disabled":e.disabled,onClick:()=>!e.disabled&&(t==null?void 0:t(e)),onKeyDown:n=>!e.disabled&&d(n,e),key:e.id,title:e.description,className:p.classNames(s==="classic"?"k-prompt-suggestion":"k-suggestion",{"k-disabled":e.disabled})},e.text)),[l,c,t,s,d]);if(!l||l.length===0)return null;if(s==="classic")return b();const k=o.createElement("div",{role:"group",className:p.classNames("k-suggestion-group",{"k-suggestion-group-scrollable":a==="scroll"}),ref:a==="scrollbuttons"?u:void 0},b());return o.createElement(h.ScrollButtonsWrapper,{visible:a==="scrollbuttons",dir:i,canScrollLeft:f,canScrollRight:m,onScrollLeft:y,onScrollRight:S},k)};exports.SuggestionGroup=g;