@progress/kendo-react-conversational-ui 12.0.0-develop.1 → 12.0.0-develop.11
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/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +179 -174
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +102 -112
- package/chat/components/elements/FileBox.js +1 -1
- package/chat/components/elements/FileBox.mjs +15 -12
- package/chat/utils/fieldMapping.js +1 -1
- package/chat/utils/fieldMapping.mjs +47 -45
- package/chat/utils.js +1 -1
- package/chat/utils.mjs +25 -23
- package/codemods/v12/author-id.js +9 -0
- package/codemods/v12/chat-send-message.js +9 -0
- package/codemods/v12/index.js +9 -0
- package/codemods/v12/message-template.js +9 -0
- package/codemods/v12/send-message.js +9 -0
- package/codemods/v12/show-toolbar.js +9 -0
- package/codemods/v12/toolbar-action-execute.js +9 -0
- package/codemods/v12/toolbar.js +9 -0
- package/codemods/v12/utils.js +9 -0
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/index.d.mts +4 -4
- package/index.d.ts +4 -4
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +3 -3
- package/package.json +57 -8
|
@@ -6,75 +6,75 @@
|
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
8
|
import * as t from "react";
|
|
9
|
-
import { classNames as A, IconWrap as
|
|
10
|
-
import { Button as
|
|
11
|
-
import { downloadIcon as
|
|
12
|
-
import { useLocalization as
|
|
13
|
-
import { ContextMenu as
|
|
14
|
-
import { copyToClipboard as
|
|
15
|
-
import { useChatContext as
|
|
16
|
-
import
|
|
17
|
-
import { downloadAllFiles as
|
|
18
|
-
const
|
|
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 be, checkCircleIcon as ge, 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
19
|
(i, u) => {
|
|
20
20
|
const {
|
|
21
21
|
item: a,
|
|
22
22
|
template: I,
|
|
23
23
|
onRequestSelection: w,
|
|
24
|
-
tabIndex:
|
|
24
|
+
tabIndex: te = -1,
|
|
25
25
|
dateFormat: F = "g",
|
|
26
26
|
selected: l,
|
|
27
27
|
allowMessageCollapse: m,
|
|
28
28
|
messageToolbarActions: d,
|
|
29
|
-
messageContextMenuActions:
|
|
30
|
-
isSender:
|
|
29
|
+
messageContextMenuActions: f,
|
|
30
|
+
isSender: p
|
|
31
31
|
} = i, {
|
|
32
|
-
setReplyToMessage:
|
|
32
|
+
setReplyToMessage: b,
|
|
33
33
|
messages: L,
|
|
34
34
|
user: c,
|
|
35
|
-
internalScrollContainerRef:
|
|
35
|
+
internalScrollContainerRef: g,
|
|
36
36
|
onToolbarAction: M,
|
|
37
37
|
onContextMenuAction: v,
|
|
38
38
|
onFileAction: V,
|
|
39
39
|
onDownload: r,
|
|
40
40
|
fileActions: K,
|
|
41
41
|
setShowCopyNotification: k,
|
|
42
|
-
statusTemplate:
|
|
43
|
-
} =
|
|
44
|
-
a != null && a.text &&
|
|
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
45
|
k(!1);
|
|
46
46
|
}, 3e3));
|
|
47
47
|
}, [a, k]), N = t.useCallback((e) => {
|
|
48
|
-
e.stopPropagation(),
|
|
49
|
-
}, []),
|
|
50
|
-
|
|
51
|
-
}, []),
|
|
52
|
-
(e.key === "Tab" || e.key === "Enter" || e.key === " " || e.key === "ArrowUp" || e.key === "ArrowDown") &&
|
|
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
53
|
}, []), S = t.useRef(null);
|
|
54
54
|
t.useEffect(() => {
|
|
55
55
|
l && S.current && S.current.focus();
|
|
56
56
|
}, [l]);
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
}, []),
|
|
60
|
-
|
|
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
61
|
}, []), x = t.useCallback(
|
|
62
|
-
(e, s) => !e.isDeleted && e.text ? e.text :
|
|
62
|
+
(e, s) => !e.isDeleted && e.text ? e.text : Me(s, o),
|
|
63
63
|
[o]
|
|
64
|
-
),
|
|
64
|
+
), q = t.useCallback(
|
|
65
65
|
(e) => {
|
|
66
66
|
var s;
|
|
67
|
-
(s = e.item) != null && s.text && (e.item.data.id === "copy" && !a.isDeleted ? y() : e.item.data.id === "reply" &&
|
|
67
|
+
(s = e.item) != null && s.text && (e.item.data.id === "copy" && !a.isDeleted ? y() : e.item.data.id === "reply" && b(a), v && v(e.item.data, e, a)), D(!1);
|
|
68
68
|
},
|
|
69
|
-
[a, v,
|
|
70
|
-
),
|
|
69
|
+
[a, v, b, y]
|
|
70
|
+
), X = t.useCallback(() => {
|
|
71
71
|
if (a.replyToId) {
|
|
72
|
-
const e =
|
|
72
|
+
const e = ve(L, a.replyToId);
|
|
73
73
|
if (e) {
|
|
74
74
|
const s = (n) => {
|
|
75
75
|
n.preventDefault(), n.stopPropagation();
|
|
76
|
-
const E =
|
|
77
|
-
|
|
76
|
+
const E = g == null ? void 0 : g.current;
|
|
77
|
+
Te(e.id, E);
|
|
78
78
|
};
|
|
79
79
|
return /* @__PURE__ */ t.createElement(
|
|
80
80
|
"div",
|
|
@@ -85,45 +85,45 @@ const _ = t.forwardRef(
|
|
|
85
85
|
),
|
|
86
86
|
onClick: s
|
|
87
87
|
},
|
|
88
|
-
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" },
|
|
88
|
+
/* @__PURE__ */ t.createElement("div", { className: "k-message-reference-content" }, H(
|
|
89
89
|
x(e, R(c, e))
|
|
90
90
|
))
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
return null;
|
|
95
|
-
}, [a.replyToId, L, c, x,
|
|
95
|
+
}, [a.replyToId, L, c, x, g]), Y = t.useCallback(() => {
|
|
96
96
|
const e = [
|
|
97
97
|
{
|
|
98
98
|
id: "reply",
|
|
99
99
|
label: "Reply",
|
|
100
|
-
svgIcon:
|
|
100
|
+
svgIcon: ke
|
|
101
101
|
},
|
|
102
102
|
{
|
|
103
103
|
id: "copy",
|
|
104
104
|
label: "Copy",
|
|
105
|
-
svgIcon:
|
|
105
|
+
svgIcon: Ce
|
|
106
106
|
}
|
|
107
|
-
], s =
|
|
108
|
-
...e.map((n) =>
|
|
109
|
-
(
|
|
107
|
+
], s = f ? [
|
|
108
|
+
...e.map((n) => f.find(
|
|
109
|
+
(de) => de.id === n.id
|
|
110
110
|
) || n),
|
|
111
|
-
...
|
|
111
|
+
...f.filter(
|
|
112
112
|
(n) => !e.some((E) => E.id === n.id)
|
|
113
113
|
)
|
|
114
114
|
] : e;
|
|
115
115
|
return /* @__PURE__ */ t.createElement(
|
|
116
|
-
|
|
116
|
+
he,
|
|
117
117
|
{
|
|
118
|
-
onSelect:
|
|
119
|
-
onClose:
|
|
118
|
+
onSelect: q,
|
|
119
|
+
onClose: U,
|
|
120
120
|
vertical: !0,
|
|
121
|
-
show:
|
|
122
|
-
offset:
|
|
121
|
+
show: z,
|
|
122
|
+
offset: W.current
|
|
123
123
|
},
|
|
124
124
|
s.map(
|
|
125
|
-
(n) => n.id === "delete" && !
|
|
126
|
-
|
|
125
|
+
(n) => n.id === "delete" && !p ? null : /* @__PURE__ */ t.createElement(
|
|
126
|
+
Ie,
|
|
127
127
|
{
|
|
128
128
|
key: n.id,
|
|
129
129
|
text: n.label,
|
|
@@ -134,25 +134,25 @@ const _ = t.forwardRef(
|
|
|
134
134
|
)
|
|
135
135
|
)
|
|
136
136
|
);
|
|
137
|
-
}, [
|
|
138
|
-
|
|
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
139
|
{
|
|
140
140
|
className: "k-chat-download-button",
|
|
141
141
|
fillMode: "flat",
|
|
142
142
|
themeColor: "base",
|
|
143
|
-
svgIcon:
|
|
143
|
+
svgIcon: fe,
|
|
144
144
|
onClick: (e) => {
|
|
145
145
|
e.stopPropagation(), r && r(a.files, a);
|
|
146
146
|
},
|
|
147
147
|
"aria-label": o.toLanguageString(
|
|
148
|
-
|
|
149
|
-
h[
|
|
148
|
+
J,
|
|
149
|
+
h[J]
|
|
150
150
|
)
|
|
151
151
|
},
|
|
152
|
-
/* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, o.toLanguageString(
|
|
153
|
-
)) : null, [a, r, o]),
|
|
152
|
+
/* @__PURE__ */ t.createElement("span", { className: "k-button-text" }, o.toLanguageString(Q, h[Q]))
|
|
153
|
+
)) : null, [a, r, o]), re = t.useCallback(() => {
|
|
154
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)));
|
|
155
|
+
return /* @__PURE__ */ t.createElement("div", { className: "k-bubble 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
156
|
if (I) {
|
|
157
157
|
const e = I;
|
|
158
158
|
return /* @__PURE__ */ t.createElement(e, { item: a });
|
|
@@ -163,32 +163,23 @@ const _ = t.forwardRef(
|
|
|
163
163
|
className: A("k-chat-bubble", "k-bubble", {
|
|
164
164
|
"k-bubble-expandable": m,
|
|
165
165
|
"k-expanded": m && C,
|
|
166
|
-
"k-selected": l
|
|
166
|
+
"k-selected": l,
|
|
167
|
+
"k-active": ae
|
|
167
168
|
}),
|
|
168
|
-
|
|
169
|
+
onClick: () => w(l ? void 0 : a.selectionIndex),
|
|
170
|
+
onContextMenu: O
|
|
169
171
|
},
|
|
170
|
-
/* @__PURE__ */ t.createElement(
|
|
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,
|
|
172
174
|
{
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
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
|
-
),
|
|
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
|
+
), $()),
|
|
192
183
|
m && /* @__PURE__ */ t.createElement(
|
|
193
184
|
"span",
|
|
194
185
|
{
|
|
@@ -196,20 +187,20 @@ const _ = t.forwardRef(
|
|
|
196
187
|
onClick: N,
|
|
197
188
|
role: "button",
|
|
198
189
|
"aria-label": C ? o.toLanguageString(
|
|
199
|
-
Q,
|
|
200
|
-
h[Q]
|
|
201
|
-
) : o.toLanguageString(
|
|
202
190
|
Z,
|
|
203
191
|
h[Z]
|
|
192
|
+
) : o.toLanguageString(
|
|
193
|
+
_,
|
|
194
|
+
h[_]
|
|
204
195
|
),
|
|
205
196
|
tabIndex: 0,
|
|
206
197
|
onKeyDown: (e) => {
|
|
207
198
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), N(e));
|
|
208
199
|
}
|
|
209
200
|
},
|
|
210
|
-
/* @__PURE__ */ t.createElement(
|
|
201
|
+
/* @__PURE__ */ t.createElement(j, { icon: C ? pe : be, size: "medium" })
|
|
211
202
|
)
|
|
212
|
-
),
|
|
203
|
+
), Y());
|
|
213
204
|
return null;
|
|
214
205
|
}, [
|
|
215
206
|
a,
|
|
@@ -217,25 +208,25 @@ const _ = t.forwardRef(
|
|
|
217
208
|
m,
|
|
218
209
|
C,
|
|
219
210
|
l,
|
|
220
|
-
|
|
221
|
-
|
|
211
|
+
O,
|
|
212
|
+
X,
|
|
222
213
|
x,
|
|
223
214
|
c,
|
|
224
215
|
V,
|
|
225
216
|
K,
|
|
226
|
-
|
|
217
|
+
$,
|
|
227
218
|
N,
|
|
228
219
|
o,
|
|
229
|
-
|
|
220
|
+
Y,
|
|
230
221
|
r
|
|
231
|
-
]),
|
|
222
|
+
]), ce = t.useCallback(() => {
|
|
232
223
|
let e = null;
|
|
233
|
-
return a.timestamp && (e = /* @__PURE__ */ t.createElement("time", { className: "k-message-time", "aria-hidden": !l },
|
|
234
|
-
}, [a.timestamp, l, F, i]),
|
|
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(() => {
|
|
235
226
|
let e = null;
|
|
236
|
-
return a.status && l && (
|
|
237
|
-
}, [a, l,
|
|
238
|
-
|
|
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: ge, 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,
|
|
239
230
|
{
|
|
240
231
|
key: e.id,
|
|
241
232
|
fillMode: "flat",
|
|
@@ -244,41 +235,40 @@ const _ = t.forwardRef(
|
|
|
244
235
|
icon: e.icon,
|
|
245
236
|
svgIcon: e.svgIcon,
|
|
246
237
|
onClick: (s) => {
|
|
247
|
-
s.stopPropagation(), e.id === "copy" && !a.isDeleted ? y() : e.id === "reply" &&
|
|
238
|
+
s.stopPropagation(), e.id === "copy" && !a.isDeleted ? y() : e.id === "reply" && b(a), M && M(e, s, a);
|
|
248
239
|
},
|
|
249
240
|
onMouseDown: (s) => s.preventDefault()
|
|
250
241
|
}
|
|
251
|
-
))), [y,
|
|
242
|
+
))), [y, p, a, d, M, b]);
|
|
252
243
|
return /* @__PURE__ */ t.createElement(
|
|
253
244
|
"div",
|
|
254
245
|
{
|
|
255
246
|
"data-message-id": a.id,
|
|
256
|
-
className:
|
|
257
|
-
tabIndex:
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
onKeyDown: ne,
|
|
247
|
+
className: ue(),
|
|
248
|
+
tabIndex: te,
|
|
249
|
+
onMouseDown: le,
|
|
250
|
+
onKeyDown: oe,
|
|
261
251
|
onFocus: (e) => {
|
|
262
|
-
|
|
252
|
+
ne && w(a.selectionIndex);
|
|
263
253
|
},
|
|
264
254
|
ref: (e) => {
|
|
265
255
|
S.current = e, typeof u == "function" ? u(e) : u && (u.current = e);
|
|
266
256
|
}
|
|
267
257
|
},
|
|
268
|
-
|
|
269
|
-
le(),
|
|
258
|
+
ce(),
|
|
270
259
|
re(),
|
|
271
|
-
ie()
|
|
260
|
+
ie(),
|
|
261
|
+
me()
|
|
272
262
|
);
|
|
273
263
|
}
|
|
274
264
|
);
|
|
275
|
-
|
|
276
|
-
class
|
|
265
|
+
ee.displayName = "ChatMessage";
|
|
266
|
+
class Se extends t.Component {
|
|
277
267
|
render() {
|
|
278
|
-
return /* @__PURE__ */ t.createElement(
|
|
268
|
+
return /* @__PURE__ */ t.createElement(ee, { ...this.props });
|
|
279
269
|
}
|
|
280
270
|
}
|
|
281
|
-
|
|
271
|
+
Ee(Se);
|
|
282
272
|
export {
|
|
283
|
-
|
|
273
|
+
ee as ChatMessage
|
|
284
274
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";const
|
|
8
|
+
"use strict";const C=require("react"),f=require("@progress/kendo-react-common"),g=require("@progress/kendo-react-buttons"),l=require("@progress/kendo-svg-icons"),b=require("@progress/kendo-react-intl"),o=require("../../../messages/index.js");function F(r){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const n in r)if(n!=="default"){const c=Object.getOwnPropertyDescriptor(r,n);Object.defineProperty(i,n,c.get?c:{enumerable:!0,get:()=>r[n]})}}return i.default=r,Object.freeze(i)}const a=F(C),M=r=>{const{files:i,onFileRemove:n,onFileAction:c,onDownload:m,fileActions:k,renderInTextarea:I=!1}=r,u=b.useLocalization(),h=[{id:"download",label:"Download",svgIcon:l.downloadIcon}],d=k||h,x=e=>{if(e==null)return"";if(e===0)return"0 B";const s=1024,t=["B","KB","MB","GB","TB"],p=Math.floor(Math.log(e)/Math.log(s));return`${parseFloat((e/Math.pow(s,p)).toFixed(2))} ${t[p]}`},B=e=>"."+e.split(".").pop()||"",E=(e,s)=>{e.item.id==="download"&&(m==null||m([s])),c==null||c(e.item,e,s)},v=e=>I?a.createElement(g.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:t=>{t.stopPropagation(),n==null||n(e.name)},"aria-label":`${u.toLanguageString(o.removeFile,o.messages[o.removeFile])} ${e.name}`}):"uid"in e||!("rawFile"in e)?d.length>0&&a.createElement(g.DropDownButton,{fillMode:"flat",themeColor:"base",svgIcon:l.moreVerticalIcon,onClick:t=>{t.syntheticEvent.stopPropagation()},onItemClick:t=>E(t,e),items:d.map(t=>({id:t.id,icon:t.icon,text:t.label,svgIcon:t.svgIcon})),"aria-label":`${u.toLanguageString(o.fileActions,o.messages[o.fileActions])} ${e.name}`}):a.createElement(g.Button,{fillMode:"flat",themeColor:"base",svgIcon:l.xIcon,onClick:t=>{t.stopPropagation(),n==null||n(e.name)},"aria-label":`${u.toLanguageString(o.removeFile,o.messages[o.removeFile])} ${e.name}`});return a.createElement("ul",{className:"k-chat-file-wrapper"},i.map(e=>a.createElement("li",{key:e.name,className:"k-chat-file"},a.createElement(f.IconWrap,{size:"xxlarge",...f.getFileExtensionIcon(B(e.name))}),a.createElement("div",{className:"k-chat-file-info"},a.createElement("span",{className:"k-chat-file-name"},e.name),a.createElement("span",{className:"k-chat-file-size"},x(e.size))),v(e))))};module.exports=M;
|
|
@@ -7,22 +7,22 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as a from "react";
|
|
9
9
|
import { IconWrap as $, getFileExtensionIcon as F } from "@progress/kendo-react-common";
|
|
10
|
-
import { Button as
|
|
10
|
+
import { Button as g, DropDownButton as M } from "@progress/kendo-react-buttons";
|
|
11
11
|
import { xIcon as d, moreVerticalIcon as w, downloadIcon as z } from "@progress/kendo-svg-icons";
|
|
12
12
|
import { useLocalization as v } from "@progress/kendo-react-intl";
|
|
13
|
-
import { removeFile as
|
|
14
|
-
const
|
|
15
|
-
const { files: h, onFileRemove: o, onFileAction:
|
|
13
|
+
import { removeFile as i, messages as c, fileActions as f } from "../../../messages/index.mjs";
|
|
14
|
+
const T = (u) => {
|
|
15
|
+
const { files: h, onFileRemove: o, onFileAction: r, onDownload: l, fileActions: I, renderInTextarea: k = !1 } = u, s = v(), m = I || [{ id: "download", label: "Download", svgIcon: z }], E = (e) => {
|
|
16
16
|
if (e == null)
|
|
17
17
|
return "";
|
|
18
18
|
if (e === 0)
|
|
19
19
|
return "0 B";
|
|
20
|
-
const n = 1024, t = ["B", "KB", "MB", "GB", "TB"],
|
|
21
|
-
return `${parseFloat((e / Math.pow(n,
|
|
20
|
+
const n = 1024, t = ["B", "KB", "MB", "GB", "TB"], p = Math.floor(Math.log(e) / Math.log(n));
|
|
21
|
+
return `${parseFloat((e / Math.pow(n, p)).toFixed(2))} ${t[p]}`;
|
|
22
22
|
}, x = (e) => "." + e.split(".").pop() || "", B = (e, n) => {
|
|
23
|
-
e.item.id === "download" && (l == null || l([n])),
|
|
23
|
+
e.item.id === "download" && (l == null || l([n])), r == null || r(e.item, e, n);
|
|
24
24
|
}, C = (e) => k ? /* @__PURE__ */ a.createElement(
|
|
25
|
-
|
|
25
|
+
g,
|
|
26
26
|
{
|
|
27
27
|
fillMode: "flat",
|
|
28
28
|
themeColor: "base",
|
|
@@ -30,7 +30,7 @@ const D = (u) => {
|
|
|
30
30
|
onClick: (t) => {
|
|
31
31
|
t.stopPropagation(), o == null || o(e.name);
|
|
32
32
|
},
|
|
33
|
-
"aria-label": `${s.toLanguageString(
|
|
33
|
+
"aria-label": `${s.toLanguageString(i, c[i])} ${e.name}`
|
|
34
34
|
}
|
|
35
35
|
) : "uid" in e || !("rawFile" in e) ? m.length > 0 && /* @__PURE__ */ a.createElement(
|
|
36
36
|
M,
|
|
@@ -38,6 +38,9 @@ const D = (u) => {
|
|
|
38
38
|
fillMode: "flat",
|
|
39
39
|
themeColor: "base",
|
|
40
40
|
svgIcon: w,
|
|
41
|
+
onClick: (t) => {
|
|
42
|
+
t.syntheticEvent.stopPropagation();
|
|
43
|
+
},
|
|
41
44
|
onItemClick: (t) => B(t, e),
|
|
42
45
|
items: m.map((t) => ({
|
|
43
46
|
id: t.id,
|
|
@@ -51,7 +54,7 @@ const D = (u) => {
|
|
|
51
54
|
)} ${e.name}`
|
|
52
55
|
}
|
|
53
56
|
) : /* @__PURE__ */ a.createElement(
|
|
54
|
-
|
|
57
|
+
g,
|
|
55
58
|
{
|
|
56
59
|
fillMode: "flat",
|
|
57
60
|
themeColor: "base",
|
|
@@ -59,11 +62,11 @@ const D = (u) => {
|
|
|
59
62
|
onClick: (t) => {
|
|
60
63
|
t.stopPropagation(), o == null || o(e.name);
|
|
61
64
|
},
|
|
62
|
-
"aria-label": `${s.toLanguageString(
|
|
65
|
+
"aria-label": `${s.toLanguageString(i, c[i])} ${e.name}`
|
|
63
66
|
}
|
|
64
67
|
);
|
|
65
68
|
return /* @__PURE__ */ a.createElement("ul", { className: "k-chat-file-wrapper" }, h.map((e) => /* @__PURE__ */ a.createElement("li", { key: e.name, className: "k-chat-file" }, /* @__PURE__ */ a.createElement($, { size: "xxlarge", ...F(x(e.name)) }), /* @__PURE__ */ a.createElement("div", { className: "k-chat-file-info" }, /* @__PURE__ */ a.createElement("span", { className: "k-chat-file-name" }, e.name), /* @__PURE__ */ a.createElement("span", { className: "k-chat-file-size" }, E(e.size))), C(e))));
|
|
66
69
|
};
|
|
67
70
|
export {
|
|
68
|
-
|
|
71
|
+
T as default
|
|
69
72
|
};
|
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n={textField:"text",statusField:"status",authorIdField:"authorId",authorNameField:"authorName",authorImageUrlField:"authorImageUrl",authorImageAltTextField:"authorImageAltText",idField:"id",timestampField:"timestamp",filesField:"files",attachmentsField:"attachments",replyToIdField:"replyToId",isDeletedField:"isDeleted",isPinnedField:"isPinned",typingField:"typing",suggestedActionsField:"suggestedActions"},r=(i,d={})=>{const t={...n,...d};let e;i.author&&typeof i.author=="object"?e={id:i.author.id||i.author[t.authorIdField]||i[t.authorIdField]||"",name:i.author.name||i.author[t.authorNameField]||i[t.authorNameField],avatarUrl:i.author.avatarUrl||i.author[t.authorImageUrlField]||i[t.authorImageUrlField],avatarAltText:i.author.avatarAltText||i.author[t.authorImageAltTextField]||i[t.authorImageAltTextField]}:e={id:i[t.authorIdField]||i.authorId||"",name:i[t.authorNameField]||i.authorName,avatarUrl:i[t.authorImageUrlField]||i.authorImageUrl,avatarAltText:i[t.authorImageAltTextField]||i.authorImageAltText};let o;i.timestamp?o=new Date(i.timestamp):i[t.timestampField]?o=new Date(i[t.timestampField]):o=new Date;const l={id:i.id!==void 0?i.id:i[t.idField],text:i.text!==void 0?i.text:i[t.textField]||"",author:e,timestamp:o,status:i.status!==void 0?i.status:i[t.statusField],attachments:i.attachments!==void 0?i.attachments:i[t.attachmentsField],attachmentLayout:i.attachmentLayout||"list",suggestedActions:i.suggestedActions!==void 0?i.suggestedActions:i[t.suggestedActionsField],isPinned:i.isPinned!==void 0?i.isPinned:i[t.isPinnedField]||!1,typing:i.typing!==void 0?i.typing:i[t.typingField],files:i.files!==void 0?i.files:i[t.filesField]||[]};return i.pinnedAt&&(l.pinnedAt=new Date(i.pinnedAt)),i.pinnedBy&&(l.pinnedBy=i.pinnedBy),i.replyToId!==void 0?l.replyToId=i.replyToId:i[t.replyToIdField]!==void 0&&(l.replyToId=i[t.replyToIdField]),i.isDeleted!==void 0?l.isDeleted=i.isDeleted:i[t.isDeletedField]!==void 0&&(l.isDeleted=i[t.isDeletedField]),l},u=(i,d={})=>Array.isArray(i)?i.map(t=>r(t,d)):[],F=i=>i&&typeof i.id!="undefined"&&typeof i.text=="string"&&i.author&&typeof i.author=="object"&&typeof i.author.id!="undefined"&&(i.timestamp instanceof Date||typeof i.timestamp=="string"||typeof i.timestamp=="number"),h=i=>({textField:i.textField,statusField:i.statusField,authorIdField:i.authorIdField,authorNameField:i.authorNameField,authorImageUrlField:i.authorImageUrlField,authorImageAltTextField:i.authorImageAltTextField,idField:i.idField,timestampField:i.timestampField,filesField:i.filesField,attachmentsField:i.attachmentsField,replyToIdField:i.replyToIdField,isDeletedField:i.isDeletedField,isPinnedField:i.isPinnedField,typingField:i.typingField,suggestedActionsField:i.suggestedActionsField}),a=(i,d={})=>{const t={...n,...d},e={};return i.id!==void 0&&(e[t.idField]=i.id),i.text!==void 0&&(e[t.textField]=i.text),i.status!==void 0&&(e[t.statusField]=i.status),i.timestamp!==void 0&&(e[t.timestampField]=i.timestamp),i.attachments!==void 0&&(e[t.attachmentsField]=i.attachments),i.files!==void 0&&(e[t.filesField]=i.files),i.suggestedActions!==void 0&&(e[t.suggestedActionsField]=i.suggestedActions),i.replyToId!==void 0&&(e[t.replyToIdField]=i.replyToId),i.isDeleted!==void 0&&(e[t.isDeletedField]=i.isDeleted),i.isPinned!==void 0&&(e[t.isPinnedField]=i.isPinned),i.typing!==void 0&&(e[t.typingField]=i.typing),i.author&&(i.author.id!==void 0&&(e[t.authorIdField]=i.author.id),i.author.name!==void 0&&(e[t.authorNameField]=i.author.name),i.author.avatarUrl!==void 0&&(e[t.authorImageUrlField]=i.author.avatarUrl),i.author.avatarAltText!==void 0&&(e[t.authorImageAltTextField]=i.author.avatarAltText)),i.pinnedAt!==void 0&&(e.pinnedAt=i.pinnedAt),i.pinnedBy!==void 0&&(e.pinnedBy=i.pinnedBy),i.attachmentLayout!==void 0&&(e.attachmentLayout=i.attachmentLayout),e};exports.DEFAULT_FIELD_MAPPING=n;exports.extractFieldMappingFromProps=h;exports.isStandardMessageFormat=F;exports.mapDataArrayToMessages=u;exports.mapDataToMessage=r;exports.mapMessageToCustomFormat=a;
|
|
@@ -21,59 +21,61 @@ const n = {
|
|
|
21
21
|
isPinnedField: "isPinned",
|
|
22
22
|
typingField: "typing",
|
|
23
23
|
suggestedActionsField: "suggestedActions"
|
|
24
|
-
},
|
|
25
|
-
const
|
|
24
|
+
}, r = (i, d = {}) => {
|
|
25
|
+
const t = { ...n, ...d };
|
|
26
26
|
let e;
|
|
27
|
-
|
|
28
|
-
id:
|
|
29
|
-
name:
|
|
30
|
-
avatarUrl:
|
|
31
|
-
avatarAltText:
|
|
27
|
+
i.author && typeof i.author == "object" ? e = {
|
|
28
|
+
id: i.author.id || i.author[t.authorIdField] || i[t.authorIdField] || "",
|
|
29
|
+
name: i.author.name || i.author[t.authorNameField] || i[t.authorNameField],
|
|
30
|
+
avatarUrl: i.author.avatarUrl || i.author[t.authorImageUrlField] || i[t.authorImageUrlField],
|
|
31
|
+
avatarAltText: i.author.avatarAltText || i.author[t.authorImageAltTextField] || i[t.authorImageAltTextField]
|
|
32
32
|
} : e = {
|
|
33
|
-
id: t
|
|
34
|
-
name: t
|
|
35
|
-
avatarUrl: t
|
|
36
|
-
avatarAltText: t
|
|
33
|
+
id: i[t.authorIdField] || i.authorId || "",
|
|
34
|
+
name: i[t.authorNameField] || i.authorName,
|
|
35
|
+
avatarUrl: i[t.authorImageUrlField] || i.authorImageUrl,
|
|
36
|
+
avatarAltText: i[t.authorImageAltTextField] || i.authorImageAltText
|
|
37
37
|
};
|
|
38
|
+
let o;
|
|
39
|
+
i.timestamp ? o = new Date(i.timestamp) : i[t.timestampField] ? o = new Date(i[t.timestampField]) : o = /* @__PURE__ */ new Date();
|
|
38
40
|
const l = {
|
|
39
|
-
id:
|
|
40
|
-
text:
|
|
41
|
+
id: i.id !== void 0 ? i.id : i[t.idField],
|
|
42
|
+
text: i.text !== void 0 ? i.text : i[t.textField] || "",
|
|
41
43
|
author: e,
|
|
42
|
-
timestamp:
|
|
43
|
-
status:
|
|
44
|
-
attachments:
|
|
45
|
-
attachmentLayout:
|
|
46
|
-
suggestedActions:
|
|
47
|
-
isPinned:
|
|
48
|
-
typing:
|
|
49
|
-
files:
|
|
44
|
+
timestamp: o,
|
|
45
|
+
status: i.status !== void 0 ? i.status : i[t.statusField],
|
|
46
|
+
attachments: i.attachments !== void 0 ? i.attachments : i[t.attachmentsField],
|
|
47
|
+
attachmentLayout: i.attachmentLayout || "list",
|
|
48
|
+
suggestedActions: i.suggestedActions !== void 0 ? i.suggestedActions : i[t.suggestedActionsField],
|
|
49
|
+
isPinned: i.isPinned !== void 0 ? i.isPinned : i[t.isPinnedField] || !1,
|
|
50
|
+
typing: i.typing !== void 0 ? i.typing : i[t.typingField],
|
|
51
|
+
files: i.files !== void 0 ? i.files : i[t.filesField] || []
|
|
50
52
|
};
|
|
51
|
-
return
|
|
52
|
-
},
|
|
53
|
-
textField:
|
|
54
|
-
statusField:
|
|
55
|
-
authorIdField:
|
|
56
|
-
authorNameField:
|
|
57
|
-
authorImageUrlField:
|
|
58
|
-
authorImageAltTextField:
|
|
59
|
-
idField:
|
|
60
|
-
timestampField:
|
|
61
|
-
filesField:
|
|
62
|
-
attachmentsField:
|
|
63
|
-
replyToIdField:
|
|
64
|
-
isDeletedField:
|
|
65
|
-
isPinnedField:
|
|
66
|
-
typingField:
|
|
67
|
-
suggestedActionsField:
|
|
68
|
-
}),
|
|
69
|
-
const
|
|
70
|
-
return
|
|
53
|
+
return i.pinnedAt && (l.pinnedAt = new Date(i.pinnedAt)), i.pinnedBy && (l.pinnedBy = i.pinnedBy), i.replyToId !== void 0 ? l.replyToId = i.replyToId : i[t.replyToIdField] !== void 0 && (l.replyToId = i[t.replyToIdField]), i.isDeleted !== void 0 ? l.isDeleted = i.isDeleted : i[t.isDeletedField] !== void 0 && (l.isDeleted = i[t.isDeletedField]), l;
|
|
54
|
+
}, u = (i, d = {}) => Array.isArray(i) ? i.map((t) => r(t, d)) : [], F = (i) => i && typeof i.id != "undefined" && typeof i.text == "string" && i.author && typeof i.author == "object" && typeof i.author.id != "undefined" && (i.timestamp instanceof Date || typeof i.timestamp == "string" || typeof i.timestamp == "number"), h = (i) => ({
|
|
55
|
+
textField: i.textField,
|
|
56
|
+
statusField: i.statusField,
|
|
57
|
+
authorIdField: i.authorIdField,
|
|
58
|
+
authorNameField: i.authorNameField,
|
|
59
|
+
authorImageUrlField: i.authorImageUrlField,
|
|
60
|
+
authorImageAltTextField: i.authorImageAltTextField,
|
|
61
|
+
idField: i.idField,
|
|
62
|
+
timestampField: i.timestampField,
|
|
63
|
+
filesField: i.filesField,
|
|
64
|
+
attachmentsField: i.attachmentsField,
|
|
65
|
+
replyToIdField: i.replyToIdField,
|
|
66
|
+
isDeletedField: i.isDeletedField,
|
|
67
|
+
isPinnedField: i.isPinnedField,
|
|
68
|
+
typingField: i.typingField,
|
|
69
|
+
suggestedActionsField: i.suggestedActionsField
|
|
70
|
+
}), f = (i, d = {}) => {
|
|
71
|
+
const t = { ...n, ...d }, e = {};
|
|
72
|
+
return i.id !== void 0 && (e[t.idField] = i.id), i.text !== void 0 && (e[t.textField] = i.text), i.status !== void 0 && (e[t.statusField] = i.status), i.timestamp !== void 0 && (e[t.timestampField] = i.timestamp), i.attachments !== void 0 && (e[t.attachmentsField] = i.attachments), i.files !== void 0 && (e[t.filesField] = i.files), i.suggestedActions !== void 0 && (e[t.suggestedActionsField] = i.suggestedActions), i.replyToId !== void 0 && (e[t.replyToIdField] = i.replyToId), i.isDeleted !== void 0 && (e[t.isDeletedField] = i.isDeleted), i.isPinned !== void 0 && (e[t.isPinnedField] = i.isPinned), i.typing !== void 0 && (e[t.typingField] = i.typing), i.author && (i.author.id !== void 0 && (e[t.authorIdField] = i.author.id), i.author.name !== void 0 && (e[t.authorNameField] = i.author.name), i.author.avatarUrl !== void 0 && (e[t.authorImageUrlField] = i.author.avatarUrl), i.author.avatarAltText !== void 0 && (e[t.authorImageAltTextField] = i.author.avatarAltText)), i.pinnedAt !== void 0 && (e.pinnedAt = i.pinnedAt), i.pinnedBy !== void 0 && (e.pinnedBy = i.pinnedBy), i.attachmentLayout !== void 0 && (e.attachmentLayout = i.attachmentLayout), e;
|
|
71
73
|
};
|
|
72
74
|
export {
|
|
73
75
|
n as DEFAULT_FIELD_MAPPING,
|
|
74
|
-
|
|
76
|
+
h as extractFieldMappingFromProps,
|
|
75
77
|
F as isStandardMessageFormat,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
u as mapDataArrayToMessages,
|
|
79
|
+
r as mapDataToMessage,
|
|
80
|
+
f as mapMessageToCustomFormat
|
|
79
81
|
};
|
package/chat/utils.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("../messages/index.js"),
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react"),n=require("../messages/index.js"),d=(t,s)=>t&&s.author&&t.id===s.author.id,g=(t,s)=>{const o=s.toLanguageString("chatSender.deletedMessage",n.messages[n.chatSenderDeletedMessage]),e=s.toLanguageString("chatReceiver.deletedMessage",n.messages[n.chatReceiverDeletedMessage]);return t?o:e},u=t=>{navigator.clipboard.writeText(t)},h=(t,s)=>t.find(o=>o.id===s),T=(t,s)=>{if(!s)return;const o=s.querySelector(`[data-message-id="${t}"]`);if(!o)return;const e=s.querySelector(".k-message-list");if(e){const c=e.getBoundingClientRect().top,a=o.getBoundingClientRect().top,l=e.scrollTop+(a-c);e.scrollTo({top:l,behavior:"smooth"})}else o.scrollIntoView({behavior:"smooth",block:"start"})},r=/(https?:\/\/[^\s]+)/g,p=t=>{if(!t)return[""];const s=t.split(r),o=[];return s.forEach(e=>{e&&r.test(e)?(r.lastIndex=0,o.push(i.createElement("a",{key:e,href:e,target:"_blank",rel:"noopener noreferrer",style:{color:"inherit",textDecoration:"underline"}},e))):e&&o.push(e)}),o};exports.URL_REGEX=r;exports.convertTextToLinkedContent=p;exports.copyToClipboard=u;exports.getDeletedMessageText=g;exports.getMessageById=h;exports.isAuthor=d;exports.scrollToMessageById=T;
|