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

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 (76) hide show
  1. package/ai-prompt/views/AIPromptView.js +2 -2
  2. package/ai-prompt/views/AIPromptView.mjs +26 -26
  3. package/chat/components/Action.js +8 -0
  4. package/chat/components/Action.mjs +37 -0
  5. package/chat/components/ActionGroup.js +8 -0
  6. package/chat/components/ActionGroup.mjs +56 -0
  7. package/chat/components/Attachment.js +8 -0
  8. package/chat/components/Attachment.mjs +23 -0
  9. package/chat/components/AttachmentGroup.js +8 -0
  10. package/chat/components/AttachmentGroup.mjs +66 -0
  11. package/chat/components/Chat.js +8 -0
  12. package/chat/components/Chat.mjs +388 -0
  13. package/chat/components/ChatContext.js +8 -0
  14. package/{components/base/FocusableUponSelection.mjs → chat/components/ChatContext.mjs} +10 -10
  15. package/chat/components/ChatMessage.js +8 -0
  16. package/chat/components/ChatMessage.mjs +284 -0
  17. package/chat/components/DateMarker.js +8 -0
  18. package/chat/components/DateMarker.mjs +22 -0
  19. package/chat/components/Header.js +8 -0
  20. package/{utils.mjs → chat/components/Header.mjs} +4 -2
  21. package/chat/components/MessageGroup.js +8 -0
  22. package/chat/components/MessageGroup.mjs +88 -0
  23. package/chat/components/NewMessage.js +8 -0
  24. package/chat/components/NewMessage.mjs +264 -0
  25. package/chat/components/Notification.js +8 -0
  26. package/chat/components/Notification.mjs +24 -0
  27. package/chat/components/SuggestionsGroup.js +1 -1
  28. package/chat/components/SuggestionsGroup.mjs +40 -23
  29. package/chat/components/elements/FileBox.js +8 -0
  30. package/chat/components/elements/FileBox.mjs +69 -0
  31. package/chat/components/elements/PinnedMessage.js +8 -0
  32. package/chat/components/elements/PinnedMessage.mjs +46 -0
  33. package/chat/components/templates/HeroCard.js +8 -0
  34. package/chat/components/templates/HeroCard.mjs +26 -0
  35. package/chat/utils/fieldMapping.js +8 -0
  36. package/chat/utils/fieldMapping.mjs +79 -0
  37. package/chat/utils.js +8 -0
  38. package/chat/utils.mjs +65 -0
  39. package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
  40. package/index.d.mts +423 -165
  41. package/index.d.ts +423 -165
  42. package/index.js +1 -1
  43. package/index.mjs +34 -27
  44. package/messages/index.js +1 -1
  45. package/messages/index.mjs +38 -16
  46. package/package-metadata.js +1 -1
  47. package/package-metadata.mjs +2 -2
  48. package/package.json +7 -7
  49. package/components/Action.js +0 -8
  50. package/components/Action.mjs +0 -45
  51. package/components/ActionGroup.js +0 -8
  52. package/components/ActionGroup.mjs +0 -36
  53. package/components/Attachment.js +0 -8
  54. package/components/Attachment.mjs +0 -50
  55. package/components/AttachmentGroup.js +0 -8
  56. package/components/AttachmentGroup.mjs +0 -64
  57. package/components/Chat.js +0 -8
  58. package/components/Chat.mjs +0 -214
  59. package/components/ChatMessage.js +0 -8
  60. package/components/ChatMessage.mjs +0 -63
  61. package/components/ChatToolbar.js +0 -8
  62. package/components/ChatToolbar.mjs +0 -33
  63. package/components/DateMarker.js +0 -8
  64. package/components/DateMarker.mjs +0 -19
  65. package/components/MessageGroup.js +0 -8
  66. package/components/MessageGroup.mjs +0 -67
  67. package/components/NewMessage.js +0 -8
  68. package/components/NewMessage.mjs +0 -106
  69. package/components/base/FocusableUponSelection.js +0 -8
  70. package/components/base/SelectableItemsContainer.js +0 -8
  71. package/components/base/SelectableItemsContainer.mjs +0 -42
  72. package/components/templates/HeroCard.js +0 -8
  73. package/components/templates/HeroCard.mjs +0 -44
  74. package/utils.js +0 -8
  75. /package/{ViewItem.js → chat/ViewItem.js} +0 -0
  76. /package/{ViewItem.mjs → chat/ViewItem.mjs} +0 -0
@@ -0,0 +1,284 @@
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 t from "react";
9
+ import { classNames as A, IconWrap as $ } from "@progress/kendo-react-common";
10
+ import { Button as j } from "@progress/kendo-react-buttons";
11
+ import { downloadIcon as me, chevronUpIcon as de, chevronDownIcon as pe, checkCircleIcon as fe, undoIcon as ge, copyIcon as be } from "@progress/kendo-svg-icons";
12
+ import { useLocalization as ke, provideIntlService as Ce, registerForIntl as ye } from "@progress/kendo-react-intl";
13
+ import { ContextMenu as xe, MenuItem as Ee } from "@progress/kendo-react-layout";
14
+ import { copyToClipboard as he, getDeletedMessageText as Ie, getMessageById as we, isAuthor as R, convertTextToLinkedContent as G, scrollToMessageById as Me } from "../utils.mjs";
15
+ import { useChatContext as ve } from "./ChatContext.mjs";
16
+ import De from "./elements/FileBox.mjs";
17
+ import { downloadAllFiles as H, messages as h, downloadAll as J, collapseMessage as Q, expandMessage as Z } from "../../messages/index.mjs";
18
+ const _ = t.forwardRef(
19
+ (i, u) => {
20
+ const {
21
+ item: a,
22
+ template: I,
23
+ onRequestSelection: w,
24
+ tabIndex: ee = -1,
25
+ dateFormat: F = "g",
26
+ selected: l,
27
+ allowMessageCollapse: m,
28
+ messageToolbarActions: d,
29
+ messageContextMenuActions: p,
30
+ isSender: f
31
+ } = i, {
32
+ setReplyToMessage: g,
33
+ messages: L,
34
+ user: c,
35
+ internalScrollContainerRef: b,
36
+ onToolbarAction: M,
37
+ onContextMenuAction: v,
38
+ onFileAction: V,
39
+ onDownload: r,
40
+ fileActions: K,
41
+ setShowCopyNotification: k,
42
+ statusTemplate: D
43
+ } = ve(), [P, T] = t.useState(!1), [C, te] = t.useState(!0), [ae, z] = t.useState(!1), o = ke(), B = t.useRef({ left: 0, top: 0 }), y = t.useCallback(() => {
44
+ a != null && a.text && he(a.text), k && (k(!0), setTimeout(() => {
45
+ k(!1);
46
+ }, 3e3));
47
+ }, [a, k]), N = t.useCallback((e) => {
48
+ e.stopPropagation(), te((s) => !s);
49
+ }, []), se = t.useCallback(() => {
50
+ z(!1);
51
+ }, []), ne = t.useCallback((e) => {
52
+ (e.key === "Tab" || e.key === "Enter" || e.key === " " || e.key === "ArrowUp" || e.key === "ArrowDown") && z(!0);
53
+ }, []), S = t.useRef(null);
54
+ t.useEffect(() => {
55
+ l && S.current && S.current.focus();
56
+ }, [l]);
57
+ const W = t.useCallback((e) => {
58
+ B.current = { left: e.pageX, top: e.pageY }, e.preventDefault(), T(!0);
59
+ }, []), O = t.useCallback(() => {
60
+ T(!1);
61
+ }, []), x = t.useCallback(
62
+ (e, s) => !e.isDeleted && e.text ? e.text : Ie(s, o),
63
+ [o]
64
+ ), U = t.useCallback(
65
+ (e) => {
66
+ var s;
67
+ (s = e.item) != null && s.text && (e.item.data.id === "copy" && !a.isDeleted ? y() : e.item.data.id === "reply" && g(a), v && v(e.item.data, e, a)), T(!1);
68
+ },
69
+ [a, v, g, y]
70
+ ), q = t.useCallback(() => {
71
+ if (a.replyToId) {
72
+ const e = we(L, a.replyToId);
73
+ if (e) {
74
+ const s = (n) => {
75
+ n.preventDefault(), n.stopPropagation();
76
+ const E = b == null ? void 0 : b.current;
77
+ Me(e.id, E);
78
+ };
79
+ return /* @__PURE__ */ t.createElement(
80
+ "div",
81
+ {
82
+ className: A(
83
+ "k-message-reference",
84
+ R(c, e) ? "k-message-reference-sender" : "k-message-reference-receiver"
85
+ ),
86
+ onClick: s
87
+ },
88
+ /* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, G(
89
+ x(e, R(c, e))
90
+ ))
91
+ );
92
+ }
93
+ }
94
+ return null;
95
+ }, [a.replyToId, L, c, x, b]), X = t.useCallback(() => {
96
+ const e = [
97
+ {
98
+ id: "reply",
99
+ label: "Reply",
100
+ svgIcon: ge
101
+ },
102
+ {
103
+ id: "copy",
104
+ label: "Copy",
105
+ svgIcon: be
106
+ }
107
+ ], s = p ? [
108
+ ...e.map((n) => p.find(
109
+ (ue) => ue.id === n.id
110
+ ) || n),
111
+ ...p.filter(
112
+ (n) => !e.some((E) => E.id === n.id)
113
+ )
114
+ ] : e;
115
+ return /* @__PURE__ */ t.createElement(
116
+ xe,
117
+ {
118
+ onSelect: U,
119
+ onClose: O,
120
+ vertical: !0,
121
+ show: P,
122
+ offset: B.current
123
+ },
124
+ s.map(
125
+ (n) => n.id === "delete" && !f ? null : /* @__PURE__ */ t.createElement(
126
+ Ee,
127
+ {
128
+ key: n.id,
129
+ text: n.label,
130
+ icon: n.icon,
131
+ svgIcon: n.svgIcon,
132
+ data: n
133
+ }
134
+ )
135
+ )
136
+ );
137
+ }, [p, U, O, P, f]), Y = t.useCallback(() => a.files && a.files.length > 1 ? /* @__PURE__ */ t.createElement("div", { className: "k-chat-download-button-wrapper" }, /* @__PURE__ */ t.createElement(
138
+ j,
139
+ {
140
+ className: "k-chat-download-button",
141
+ fillMode: "flat",
142
+ themeColor: "base",
143
+ svgIcon: me,
144
+ onClick: (e) => {
145
+ e.stopPropagation(), r && r(a.files, a);
146
+ },
147
+ "aria-label": o.toLanguageString(
148
+ H,
149
+ h[H]
150
+ )
151
+ },
152
+ /* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, o.toLanguageString(J, h[J]))
153
+ )) : null, [a, r, o]), le = t.useCallback(() => {
154
+ if (a.typing)
155
+ return /* @__PURE__ */ t.createElement("div", { className: "k-chat-bubble" }, /* @__PURE__ */ t.createElement("div", { className: "k-typing-indicator" }, /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("span", null), /* @__PURE__ */ t.createElement("span", null)));
156
+ if (I) {
157
+ const e = I;
158
+ return /* @__PURE__ */ t.createElement(e, { item: a });
159
+ } else if (a.text || a.files && a.files.length > 0)
160
+ return /* @__PURE__ */ t.createElement(t.Fragment, null, /* @__PURE__ */ t.createElement(
161
+ "div",
162
+ {
163
+ className: A("k-chat-bubble", "k-bubble", {
164
+ "k-bubble-expandable": m,
165
+ "k-expanded": m && C,
166
+ "k-selected": l
167
+ }),
168
+ onContextMenu: W
169
+ },
170
+ /* @__PURE__ */ t.createElement(
171
+ "div",
172
+ {
173
+ className: "k-bubble-content",
174
+ onClick: (e) => {
175
+ e.stopPropagation(), e.preventDefault();
176
+ }
177
+ },
178
+ /* @__PURE__ */ t.createElement("span", { className: "k-chat-bubble-text" }, !a.isDeleted && q(), G(x(a, R(c, a)))),
179
+ a.files && /* @__PURE__ */ t.createElement(
180
+ De,
181
+ {
182
+ files: a.files,
183
+ message: a,
184
+ onFileAction: V,
185
+ onDownload: (e) => r == null ? void 0 : r(e, a),
186
+ renderInTextarea: !1,
187
+ fileActions: K
188
+ }
189
+ ),
190
+ Y()
191
+ ),
192
+ m && /* @__PURE__ */ t.createElement(
193
+ "span",
194
+ {
195
+ className: "k-bubble-expandable-indicator",
196
+ onClick: N,
197
+ role: "button",
198
+ "aria-label": C ? o.toLanguageString(
199
+ Q,
200
+ h[Q]
201
+ ) : o.toLanguageString(
202
+ Z,
203
+ h[Z]
204
+ ),
205
+ tabIndex: 0,
206
+ onKeyDown: (e) => {
207
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), N(e));
208
+ }
209
+ },
210
+ /* @__PURE__ */ t.createElement($, { icon: C ? de : pe, size: "medium" })
211
+ )
212
+ ), X());
213
+ return null;
214
+ }, [
215
+ a,
216
+ I,
217
+ m,
218
+ C,
219
+ l,
220
+ W,
221
+ q,
222
+ x,
223
+ c,
224
+ V,
225
+ K,
226
+ Y,
227
+ N,
228
+ o,
229
+ X,
230
+ r
231
+ ]), oe = t.useCallback(() => {
232
+ let e = null;
233
+ return a.timestamp && (e = /* @__PURE__ */ t.createElement("time", { className: "k-message-time", "aria-hidden": !l }, Ce({ props: i }).formatDate(a.timestamp, F))), e;
234
+ }, [a.timestamp, l, F, i]), re = t.useCallback(() => {
235
+ let e = null;
236
+ return a.status && l && (D ? e = t.createElement(D, { item: a }) : e = /* @__PURE__ */ t.createElement("span", { className: "k-message-status" }, /* @__PURE__ */ t.createElement($, { icon: fe, size: "xsmall" }), a.status)), e;
237
+ }, [a, l, D]), ce = t.useCallback(() => A({ "k-focus": l, "k-message-removed": a.isDeleted }, "k-message"), [l, a.isDeleted]), ie = t.useCallback(() => d && d.length > 0 && /* @__PURE__ */ t.createElement("div", { className: "k-chat-message-toolbar k-toolbar k-toolbar-md k-toolbar-flat" }, d.map((e) => e.id === "delete" && !f ? null : /* @__PURE__ */ t.createElement(
238
+ j,
239
+ {
240
+ key: e.id,
241
+ fillMode: "flat",
242
+ className: "k-toolbar-button",
243
+ themeColor: "base",
244
+ icon: e.icon,
245
+ svgIcon: e.svgIcon,
246
+ onClick: (s) => {
247
+ s.stopPropagation(), e.id === "copy" && !a.isDeleted ? y() : e.id === "reply" && g(a), M && M(e, s, a);
248
+ },
249
+ onMouseDown: (s) => s.preventDefault()
250
+ }
251
+ ))), [y, f, a, d, M, g]);
252
+ return /* @__PURE__ */ t.createElement(
253
+ "div",
254
+ {
255
+ "data-message-id": a.id,
256
+ className: ce(),
257
+ tabIndex: ee,
258
+ onClick: () => w(l ? void 0 : a.selectionIndex),
259
+ onMouseDown: se,
260
+ onKeyDown: ne,
261
+ onFocus: (e) => {
262
+ ae && w(a.selectionIndex);
263
+ },
264
+ ref: (e) => {
265
+ S.current = e, typeof u == "function" ? u(e) : u && (u.current = e);
266
+ }
267
+ },
268
+ oe(),
269
+ le(),
270
+ re(),
271
+ ie()
272
+ );
273
+ }
274
+ );
275
+ _.displayName = "ChatMessage";
276
+ class Te extends t.Component {
277
+ render() {
278
+ return /* @__PURE__ */ t.createElement(_, { ...this.props });
279
+ }
280
+ }
281
+ ye(Te);
282
+ export {
283
+ _ as ChatMessage
284
+ };
@@ -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";const c=require("react"),o=require("@progress/kendo-react-intl");function p(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const a=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,a.get?a:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const n=p(c),s=({item:e,timestampTemplate:r})=>{const t=r;return n.createElement("div",{className:"k-timestamp"},t?n.createElement(t,{item:e}):o.provideIntlService({props:{item:e}}).formatDate(e.timestamp,"D"))};class l extends n.Component{render(){return n.createElement(s,{...this.props})}}o.registerForIntl(l);module.exports=s;
@@ -0,0 +1,22 @@
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 t from "react";
9
+ import { provideIntlService as s, registerForIntl as o } from "@progress/kendo-react-intl";
10
+ const m = ({ item: e, timestampTemplate: a }) => {
11
+ const r = a;
12
+ return /* @__PURE__ */ t.createElement("div", { className: "k-timestamp" }, r ? /* @__PURE__ */ t.createElement(r, { item: e }) : s({ props: { item: e } }).formatDate(e.timestamp, "D"));
13
+ };
14
+ class n extends t.Component {
15
+ render() {
16
+ return /* @__PURE__ */ t.createElement(m, { ...this.props });
17
+ }
18
+ }
19
+ o(n);
20
+ export {
21
+ m as default
22
+ };
@@ -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";const n=require("@progress/kendo-react-layout"),o=require("react");function a(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const c=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,c.get?c:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const s=a(o),i=e=>s.createElement(n.AppBar,{className:"k-chat-header",positionMode:"sticky",themeColor:"light"},e.children);module.exports=i;
@@ -5,7 +5,9 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- const h = (o, t) => o && t.author && o.id === t.author.id;
8
+ import { AppBar as t } from "@progress/kendo-react-layout";
9
+ import * as r from "react";
10
+ const o = (e) => /* @__PURE__ */ r.createElement(t, { className: "k-chat-header", positionMode: "sticky", themeColor: "light" }, e.children);
9
11
  export {
10
- h as isAuthor
12
+ o as default
11
13
  };
@@ -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";const C=require("react"),O=require("@progress/kendo-react-common"),T=require("@progress/kendo-react-layout"),j=require("./Attachment.js"),b=require("../utils.js"),w=require("@progress/kendo-react-intl"),l=require("../../messages/index.js");function L(n){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const a in n)if(a!=="default"){const r=Object.getOwnPropertyDescriptor(n,a);Object.defineProperty(e,a,r.get?r:{enumerable:!0,get:()=>n[a]})}}return e.default=n,Object.freeze(e)}const t=L(C),z=n=>{const{group:e,user:a,itemTemplate:r,attachmentTemplate:u,onRequestSelection:m,selectedItemIndex:i,isLastGroup:g,message:d,allowMessageCollapse:p,messageToolbarActions:h,messageContextMenuActions:v,messageWidthMode:f="standard"}=n,q=w.useLocalization(),o=e.messages.length>0&&b.isAuthor(a,e.messages[0]),c=!o,x=t.useMemo(()=>O.classNames("k-message-group",{"k-message-group-sender k-no-avatar":o,"k-message-group-receiver":c,"k-message-group-full-width":f==="full"}),[o,c,f]),S=()=>{if(!(!c||!k))return t.createElement(T.Avatar,{type:"image"},t.createElement("img",{src:k,alt:I}))},y=t.useMemo(()=>{const R=e.messages.length-1;return e.messages.map((s,N)=>{const M=[t.createElement(d,{item:s,template:r,selected:s.selectionIndex===i,onRequestSelection:m,tabIndex:N===R&&g?0:-1,key:s.id,allowMessageCollapse:p,messageToolbarActions:h,messageContextMenuActions:v,isSender:b.isAuthor(a,s)})];return s.attachments&&s.attachments.length===1&&M.push(t.createElement(j,{item:s.attachments[0],template:u,selected:!1,key:`att-${s.attachments[0].content}`})),M})},[e.messages,d,r,i,m,g,p,h,v,a,u]),{avatarUrl:k,avatarAltText:A,name:E}=e.author,I=A!==void 0?A:q.toLanguageString(l.avatarAlt,l.messages[l.avatarAlt]);return t.createElement("div",{className:x},S(),t.createElement("div",{className:"k-message-group-content"},t.createElement("span",{className:"k-message-author"},E),y))};module.exports=z;
@@ -0,0 +1,88 @@
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 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) => {
16
+ const {
17
+ 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"
34
+ }),
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,
45
+ {
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)
56
+ }
57
+ )
58
+ ];
59
+ return t.attachments && t.attachments.length === 1 && A.push(
60
+ /* @__PURE__ */ e.createElement(
61
+ R,
62
+ {
63
+ item: t.attachments[0],
64
+ template: m,
65
+ selected: !1,
66
+ key: `att-${t.attachments[0].content}`
67
+ }
68
+ )
69
+ ), A;
70
+ });
71
+ }, [
72
+ a.messages,
73
+ u,
74
+ n,
75
+ c,
76
+ l,
77
+ i,
78
+ g,
79
+ 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));
85
+ };
86
+ export {
87
+ B as default
88
+ };
@@ -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";const D=require("@progress/kendo-react-common"),le=require("react"),T=require("@progress/kendo-react-buttons"),re=require("@progress/kendo-react-upload"),ce=require("./SuggestionsGroup.js"),te=require("@progress/kendo-react-inputs"),F=require("@progress/kendo-svg-icons"),ue=require("./ChatContext.js"),ie=require("@progress/kendo-react-intl"),se=require("../utils.js"),n=require("../../messages/index.js"),ge=require("./elements/FileBox.js");function fe(f){const d=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(f){for(const i in f)if(i!=="default"){const k=Object.getOwnPropertyDescriptor(f,i);Object.defineProperty(d,i,k.get?k:{enumerable:!0,get:()=>f[i]})}}return d.default=f,Object.freeze(d)}const e=fe(le),ne=e.forwardRef((f,d)=>{const{onSendMessage:i,isDirectionRightToLeft:k,placeholder:q,MessageBox:z,suggestions:R,onSuggestionClick:ae,inputValue:C,onInputValueChange:m,suggestionTemplate:oe,sendButtonConfig:j}=f,{replyToMessage:a,setReplyToMessage:S,user:x,messageListScrollContainerRef:p,speechToTextConfig:E,uploadConfig:I}=ue.useChatContext(),[L]=e.useState(!1),[o,y]=e.useState(void 0),[l,B]=e.useState([]),[P,K]=e.useState(!1),b=e.useRef(null),N=e.useRef(null),r=ie.useLocalization(),g=e.useCallback(()=>{b.current!==null&&b.current.focus()},[]);e.useEffect(()=>{C!==void 0&&C!==o&&(y(C),g())},[C,o,g]),e.useEffect(()=>{a&&g()},[a,g]),e.useLayoutEffect(()=>{P&&(p!=null&&p.current)&&(p.current.scrollTop=p.current.scrollHeight-p.current.clientHeight,K(!1))},[P,p]);const O=e.useCallback(t=>{const s=t.value;y(s),m&&m(s)},[m]),h=e.useMemo(()=>!!(o!=null&&o.trim()||l.length>0),[o,l.length]),M=e.useCallback(t=>{if(t.preventDefault(),i){const s=o;if(h){const c={id:"",author:x,text:s||"",timestamp:new Date,replyToId:a?a.id:void 0,files:l.map(u=>({name:u.name,size:u.size,type:u.extension,rawFile:u.getRawFile?u.getRawFile():u}))};S(null),i(c,t),B([]),y(""),m&&m(""),K(!0)}}},[i,o,x,a,l,S,m,h]),A=e.useCallback(t=>{if(!(t.key==="Enter"&&t.shiftKey))switch(t.key){case"Enter":return t.preventDefault(),M(t);case"Escape":b.current&&b.current.blur();break;default:return}},[M]);e.useImperativeHandle(d,()=>({focusInput:g}),[g]);const U=e.useCallback(t=>{B(s=>s.filter(c=>c.name!==t))},[]),H=e.useCallback(()=>e.createElement(ge,{files:l,onFileRemove:U,renderInTextarea:!0}),[l,U]),V=e.useCallback((t,s)=>t.isDeleted?se.getDeletedMessageText(s,r):t.text,[r]),_=e.useCallback(()=>{if(a){const t=se.isAuthor(x,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"},V(a,t)),e.createElement("span",{className:"k-spacer"}),e.createElement(T.Button,{fillMode:"flat",themeColor:"base",svgIcon:F.xIcon,onClick:()=>S(null),"aria-label":r.toLanguageString(n.closeReply,n.messages[n.closeReply])}))}return null},[a,x,V,S,r]),G=e.useCallback(t=>{try{const s=Array.from(t.newState);B(c=>[...c,...s]),g()}catch{}},[g]),$=e.useCallback(()=>{N.current&&N.current.actionElement.click()},[]),J=e.useCallback(t=>{},[]),Q=e.useCallback(t=>{const{isFinal:s,alternatives:c}=t;if(c.length>0){const u=c[0];s&&y(w=>(w?`${w} `:"")+u.transcript)}},[]),W=e.useCallback(()=>e.createElement(e.Fragment,null,l.length>0&&H(),a&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},_())),[l.length,a,H,_]),X=e.useCallback(t=>{t.preventDefault()},[]),Y=e.useCallback(t=>{t.key==="Escape"&&t.currentTarget.blur()},[]),v=e.useMemo(()=>e.createElement(T.Button,{rounded:"full",fillMode:"solid",themeColor:"primary",className:"k-chat-send",icon:"paper-plane",svgIcon:F.paperPlaneIcon,onClick:M,onMouseDown:X,onKeyDown:Y,"aria-label":r.toLanguageString(n.newMessageSendButton,n.messages[n.newMessageSendButton]),dir:k?"rtl":void 0,disabled:!h,"aria-disabled":!h,...j}),[M,X,Y,r,k,h,j]),Z=e.useCallback(()=>{const t=typeof E=="object"?E:void 0,s=typeof I=="object"?I:{},{className:c,...u}=s,w=D.classNames("k-hidden",c);return e.createElement(te.InputSuffix,null,E!==!1&&e.createElement(T.SpeechToTextButton,{fillMode:"clear",themeColor:"base",onError:J,onResult:Q,...t}),e.createElement(T.Button,{key:"attach-file",fillMode:"clear",themeColor:"base",svgIcon:F.paperclipIcon,onClick:$,"aria-label":r.toLanguageString(n.attachFile,n.messages[n.attachFile])}),e.createElement(re.Upload,{ref:N,files:l,onAdd:G,multiple:!0,autoUpload:!1,...u,className:w}),e.createElement("span",{className:"k-spacer"}),v)},[E,I,l,J,Q,$,G,r,v]),ee=e.useMemo(()=>e.createElement(te.TextArea,{className:D.classNames("k-message-box","!k-flex-col",{"k-focus":L}),resizable:"none",rows:1,placeholder:q,value:o,onChange:O,onKeyDown:A,prefix:W,suffix:Z,ref:b,"aria-label":r.toLanguageString(n.newMessageMessageInput,n.messages[n.newMessageMessageInput])}),[L,q,o,O,A,W,Z,r]);return e.createElement("div",{className:"k-message-box-wrapper"},R&&R.length>0&&e.createElement(ce.SuggestionGroup,{onSuggestionClick:ae,suggestions:R,suggestionTemplate:oe}),z?e.createElement(z,{messageInput:ee,sendButton:v}):ee)});ne.displayName="NewMessage";module.exports=ne;