@progress/kendo-react-conversational-ui 11.4.0 → 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.
- 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 +284 -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 +69 -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 +423 -165
- package/index.d.ts +423 -165
- 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 +7 -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,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
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
|
|
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;
|