@progress/kendo-react-conversational-ui 11.4.0-develop.9 → 12.0.0-develop.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/README.md +80 -23
  2. package/ai-prompt/AIPrompt.js +1 -1
  3. package/ai-prompt/AIPrompt.mjs +40 -38
  4. package/ai-prompt/views/AIPromptView.js +2 -2
  5. package/ai-prompt/views/AIPromptView.mjs +42 -47
  6. package/ai-prompt/views/constants.js +1 -1
  7. package/ai-prompt/views/constants.mjs +1 -1
  8. package/chat/components/Action.js +8 -0
  9. package/chat/components/Action.mjs +37 -0
  10. package/chat/components/ActionGroup.js +8 -0
  11. package/chat/components/ActionGroup.mjs +56 -0
  12. package/chat/components/Attachment.js +8 -0
  13. package/chat/components/Attachment.mjs +23 -0
  14. package/chat/components/AttachmentGroup.js +8 -0
  15. package/chat/components/AttachmentGroup.mjs +66 -0
  16. package/chat/components/Chat.js +8 -0
  17. package/chat/components/Chat.mjs +388 -0
  18. package/chat/components/ChatContext.js +8 -0
  19. package/{components/base/FocusableUponSelection.mjs → chat/components/ChatContext.mjs} +10 -10
  20. package/chat/components/ChatMessage.js +8 -0
  21. package/chat/components/ChatMessage.mjs +284 -0
  22. package/chat/components/DateMarker.js +8 -0
  23. package/chat/components/DateMarker.mjs +22 -0
  24. package/chat/components/Header.js +8 -0
  25. package/{utils.mjs → chat/components/Header.mjs} +4 -2
  26. package/chat/components/MessageGroup.js +8 -0
  27. package/chat/components/MessageGroup.mjs +88 -0
  28. package/chat/components/NewMessage.js +8 -0
  29. package/chat/components/NewMessage.mjs +264 -0
  30. package/chat/components/Notification.js +8 -0
  31. package/chat/components/Notification.mjs +24 -0
  32. package/chat/components/SuggestionsGroup.js +1 -1
  33. package/chat/components/SuggestionsGroup.mjs +39 -20
  34. package/chat/components/elements/FileBox.js +8 -0
  35. package/chat/components/elements/FileBox.mjs +69 -0
  36. package/chat/components/elements/PinnedMessage.js +8 -0
  37. package/chat/components/elements/PinnedMessage.mjs +46 -0
  38. package/chat/components/templates/HeroCard.js +8 -0
  39. package/chat/components/templates/HeroCard.mjs +26 -0
  40. package/chat/utils/fieldMapping.js +8 -0
  41. package/chat/utils/fieldMapping.mjs +79 -0
  42. package/chat/utils.js +8 -0
  43. package/chat/utils.mjs +65 -0
  44. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  45. package/index.d.mts +437 -165
  46. package/index.d.ts +437 -165
  47. package/index.js +1 -1
  48. package/index.mjs +34 -27
  49. package/messages/index.js +1 -1
  50. package/messages/index.mjs +38 -16
  51. package/package-metadata.js +1 -1
  52. package/package-metadata.mjs +2 -2
  53. package/package.json +7 -7
  54. package/components/Action.js +0 -8
  55. package/components/Action.mjs +0 -45
  56. package/components/ActionGroup.js +0 -8
  57. package/components/ActionGroup.mjs +0 -36
  58. package/components/Attachment.js +0 -8
  59. package/components/Attachment.mjs +0 -50
  60. package/components/AttachmentGroup.js +0 -8
  61. package/components/AttachmentGroup.mjs +0 -64
  62. package/components/Chat.js +0 -8
  63. package/components/Chat.mjs +0 -214
  64. package/components/ChatMessage.js +0 -8
  65. package/components/ChatMessage.mjs +0 -63
  66. package/components/ChatToolbar.js +0 -8
  67. package/components/ChatToolbar.mjs +0 -33
  68. package/components/DateMarker.js +0 -8
  69. package/components/DateMarker.mjs +0 -19
  70. package/components/MessageGroup.js +0 -8
  71. package/components/MessageGroup.mjs +0 -67
  72. package/components/NewMessage.js +0 -8
  73. package/components/NewMessage.mjs +0 -106
  74. package/components/base/FocusableUponSelection.js +0 -8
  75. package/components/base/SelectableItemsContainer.js +0 -8
  76. package/components/base/SelectableItemsContainer.mjs +0 -42
  77. package/components/templates/HeroCard.js +0 -8
  78. package/components/templates/HeroCard.mjs +0 -44
  79. package/utils.js +0 -8
  80. /package/{ViewItem.js → chat/ViewItem.js} +0 -0
  81. /package/{ViewItem.mjs → chat/ViewItem.mjs} +0 -0
@@ -0,0 +1,66 @@
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 l from "react";
9
+ import { Keys as m, classNames as B } from "@progress/kendo-react-common";
10
+ import { chevronLeftIcon as D, chevronRightIcon as K } from "@progress/kendo-svg-icons";
11
+ import N from "./Attachment.mjs";
12
+ import { Button as b } from "@progress/kendo-react-buttons";
13
+ const P = (y) => {
14
+ const { group: t, itemTemplate: v, selected: f, isLastGroup: L, onRequestSelection: k } = y, [n, r] = l.useState(null);
15
+ l.useEffect(() => {
16
+ !f && n !== null ? r(null) : f && n === null && r(0);
17
+ }, [f, n]);
18
+ const c = l.useCallback((e) => e.attachmentLayout !== "list", []), C = l.useCallback(() => t.attachments ? t.attachments.length - 1 : -1, [t.attachments]), h = l.useCallback(() => t.attachments.length - 1, [t.attachments]), o = l.useCallback(
19
+ (e, s = 0) => {
20
+ let a = null;
21
+ return e ? n === null ? a = s : n < C() && (a = n + 1) : n === null ? a = 0 : n > 0 && (a = n - 1), a !== null && r(a), a;
22
+ },
23
+ [n, C]
24
+ ), u = l.useCallback(() => {
25
+ k(t.selectionIndex);
26
+ }, [k, t.selectionIndex]), g = l.useCallback(
27
+ (e) => {
28
+ let s = null, a, d;
29
+ c(t) ? (a = m.left, d = m.right) : (a = m.up, d = m.down), e.keyCode === a ? s = o(!1) : e.keyCode === d && (s = o(!0)), s !== null && (e.preventDefault(), e.stopPropagation());
30
+ },
31
+ [o, c, t]
32
+ ), S = l.useCallback(
33
+ (e) => {
34
+ u(), r(e);
35
+ },
36
+ [u]
37
+ ), i = l.useCallback(
38
+ (e) => {
39
+ u(), o(e, 1);
40
+ },
41
+ [u, o]
42
+ ), w = l.useCallback(() => {
43
+ let e = null;
44
+ return c(t) && n && (e = /* @__PURE__ */ l.createElement(b, { icon: "chevron-left", onClick: () => i(!1), svgIcon: D })), e;
45
+ }, [c, t, n, i]), x = l.useCallback(() => {
46
+ let e = null;
47
+ return c(t) && n !== h() && (e = /* @__PURE__ */ l.createElement(b, { icon: "chevron-right", onClick: () => i(!0), svgIcon: K })), e;
48
+ }, [c, t, n, h, i]), E = l.useCallback(() => B({
49
+ "k-card-list": t.attachmentLayout,
50
+ "k-card-deck": c(t)
51
+ }), [t.attachmentLayout, t, c]), p = c(t), I = /* @__PURE__ */ l.createElement("div", { className: E(), onKeyDown: p ? void 0 : g }, t.attachments.map((e, s) => /* @__PURE__ */ l.createElement(
52
+ N,
53
+ {
54
+ item: e,
55
+ template: v,
56
+ selected: s === n,
57
+ tabbable: L && s === n,
58
+ onClick: () => S(s),
59
+ key: e.content
60
+ }
61
+ )));
62
+ return p ? /* @__PURE__ */ l.createElement("div", { className: "k-card-deck-scrollwrap", onKeyDown: g }, w(), I, x()) : I;
63
+ };
64
+ export {
65
+ P as default
66
+ };
@@ -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 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;
@@ -0,0 +1,388 @@
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 { validatePackage as Ye, Keys as y, classNames as je, WatermarkOverlay as ze } from "@progress/kendo-react-common";
9
+ import r from "prop-types";
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) => {
27
+ const {
28
+ messages: m = [],
29
+ messageTemplate: b,
30
+ attachmentTemplate: E,
31
+ width: Ie,
32
+ height: Le,
33
+ onSendMessage: p,
34
+ onSuggestionClick: A,
35
+ onInputValueChange: F,
36
+ onActionExecute: S,
37
+ dir: k,
38
+ messageBox: we,
39
+ placeholder: be,
40
+ className: N,
41
+ message: v = st,
42
+ authorId: l,
43
+ suggestions: h,
44
+ suggestionTemplate: Ae,
45
+ inputValue: Fe,
46
+ headerTemplate: f,
47
+ timestampTemplate: D,
48
+ statusTemplate: B,
49
+ allowMessageCollapse: O,
50
+ messageToolbarActions: P,
51
+ messageContextMenuActions: _,
52
+ fileActions: H,
53
+ onUnpin: Ne,
54
+ messageWidthMode: U,
55
+ onToolbarAction: V,
56
+ onContextMenuAction: G,
57
+ onFileAction: q,
58
+ onDownload: W,
59
+ speechToTextConfig: Y,
60
+ uploadConfig: j,
61
+ sendButtonConfig: ve,
62
+ textField: z,
63
+ statusField: K,
64
+ authorIdField: $,
65
+ authorNameField: J,
66
+ authorImageUrlField: Q,
67
+ authorImageAltTextField: X,
68
+ idField: Z,
69
+ timestampField: ee,
70
+ filesField: te,
71
+ attachmentsField: ne,
72
+ replyToIdField: oe,
73
+ isDeletedField: se,
74
+ isPinnedField: re,
75
+ typingField: ae,
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
+ }), [
98
+ m,
99
+ z,
100
+ K,
101
+ $,
102
+ J,
103
+ Q,
104
+ X,
105
+ Z,
106
+ ee,
107
+ te,
108
+ ne,
109
+ oe,
110
+ se,
111
+ re,
112
+ ae,
113
+ le
114
+ ]);
115
+ e.useEffect(() => {
116
+ if (l === pe.current && w.current) {
117
+ me(w.current);
118
+ return;
119
+ }
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
+ }
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(() => {
128
+ clearTimeout(I.current);
129
+ }, []), He = e.useCallback(() => {
130
+ I.current = window.setTimeout(() => {
131
+ R(null);
132
+ }, 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());
140
+ },
141
+ [i, u]
142
+ ), d = e.useCallback(() => {
143
+ a.current && (a.current.scrollTop = a.current.scrollHeight - a.current.clientHeight);
144
+ }, []), Te = e.useCallback(() => {
145
+ if (!a.current)
146
+ return !0;
147
+ const { scrollTop: n, scrollHeight: t, clientHeight: o } = a.current;
148
+ return t - n - o < ct;
149
+ }, []), C = e.useCallback(() => {
150
+ Te() && requestAnimationFrame(() => {
151
+ d();
152
+ });
153
+ }, [Te, d]), Ce = e.useCallback(() => {
154
+ requestAnimationFrame(() => {
155
+ d();
156
+ });
157
+ }, [d]), ye = e.useCallback(
158
+ (n, t, o) => {
159
+ var Ee;
160
+ 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) {
167
+ case "reply":
168
+ p && p({
169
+ message: {
170
+ id: "",
171
+ author: c,
172
+ text: n.value,
173
+ timestamp: /* @__PURE__ */ new Date()
174
+ },
175
+ syntheticEvent: t,
176
+ nativeEvent: t.nativeEvent,
177
+ target: t.currentTarget
178
+ });
179
+ break;
180
+ case "call":
181
+ window.open("tel:" + n.value);
182
+ break;
183
+ case "openUrl":
184
+ window.open(n.value);
185
+ break;
186
+ }
187
+ (Ee = de.current) == null || Ee.focusInput();
188
+ }
189
+ },
190
+ [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,
195
+ {
196
+ group: t,
197
+ itemTemplate: b,
198
+ attachmentTemplate: E,
199
+ user: c,
200
+ selectedItemIndex: i,
201
+ onRequestSelection: T,
202
+ isLastGroup: o === n,
203
+ key: t.messages[0].selectionIndex,
204
+ message: v,
205
+ allowMessageCollapse: O,
206
+ messageToolbarActions: P,
207
+ messageContextMenuActions: _,
208
+ messageWidthMode: U
209
+ }
210
+ ) : t.type === "attachment-group" ? /* @__PURE__ */ e.createElement(
211
+ Je,
212
+ {
213
+ group: t,
214
+ itemTemplate: E,
215
+ onRequestSelection: T,
216
+ selected: t.selectionIndex === i,
217
+ isLastGroup: o === n,
218
+ key: t.selectionIndex
219
+ }
220
+ ) : t.type === "action-group" ? /* @__PURE__ */ e.createElement(
221
+ $e,
222
+ {
223
+ group: t,
224
+ onActionExecute: ye,
225
+ onRequestSelection: T,
226
+ selected: t.selectionIndex === i,
227
+ key: t.selectionIndex
228
+ }
229
+ ) : null);
230
+ }, [
231
+ u,
232
+ D,
233
+ b,
234
+ E,
235
+ c,
236
+ i,
237
+ T,
238
+ v,
239
+ O,
240
+ P,
241
+ _,
242
+ U,
243
+ ye
244
+ ]), qe = e.useCallback(() => f ? typeof f == "function" ? f() : f : null, [f]);
245
+ 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), () => {
249
+ clearTimeout(L.current);
250
+ }), [d]), e.useEffect(() => () => {
251
+ clearTimeout(I.current), clearTimeout(L.current);
252
+ }, []), e.useEffect(() => {
253
+ Ce();
254
+ }, [s.length, Ce]), e.useEffect(() => {
255
+ const n = window.setTimeout(() => {
256
+ C();
257
+ }, mt);
258
+ return () => {
259
+ clearTimeout(n);
260
+ };
261
+ }, [s, C]), e.useEffect(() => {
262
+ if (h && h.length > 0) {
263
+ const n = window.setTimeout(() => {
264
+ C();
265
+ }, ft);
266
+ return () => {
267
+ clearTimeout(n);
268
+ };
269
+ }
270
+ }, [h, C]);
271
+ const We = e.useMemo(
272
+ () => ({
273
+ replyToMessage: ce,
274
+ setReplyToMessage: ue,
275
+ messages: s,
276
+ user: c,
277
+ internalScrollContainerRef: fe,
278
+ messageListScrollContainerRef: a,
279
+ onToolbarAction: V,
280
+ onContextMenuAction: G,
281
+ onFileAction: q,
282
+ setShowCopyNotification: ie,
283
+ onDownload: W,
284
+ fileActions: H,
285
+ speechToTextConfig: Y,
286
+ uploadConfig: j,
287
+ statusTemplate: B
288
+ }),
289
+ [
290
+ ce,
291
+ ue,
292
+ s,
293
+ c,
294
+ V,
295
+ G,
296
+ q,
297
+ ie,
298
+ W,
299
+ H,
300
+ Y,
301
+ j,
302
+ B
303
+ ]
304
+ );
305
+ return /* @__PURE__ */ e.createElement(ot.Provider, { value: We }, /* @__PURE__ */ e.createElement(
306
+ "div",
307
+ {
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
+ },
314
+ ...De
315
+ },
316
+ f !== void 0 && /* @__PURE__ */ e.createElement(et, null, qe()),
317
+ ge && /* @__PURE__ */ e.createElement(tt, { message: ge, onUnpin: Ne, user: c }),
318
+ /* @__PURE__ */ e.createElement(
319
+ "div",
320
+ {
321
+ className: "k-message-list k-avatars",
322
+ onBlur: He,
323
+ onFocus: _e,
324
+ role: "log",
325
+ "aria-label": he.toLanguageString(
326
+ Se,
327
+ ke[Se]
328
+ ),
329
+ "aria-live": "polite",
330
+ ref: a
331
+ },
332
+ /* @__PURE__ */ e.createElement("div", { className: "k-message-list-content" }, Ge())
333
+ ),
334
+ /* @__PURE__ */ e.createElement(
335
+ Ze,
336
+ {
337
+ onSendMessage: (n, t) => {
338
+ p && p({
339
+ message: n,
340
+ syntheticEvent: t,
341
+ nativeEvent: t.nativeEvent,
342
+ target: t.currentTarget
343
+ });
344
+ },
345
+ onSuggestionClick: (n) => {
346
+ A && A(n);
347
+ },
348
+ isDirectionRightToLeft: x,
349
+ ref: de,
350
+ placeholder: be,
351
+ MessageBox: we,
352
+ suggestions: h,
353
+ suggestionTemplate: Ae,
354
+ inputValue: Fe,
355
+ onInputValueChange: (n) => {
356
+ F && F(n);
357
+ },
358
+ sendButtonConfig: ve
359
+ }
360
+ ),
361
+ Pe && /* @__PURE__ */ e.createElement(ze, null),
362
+ /* @__PURE__ */ e.createElement(
363
+ nt,
364
+ {
365
+ show: Oe,
366
+ text: he.toLanguageString(
367
+ Re,
368
+ ke[Re]
369
+ )
370
+ }
371
+ )
372
+ ));
373
+ });
374
+ xe.displayName = "Chat";
375
+ xe.propTypes = {
376
+ messages: r.arrayOf(r.object),
377
+ user: r.object,
378
+ messageTemplate: r.any,
379
+ attachmentTemplate: r.any,
380
+ width: r.oneOfType([r.string, r.number]),
381
+ onSendMessage: r.func,
382
+ onActionExecute: r.func,
383
+ dir: r.string,
384
+ messageBox: r.any
385
+ };
386
+ export {
387
+ xe as Chat
388
+ };
@@ -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.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const r=require("react");function a(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const c=a(r),u=c.createContext(void 0),s=()=>{const e=r.useContext(u);if(e===void 0)throw new Error("useChatContext must be used within a ChatContext.Provider");return e};exports.default=u;exports.useChatContext=s;
@@ -5,15 +5,15 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as o from "react";
9
- class s extends o.Component {
10
- /**
11
- * @hidden
12
- */
13
- componentDidUpdate(e) {
14
- !e.selected && this.props.selected && this.elementToFocus.focus();
15
- }
16
- }
8
+ import * as e from "react";
9
+ import { useContext as o } from "react";
10
+ const r = e.createContext(void 0), a = () => {
11
+ const t = o(r);
12
+ if (t === void 0)
13
+ throw new Error("useChatContext must be used within a ChatContext.Provider");
14
+ return t;
15
+ };
17
16
  export {
18
- s as FocusableUponSelection
17
+ r as default,
18
+ a as useChatContext
19
19
  };
@@ -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 ce=require("react"),g=require("@progress/kendo-react-common"),H=require("@progress/kendo-react-buttons"),p=require("@progress/kendo-svg-icons"),F=require("@progress/kendo-react-intl"),J=require("@progress/kendo-react-layout"),c=require("../utils.js"),ie=require("./ChatContext.js"),ue=require("./elements/FileBox.js"),l=require("../../messages/index.js");function de(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const m=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(i,n,m.get?m:{enumerable:!0,get:()=>r[n]})}}return i.default=r,Object.freeze(i)}const t=de(ce),L=t.forwardRef((r,i)=>{const{item:n,template:m,onRequestSelection:T,tabIndex:Q=-1,dateFormat:O="g",selected:o,allowMessageCollapse:b,messageToolbarActions:k,messageContextMenuActions:C,isSender:y}=r,{setReplyToMessage:x,messages:P,user:f,internalScrollContainerRef:h,onToolbarAction:D,onContextMenuAction:N,onFileAction:V,onDownload:d,fileActions:B,setShowCopyNotification:I,statusTemplate:S}=ie.useChatContext(),[j,A]=t.useState(!1),[E,Z]=t.useState(!0),[$,z]=t.useState(!1),u=F.useLocalization(),K=t.useRef({left:0,top:0}),w=t.useCallback(()=>{n!=null&&n.text&&c.copyToClipboard(n.text),I&&(I(!0),setTimeout(()=>{I(!1)},3e3))},[n,I]),R=t.useCallback(e=>{e.stopPropagation(),Z(a=>!a)},[]),ee=t.useCallback(()=>{z(!1)},[]),te=t.useCallback(e=>{(e.key==="Tab"||e.key==="Enter"||e.key===" "||e.key==="ArrowUp"||e.key==="ArrowDown")&&z(!0)},[]),q=t.useRef(null);t.useEffect(()=>{o&&q.current&&q.current.focus()},[o]);const W=t.useCallback(e=>{K.current={left:e.pageX,top:e.pageY},e.preventDefault(),A(!0)},[]),_=t.useCallback(()=>{A(!1)},[]),M=t.useCallback((e,a)=>!e.isDeleted&&e.text?e.text:c.getDeletedMessageText(a,u),[u]),U=t.useCallback(e=>{var a;(a=e.item)!=null&&a.text&&(e.item.data.id==="copy"&&!n.isDeleted?w():e.item.data.id==="reply"&&x(n),N&&N(e.item.data,e,n)),A(!1)},[n,N,x,w]),X=t.useCallback(()=>{if(n.replyToId){const e=c.getMessageById(P,n.replyToId);if(e){const a=s=>{s.preventDefault(),s.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(f,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(f,e)))))}}return null},[n.replyToId,P,f,M,h]),Y=t.useCallback(()=>{const e=[{id:"reply",label:"Reply",svgIcon:p.undoIcon},{id:"copy",label:"Copy",svgIcon:p.copyIcon}],a=C?[...e.map(s=>C.find(re=>re.id===s.id)||s),...C.filter(s=>!e.some(v=>v.id===s.id))]:e;return t.createElement(J.ContextMenu,{onSelect:U,onClose:_,vertical:!0,show:j,offset:K.current},a.map(s=>s.id==="delete"&&!y?null:t.createElement(J.MenuItem,{key:s.id,text:s.label,icon:s.icon,svgIcon:s.svgIcon,data:s})))},[C,U,_,j,y]),G=t.useCallback(()=>n.files&&n.files.length>1?t.createElement("div",{className:"k-chat-download-button-wrapper"},t.createElement(H.Button,{className:"k-chat-download-button",fillMode:"flat",themeColor:"base",svgIcon:p.downloadIcon,onClick:e=>{e.stopPropagation(),d&&d(n.files,n)},"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,[n,d,u]),ne=t.useCallback(()=>{if(n.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:n})}else if(n.text||n.files&&n.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}),onContextMenu:W},t.createElement("div",{className:"k-bubble-content",onClick:e=>{e.stopPropagation(),e.preventDefault()}},t.createElement("span",{className:"k-chat-bubble-text"},!n.isDeleted&&X(),c.convertTextToLinkedContent(M(n,c.isAuthor(f,n)))),n.files&&t.createElement(ue,{files:n.files,message:n,onFileAction:V,onDownload:e=>d==null?void 0:d(e,n),renderInTextarea:!1,fileActions:B}),G()),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?p.chevronUpIcon:p.chevronDownIcon,size:"medium"}))),Y());return null},[n,m,b,E,o,W,X,M,f,V,B,G,R,u,Y,d]),ae=t.useCallback(()=>{let e=null;return n.timestamp&&(e=t.createElement("time",{className:"k-message-time","aria-hidden":!o},F.provideIntlService({props:r}).formatDate(n.timestamp,O))),e},[n.timestamp,o,O,r]),se=t.useCallback(()=>{let e=null;return n.status&&o&&(S?e=t.createElement(S,{item:n}):e=t.createElement("span",{className:"k-message-status"},t.createElement(g.IconWrap,{icon:p.checkCircleIcon,size:"xsmall"}),n.status)),e},[n,o,S]),le=t.useCallback(()=>g.classNames({"k-focus":o,"k-message-removed":n.isDeleted},"k-message"),[o,n.isDeleted]),oe=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(H.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"&&!n.isDeleted?w():e.id==="reply"&&x(n),D&&D(e,a,n)},onMouseDown:a=>a.preventDefault()}))),[w,y,n,k,D,x]);return t.createElement("div",{"data-message-id":n.id,className:le(),tabIndex:Q,onClick:()=>T(o?void 0:n.selectionIndex),onMouseDown:ee,onKeyDown:te,onFocus:e=>{$&&T(n.selectionIndex)},ref:e=>{q.current=e,typeof i=="function"?i(e):i&&(i.current=e)}},ae(),ne(),se(),oe())});L.displayName="ChatMessage";class me extends t.Component{render(){return t.createElement(L,{...this.props})}}F.registerForIntl(me);exports.ChatMessage=L;