@progress/kendo-react-conversational-ui 11.4.0 → 12.0.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.
- package/ai-prompt/views/AIPromptView.js +2 -2
- package/ai-prompt/views/AIPromptView.mjs +26 -26
- package/chat/components/Action.js +8 -0
- package/chat/components/Action.mjs +37 -0
- package/chat/components/ActionGroup.js +8 -0
- package/chat/components/ActionGroup.mjs +56 -0
- package/chat/components/Attachment.js +8 -0
- package/chat/components/Attachment.mjs +23 -0
- package/chat/components/AttachmentGroup.js +8 -0
- package/chat/components/AttachmentGroup.mjs +66 -0
- package/chat/components/Chat.js +8 -0
- package/chat/components/Chat.mjs +388 -0
- package/chat/components/ChatContext.js +8 -0
- package/{components/base/FocusableUponSelection.mjs → chat/components/ChatContext.mjs} +10 -10
- package/chat/components/ChatMessage.js +8 -0
- package/chat/components/ChatMessage.mjs +274 -0
- package/chat/components/DateMarker.js +8 -0
- package/chat/components/DateMarker.mjs +22 -0
- package/chat/components/Header.js +8 -0
- package/{utils.mjs → chat/components/Header.mjs} +4 -2
- package/chat/components/MessageGroup.js +8 -0
- package/chat/components/MessageGroup.mjs +88 -0
- package/chat/components/NewMessage.js +8 -0
- package/chat/components/NewMessage.mjs +264 -0
- package/chat/components/Notification.js +8 -0
- package/chat/components/Notification.mjs +24 -0
- package/chat/components/SuggestionsGroup.js +1 -1
- package/chat/components/SuggestionsGroup.mjs +40 -23
- package/chat/components/elements/FileBox.js +8 -0
- package/chat/components/elements/FileBox.mjs +72 -0
- package/chat/components/elements/PinnedMessage.js +8 -0
- package/chat/components/elements/PinnedMessage.mjs +46 -0
- package/chat/components/templates/HeroCard.js +8 -0
- package/chat/components/templates/HeroCard.mjs +26 -0
- package/chat/utils/fieldMapping.js +8 -0
- package/chat/utils/fieldMapping.mjs +79 -0
- package/chat/utils.js +8 -0
- package/chat/utils.mjs +65 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +427 -169
- package/index.d.ts +427 -169
- package/index.js +1 -1
- package/index.mjs +34 -27
- package/messages/index.js +1 -1
- package/messages/index.mjs +38 -16
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -7
- package/components/Action.js +0 -8
- package/components/Action.mjs +0 -45
- package/components/ActionGroup.js +0 -8
- package/components/ActionGroup.mjs +0 -36
- package/components/Attachment.js +0 -8
- package/components/Attachment.mjs +0 -50
- package/components/AttachmentGroup.js +0 -8
- package/components/AttachmentGroup.mjs +0 -64
- package/components/Chat.js +0 -8
- package/components/Chat.mjs +0 -214
- package/components/ChatMessage.js +0 -8
- package/components/ChatMessage.mjs +0 -63
- package/components/ChatToolbar.js +0 -8
- package/components/ChatToolbar.mjs +0 -33
- package/components/DateMarker.js +0 -8
- package/components/DateMarker.mjs +0 -19
- package/components/MessageGroup.js +0 -8
- package/components/MessageGroup.mjs +0 -67
- package/components/NewMessage.js +0 -8
- package/components/NewMessage.mjs +0 -106
- package/components/base/FocusableUponSelection.js +0 -8
- package/components/base/SelectableItemsContainer.js +0 -8
- package/components/base/SelectableItemsContainer.mjs +0 -42
- package/components/templates/HeroCard.js +0 -8
- package/components/templates/HeroCard.mjs +0 -44
- package/utils.js +0 -8
- /package/{ViewItem.js → chat/ViewItem.js} +0 -0
- /package/{ViewItem.mjs → chat/ViewItem.mjs} +0 -0
|
@@ -0,0 +1,274 @@
|
|
|
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 j } from "@progress/kendo-react-common";
|
|
10
|
+
import { Button as G } from "@progress/kendo-react-buttons";
|
|
11
|
+
import { downloadIcon as fe, chevronUpIcon as pe, chevronDownIcon as ge, checkCircleIcon as be, undoIcon as ke, copyIcon as Ce } from "@progress/kendo-svg-icons";
|
|
12
|
+
import { useLocalization as ye, provideIntlService as xe, registerForIntl as Ee } from "@progress/kendo-react-intl";
|
|
13
|
+
import { ContextMenu as he, MenuItem as Ie } from "@progress/kendo-react-layout";
|
|
14
|
+
import { copyToClipboard as we, getDeletedMessageText as Me, getMessageById as ve, isAuthor as R, convertTextToLinkedContent as H, scrollToMessageById as Te } from "../utils.mjs";
|
|
15
|
+
import { useChatContext as De } from "./ChatContext.mjs";
|
|
16
|
+
import Ne from "./elements/FileBox.mjs";
|
|
17
|
+
import { downloadAllFiles as J, messages as h, downloadAll as Q, collapseMessage as Z, expandMessage as _ } from "../../messages/index.mjs";
|
|
18
|
+
const ee = t.forwardRef(
|
|
19
|
+
(i, u) => {
|
|
20
|
+
const {
|
|
21
|
+
item: a,
|
|
22
|
+
template: I,
|
|
23
|
+
onRequestSelection: w,
|
|
24
|
+
tabIndex: te = -1,
|
|
25
|
+
dateFormat: F = "g",
|
|
26
|
+
selected: l,
|
|
27
|
+
allowMessageCollapse: m,
|
|
28
|
+
messageToolbarActions: d,
|
|
29
|
+
messageContextMenuActions: f,
|
|
30
|
+
isSender: p
|
|
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: T
|
|
43
|
+
} = De(), [z, D] = t.useState(!1), [ae, B] = t.useState(!1), [C, se] = t.useState(!0), [ne, P] = t.useState(!1), o = ye(), W = t.useRef({ left: 0, top: 0 }), y = t.useCallback(() => {
|
|
44
|
+
a != null && a.text && we(a.text), k && (k(!0), setTimeout(() => {
|
|
45
|
+
k(!1);
|
|
46
|
+
}, 3e3));
|
|
47
|
+
}, [a, k]), N = t.useCallback((e) => {
|
|
48
|
+
e.stopPropagation(), se((s) => !s);
|
|
49
|
+
}, []), le = t.useCallback(() => {
|
|
50
|
+
P(!1);
|
|
51
|
+
}, []), oe = t.useCallback((e) => {
|
|
52
|
+
(e.key === "Tab" || e.key === "Enter" || e.key === " " || e.key === "ArrowUp" || e.key === "ArrowDown") && P(!0);
|
|
53
|
+
}, []), S = t.useRef(null);
|
|
54
|
+
t.useEffect(() => {
|
|
55
|
+
l && S.current && S.current.focus();
|
|
56
|
+
}, [l]);
|
|
57
|
+
const O = t.useCallback((e) => {
|
|
58
|
+
W.current = { left: e.pageX, top: e.pageY }, e.preventDefault(), B(!0), D(!0);
|
|
59
|
+
}, []), U = t.useCallback(() => {
|
|
60
|
+
B(!1), D(!1);
|
|
61
|
+
}, []), x = t.useCallback(
|
|
62
|
+
(e, s) => !e.isDeleted && e.text ? e.text : Me(s, o),
|
|
63
|
+
[o]
|
|
64
|
+
), q = 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)), D(!1);
|
|
68
|
+
},
|
|
69
|
+
[a, v, g, y]
|
|
70
|
+
), X = t.useCallback(() => {
|
|
71
|
+
if (a.replyToId) {
|
|
72
|
+
const e = ve(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
|
+
Te(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" }, H(
|
|
89
|
+
x(e, R(c, e))
|
|
90
|
+
))
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return null;
|
|
95
|
+
}, [a.replyToId, L, c, x, b]), Y = t.useCallback(() => {
|
|
96
|
+
const e = [
|
|
97
|
+
{
|
|
98
|
+
id: "reply",
|
|
99
|
+
label: "Reply",
|
|
100
|
+
svgIcon: ke
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: "copy",
|
|
104
|
+
label: "Copy",
|
|
105
|
+
svgIcon: Ce
|
|
106
|
+
}
|
|
107
|
+
], s = f ? [
|
|
108
|
+
...e.map((n) => f.find(
|
|
109
|
+
(de) => de.id === n.id
|
|
110
|
+
) || n),
|
|
111
|
+
...f.filter(
|
|
112
|
+
(n) => !e.some((E) => E.id === n.id)
|
|
113
|
+
)
|
|
114
|
+
] : e;
|
|
115
|
+
return /* @__PURE__ */ t.createElement(
|
|
116
|
+
he,
|
|
117
|
+
{
|
|
118
|
+
onSelect: q,
|
|
119
|
+
onClose: U,
|
|
120
|
+
vertical: !0,
|
|
121
|
+
show: z,
|
|
122
|
+
offset: W.current
|
|
123
|
+
},
|
|
124
|
+
s.map(
|
|
125
|
+
(n) => n.id === "delete" && !p ? null : /* @__PURE__ */ t.createElement(
|
|
126
|
+
Ie,
|
|
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
|
+
}, [f, q, U, z, p]), $ = t.useCallback(() => a.files && a.files.length > 1 ? /* @__PURE__ */ t.createElement("div", { className: "k-chat-download-button-wrapper" }, /* @__PURE__ */ t.createElement(
|
|
138
|
+
G,
|
|
139
|
+
{
|
|
140
|
+
className: "k-chat-download-button",
|
|
141
|
+
fillMode: "flat",
|
|
142
|
+
themeColor: "base",
|
|
143
|
+
svgIcon: fe,
|
|
144
|
+
onClick: (e) => {
|
|
145
|
+
e.stopPropagation(), r && r(a.files, a);
|
|
146
|
+
},
|
|
147
|
+
"aria-label": o.toLanguageString(
|
|
148
|
+
J,
|
|
149
|
+
h[J]
|
|
150
|
+
)
|
|
151
|
+
},
|
|
152
|
+
/* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, o.toLanguageString(Q, h[Q]))
|
|
153
|
+
)) : null, [a, r, o]), re = 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
|
+
"k-active": ae
|
|
168
|
+
}),
|
|
169
|
+
onClick: () => w(l ? void 0 : a.selectionIndex),
|
|
170
|
+
onContextMenu: O
|
|
171
|
+
},
|
|
172
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-bubble-content" }, /* @__PURE__ */ t.createElement("span", { className: "k-chat-bubble-text" }, !a.isDeleted && X(), H(x(a, R(c, a)))), a.files && /* @__PURE__ */ t.createElement(
|
|
173
|
+
Ne,
|
|
174
|
+
{
|
|
175
|
+
files: a.files,
|
|
176
|
+
message: a,
|
|
177
|
+
onFileAction: V,
|
|
178
|
+
onDownload: (e) => r == null ? void 0 : r(e, a),
|
|
179
|
+
renderInTextarea: !1,
|
|
180
|
+
fileActions: K
|
|
181
|
+
}
|
|
182
|
+
), $()),
|
|
183
|
+
m && /* @__PURE__ */ t.createElement(
|
|
184
|
+
"span",
|
|
185
|
+
{
|
|
186
|
+
className: "k-bubble-expandable-indicator",
|
|
187
|
+
onClick: N,
|
|
188
|
+
role: "button",
|
|
189
|
+
"aria-label": C ? o.toLanguageString(
|
|
190
|
+
Z,
|
|
191
|
+
h[Z]
|
|
192
|
+
) : o.toLanguageString(
|
|
193
|
+
_,
|
|
194
|
+
h[_]
|
|
195
|
+
),
|
|
196
|
+
tabIndex: 0,
|
|
197
|
+
onKeyDown: (e) => {
|
|
198
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), N(e));
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
/* @__PURE__ */ t.createElement(j, { icon: C ? pe : ge, size: "medium" })
|
|
202
|
+
)
|
|
203
|
+
), Y());
|
|
204
|
+
return null;
|
|
205
|
+
}, [
|
|
206
|
+
a,
|
|
207
|
+
I,
|
|
208
|
+
m,
|
|
209
|
+
C,
|
|
210
|
+
l,
|
|
211
|
+
O,
|
|
212
|
+
X,
|
|
213
|
+
x,
|
|
214
|
+
c,
|
|
215
|
+
V,
|
|
216
|
+
K,
|
|
217
|
+
$,
|
|
218
|
+
N,
|
|
219
|
+
o,
|
|
220
|
+
Y,
|
|
221
|
+
r
|
|
222
|
+
]), ce = t.useCallback(() => {
|
|
223
|
+
let e = null;
|
|
224
|
+
return a.timestamp && (e = /* @__PURE__ */ t.createElement("time", { className: "k-message-time", "aria-hidden": !l }, xe({ props: i }).formatDate(a.timestamp, F))), e;
|
|
225
|
+
}, [a.timestamp, l, F, i]), ie = t.useCallback(() => {
|
|
226
|
+
let e = null;
|
|
227
|
+
return a.status && l && (T ? e = t.createElement(T, { item: a }) : e = /* @__PURE__ */ t.createElement("span", { className: "k-message-status" }, /* @__PURE__ */ t.createElement(j, { icon: be, size: "xsmall" }), a.status)), e;
|
|
228
|
+
}, [a, l, T]), ue = t.useCallback(() => A({ "k-focus": l, "k-message-removed": a.isDeleted }, "k-message"), [l, a.isDeleted]), me = 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" && !p ? null : /* @__PURE__ */ t.createElement(
|
|
229
|
+
G,
|
|
230
|
+
{
|
|
231
|
+
key: e.id,
|
|
232
|
+
fillMode: "flat",
|
|
233
|
+
className: "k-toolbar-button",
|
|
234
|
+
themeColor: "base",
|
|
235
|
+
icon: e.icon,
|
|
236
|
+
svgIcon: e.svgIcon,
|
|
237
|
+
onClick: (s) => {
|
|
238
|
+
s.stopPropagation(), e.id === "copy" && !a.isDeleted ? y() : e.id === "reply" && g(a), M && M(e, s, a);
|
|
239
|
+
},
|
|
240
|
+
onMouseDown: (s) => s.preventDefault()
|
|
241
|
+
}
|
|
242
|
+
))), [y, p, a, d, M, g]);
|
|
243
|
+
return /* @__PURE__ */ t.createElement(
|
|
244
|
+
"div",
|
|
245
|
+
{
|
|
246
|
+
"data-message-id": a.id,
|
|
247
|
+
className: ue(),
|
|
248
|
+
tabIndex: te,
|
|
249
|
+
onMouseDown: le,
|
|
250
|
+
onKeyDown: oe,
|
|
251
|
+
onFocus: (e) => {
|
|
252
|
+
ne && w(a.selectionIndex);
|
|
253
|
+
},
|
|
254
|
+
ref: (e) => {
|
|
255
|
+
S.current = e, typeof u == "function" ? u(e) : u && (u.current = e);
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
ce(),
|
|
259
|
+
re(),
|
|
260
|
+
ie(),
|
|
261
|
+
me()
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
);
|
|
265
|
+
ee.displayName = "ChatMessage";
|
|
266
|
+
class Se extends t.Component {
|
|
267
|
+
render() {
|
|
268
|
+
return /* @__PURE__ */ t.createElement(ee, { ...this.props });
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
Ee(Se);
|
|
272
|
+
export {
|
|
273
|
+
ee as ChatMessage
|
|
274
|
+
};
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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;
|