@progress/kendo-react-conversational-ui 14.3.0-develop.1 → 14.3.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/ChatPropsAndState.d.ts +58 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +314 -306
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +153 -152
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +166 -151
- package/chat/utils/scroll.d.ts +12 -20
- package/chat/utils/scroll.js +1 -5
- package/chat/utils/scroll.mjs +114 -172
- package/dist/cdn/js/kendo-react-conversational-ui.js +1 -1
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +11 -11
package/chat/components/Chat.mjs
CHANGED
|
@@ -5,196 +5,198 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import { validatePackage as
|
|
8
|
+
import { validatePackage as St, getLicenseMessage as Mt, Keys as k, classNames as Ue, WatermarkOverlay as bt } from "@progress/kendo-react-common";
|
|
9
9
|
import o from "prop-types";
|
|
10
|
-
import * as
|
|
11
|
-
import { FloatingActionButton as
|
|
12
|
-
import { arrowDownOutlineIcon as
|
|
13
|
-
import { convertMsgsToViewItems as
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
19
|
-
import
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { ChatMessage as
|
|
24
|
-
import { packageMetadata as
|
|
25
|
-
import { ariaLabelMessageList as
|
|
26
|
-
import { useLocalization as
|
|
27
|
-
import { isStandardMessageFormat as
|
|
28
|
-
import { useChatScroll as
|
|
29
|
-
import { resolveMessageSettings as
|
|
30
|
-
const
|
|
10
|
+
import * as t from "react";
|
|
11
|
+
import { FloatingActionButton as kt } from "@progress/kendo-react-buttons";
|
|
12
|
+
import { arrowDownOutlineIcon as vt } from "@progress/kendo-svg-icons";
|
|
13
|
+
import { convertMsgsToViewItems as Et } from "../ViewItem.mjs";
|
|
14
|
+
import xt from "./ActionGroup.mjs";
|
|
15
|
+
import At from "./AttachmentGroup.mjs";
|
|
16
|
+
import wt from "./DateMarker.mjs";
|
|
17
|
+
import Ft from "./MessageGroup.mjs";
|
|
18
|
+
import Rt from "./NewMessage.mjs";
|
|
19
|
+
import Lt from "./Header.mjs";
|
|
20
|
+
import It from "./elements/PinnedMessage.mjs";
|
|
21
|
+
import Bt from "./Notification.mjs";
|
|
22
|
+
import Nt from "./ChatContext.mjs";
|
|
23
|
+
import { ChatMessage as Dt } from "./ChatMessage.mjs";
|
|
24
|
+
import { packageMetadata as Pe } from "../../package-metadata.mjs";
|
|
25
|
+
import { ariaLabelMessageList as Ve, messages as v, scrollToBottom as E, chatCopyNotification as qe } from "../../messages/index.mjs";
|
|
26
|
+
import { useLocalization as Ot } from "@progress/kendo-react-intl";
|
|
27
|
+
import { isStandardMessageFormat as Ut, mapDataArrayToMessages as Pt } from "../utils/fieldMapping.mjs";
|
|
28
|
+
import { useChatScroll as Vt, useHasScrollbar as qt } from "../utils/scroll.mjs";
|
|
29
|
+
import { resolveMessageSettings as Ht } from "../utils/messageSettings.mjs";
|
|
30
|
+
const He = t.forwardRef((je, T) => {
|
|
31
31
|
const {
|
|
32
32
|
messages: p = [],
|
|
33
33
|
messageTemplate: D,
|
|
34
|
-
messageContentTemplate:
|
|
34
|
+
messageContentTemplate: O,
|
|
35
35
|
attachmentTemplate: x,
|
|
36
|
-
width:
|
|
37
|
-
height:
|
|
36
|
+
width: We,
|
|
37
|
+
height: Ge,
|
|
38
38
|
onSendMessage: y,
|
|
39
|
-
onSuggestionClick:
|
|
39
|
+
onSuggestionClick: U,
|
|
40
40
|
onInputValueChange: P,
|
|
41
|
-
onActionExecute:
|
|
42
|
-
dir:
|
|
43
|
-
messageBox:
|
|
44
|
-
placeholder:
|
|
41
|
+
onActionExecute: A,
|
|
42
|
+
dir: d,
|
|
43
|
+
messageBox: ze,
|
|
44
|
+
placeholder: Ke,
|
|
45
45
|
className: V,
|
|
46
|
-
style:
|
|
47
|
-
message:
|
|
46
|
+
style: $e,
|
|
47
|
+
message: q = Dt,
|
|
48
48
|
authorId: i,
|
|
49
|
-
suggestions:
|
|
50
|
-
suggestionTemplate:
|
|
51
|
-
suggestionsLayout:
|
|
52
|
-
quickActionsLayout:
|
|
53
|
-
inputValue:
|
|
54
|
-
headerTemplate:
|
|
49
|
+
suggestions: Je,
|
|
50
|
+
suggestionTemplate: Qe,
|
|
51
|
+
suggestionsLayout: Xe = "scroll",
|
|
52
|
+
quickActionsLayout: H = "scroll",
|
|
53
|
+
inputValue: Ye,
|
|
54
|
+
headerTemplate: f,
|
|
55
55
|
noDataTemplate: h,
|
|
56
|
-
timestampTemplate:
|
|
57
|
-
statusTemplate:
|
|
58
|
-
userStatusTemplate:
|
|
59
|
-
allowMessageCollapse:
|
|
60
|
-
messageToolbarActions:
|
|
61
|
-
messageContextMenuActions:
|
|
62
|
-
fileActions:
|
|
63
|
-
onUnpin:
|
|
64
|
-
messageWidthMode:
|
|
65
|
-
showAvatar:
|
|
66
|
-
showUsername:
|
|
67
|
-
timestampVisibility:
|
|
68
|
-
authorMessageSettings:
|
|
69
|
-
receiverMessageSettings:
|
|
70
|
-
onToolbarAction:
|
|
71
|
-
onContextMenuAction:
|
|
72
|
-
onFileAction:
|
|
73
|
-
onDownload:
|
|
74
|
-
speechToTextConfig:
|
|
75
|
-
uploadConfig:
|
|
76
|
-
sendButtonConfig:
|
|
77
|
-
messageFilesLayout:
|
|
78
|
-
scrollToBottomButton:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
56
|
+
timestampTemplate: j,
|
|
57
|
+
statusTemplate: W,
|
|
58
|
+
userStatusTemplate: G,
|
|
59
|
+
allowMessageCollapse: z,
|
|
60
|
+
messageToolbarActions: K,
|
|
61
|
+
messageContextMenuActions: $,
|
|
62
|
+
fileActions: S,
|
|
63
|
+
onUnpin: Ze,
|
|
64
|
+
messageWidthMode: J,
|
|
65
|
+
showAvatar: Q,
|
|
66
|
+
showUsername: X,
|
|
67
|
+
timestampVisibility: Y,
|
|
68
|
+
authorMessageSettings: Z,
|
|
69
|
+
receiverMessageSettings: _,
|
|
70
|
+
onToolbarAction: ee,
|
|
71
|
+
onContextMenuAction: te,
|
|
72
|
+
onFileAction: se,
|
|
73
|
+
onDownload: oe,
|
|
74
|
+
speechToTextConfig: ne,
|
|
75
|
+
uploadConfig: ae,
|
|
76
|
+
sendButtonConfig: _e,
|
|
77
|
+
messageFilesLayout: re,
|
|
78
|
+
scrollToBottomButton: w = !0,
|
|
79
|
+
autoScrollThreshold: et,
|
|
80
|
+
textField: le,
|
|
81
|
+
statusField: ie,
|
|
82
|
+
authorIdField: ce,
|
|
83
|
+
authorNameField: ue,
|
|
84
|
+
authorImageUrlField: me,
|
|
85
|
+
authorImageAltTextField: ge,
|
|
86
|
+
idField: pe,
|
|
86
87
|
timestampField: de,
|
|
87
|
-
filesField:
|
|
88
|
-
attachmentsField:
|
|
89
|
-
replyToIdField:
|
|
88
|
+
filesField: fe,
|
|
89
|
+
attachmentsField: he,
|
|
90
|
+
replyToIdField: ye,
|
|
90
91
|
isDeletedField: Ce,
|
|
91
|
-
isPinnedField:
|
|
92
|
-
typingField:
|
|
93
|
-
suggestedActionsField:
|
|
92
|
+
isPinnedField: Te,
|
|
93
|
+
typingField: Se,
|
|
94
|
+
suggestedActionsField: Me,
|
|
94
95
|
isFailedField: be,
|
|
95
|
-
onResendMessage:
|
|
96
|
-
messageBoxSettings:
|
|
97
|
-
loading:
|
|
98
|
-
...
|
|
99
|
-
} =
|
|
96
|
+
onResendMessage: ke,
|
|
97
|
+
messageBoxSettings: tt,
|
|
98
|
+
loading: st,
|
|
99
|
+
...ot
|
|
100
|
+
} = je, [u, F] = t.useState(null), [R, nt] = t.useState(!1), [at, ve] = t.useState(!1), [Ee, xe] = t.useState(null), [m, Ae] = t.useState(null), [rt, we] = t.useState(!1), L = t.useRef(null), Fe = t.useRef(null), l = t.useRef(null), Re = t.useRef(null), I = t.useRef(void 0), B = t.useRef(!1), N = t.useRef(null), Le = t.useRef(""), a = t.useMemo(() => {
|
|
100
101
|
if (!p || p.length === 0)
|
|
101
102
|
return [];
|
|
102
103
|
const s = {
|
|
103
|
-
textField:
|
|
104
|
-
statusField:
|
|
105
|
-
authorIdField:
|
|
106
|
-
authorNameField:
|
|
107
|
-
authorImageUrlField:
|
|
108
|
-
authorImageAltTextField:
|
|
109
|
-
idField:
|
|
104
|
+
textField: le,
|
|
105
|
+
statusField: ie,
|
|
106
|
+
authorIdField: ce,
|
|
107
|
+
authorNameField: ue,
|
|
108
|
+
authorImageUrlField: me,
|
|
109
|
+
authorImageAltTextField: ge,
|
|
110
|
+
idField: pe,
|
|
110
111
|
timestampField: de,
|
|
111
|
-
filesField:
|
|
112
|
-
attachmentsField:
|
|
113
|
-
replyToIdField:
|
|
112
|
+
filesField: fe,
|
|
113
|
+
attachmentsField: he,
|
|
114
|
+
replyToIdField: ye,
|
|
114
115
|
isDeletedField: Ce,
|
|
115
|
-
isPinnedField:
|
|
116
|
-
typingField:
|
|
117
|
-
suggestedActionsField:
|
|
116
|
+
isPinnedField: Te,
|
|
117
|
+
typingField: Se,
|
|
118
|
+
suggestedActionsField: Me,
|
|
118
119
|
isFailedField: be
|
|
119
120
|
};
|
|
120
|
-
return !Object.values(s).some((n) => n !== void 0) &&
|
|
121
|
+
return !Object.values(s).some((n) => n !== void 0) && Ut(p[0]) ? p.map((n) => ({
|
|
121
122
|
...n,
|
|
122
123
|
timestamp: n.timestamp ? new Date(n.timestamp) : n.timestamp
|
|
123
|
-
})) :
|
|
124
|
+
})) : Pt(p, s);
|
|
124
125
|
}, [
|
|
125
126
|
p,
|
|
127
|
+
le,
|
|
126
128
|
ie,
|
|
127
129
|
ce,
|
|
128
130
|
ue,
|
|
129
131
|
me,
|
|
130
132
|
ge,
|
|
131
133
|
pe,
|
|
132
|
-
fe,
|
|
133
134
|
de,
|
|
135
|
+
fe,
|
|
134
136
|
he,
|
|
135
137
|
ye,
|
|
136
|
-
Te,
|
|
137
138
|
Ce,
|
|
139
|
+
Te,
|
|
138
140
|
Se,
|
|
139
141
|
Me,
|
|
140
|
-
ke,
|
|
141
142
|
be
|
|
142
143
|
]);
|
|
143
|
-
|
|
144
|
-
if (i ===
|
|
144
|
+
t.useEffect(() => {
|
|
145
|
+
if (i === Le.current && N.current) {
|
|
145
146
|
Ae(N.current);
|
|
146
147
|
return;
|
|
147
148
|
}
|
|
148
149
|
if (i && a.length > 0) {
|
|
149
150
|
const s = a.find(
|
|
150
151
|
(n) => n.author && (n.author.id === i || n.author.id === String(i))
|
|
151
|
-
),
|
|
152
|
-
N.current =
|
|
152
|
+
), e = (s == null ? void 0 : s.author) || { id: i };
|
|
153
|
+
N.current = e, Le.current = i, Ae(e);
|
|
153
154
|
}
|
|
154
155
|
}, [i, a]);
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
viewItemsWrapperRef:
|
|
158
|
-
isKeyboardNavigationActiveRef:
|
|
156
|
+
const g = t.useMemo(() => a.length > 0 ? Et(a) : [], [a]), lt = t.useMemo(() => !St(Pe, { component: "Chat" }), []), it = Mt(Pe), Ie = t.useMemo(() => a.find((s) => s.isPinned), [a]), M = Ot();
|
|
157
|
+
Vt({
|
|
158
|
+
viewItemsWrapperRef: l,
|
|
159
|
+
isKeyboardNavigationActiveRef: B,
|
|
159
160
|
processedMessages: a,
|
|
160
|
-
|
|
161
|
+
authorId: i,
|
|
162
|
+
autoScrollThreshold: et
|
|
161
163
|
});
|
|
162
|
-
const
|
|
163
|
-
clearTimeout(
|
|
164
|
-
}, []),
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
const ct = qt({ elementRef: l }), ut = t.useCallback(() => {
|
|
165
|
+
clearTimeout(I.current);
|
|
166
|
+
}, []), mt = t.useCallback(() => {
|
|
167
|
+
I.current = window.setTimeout(() => {
|
|
168
|
+
F(null);
|
|
167
169
|
}, 0);
|
|
168
|
-
}, []),
|
|
169
|
-
|
|
170
|
-
}, []),
|
|
170
|
+
}, []), b = t.useCallback((s) => {
|
|
171
|
+
F(s);
|
|
172
|
+
}, []), gt = t.useCallback(
|
|
171
173
|
(s) => {
|
|
172
|
-
let
|
|
173
|
-
const n =
|
|
174
|
-
s.keyCode === k.up ? n === null ?
|
|
174
|
+
let e = null;
|
|
175
|
+
const n = u !== null ? u : g.lastSelectionIndex;
|
|
176
|
+
s.keyCode === k.up ? n === null ? e = 0 : n > 0 && (e = n - 1) : s.keyCode === k.down ? n === null ? e = 0 : n < g.lastSelectionIndex && (e = n + 1) : s.keyCode === k.home ? e = 0 : s.keyCode === k.end && (e = g.lastSelectionIndex), e !== null && (F(e), B.current = !0, s.preventDefault());
|
|
175
177
|
},
|
|
176
|
-
[
|
|
177
|
-
), Be =
|
|
178
|
-
(s,
|
|
179
|
-
var
|
|
180
|
-
if (
|
|
178
|
+
[u, g]
|
|
179
|
+
), Be = t.useCallback(
|
|
180
|
+
(s, e, n) => {
|
|
181
|
+
var c;
|
|
182
|
+
if (A && A({
|
|
181
183
|
action: { value: s.value, title: s.title, type: s.type },
|
|
182
|
-
syntheticEvent:
|
|
183
|
-
nativeEvent:
|
|
184
|
-
target:
|
|
185
|
-
}), !
|
|
184
|
+
syntheticEvent: e,
|
|
185
|
+
nativeEvent: e.nativeEvent,
|
|
186
|
+
target: e.currentTarget
|
|
187
|
+
}), !e.isDefaultPrevented()) {
|
|
186
188
|
switch (s.type) {
|
|
187
189
|
case "reply":
|
|
188
190
|
y && y({
|
|
189
191
|
message: {
|
|
190
192
|
id: "",
|
|
191
|
-
author:
|
|
193
|
+
author: m,
|
|
192
194
|
text: s.value,
|
|
193
195
|
timestamp: /* @__PURE__ */ new Date()
|
|
194
196
|
},
|
|
195
|
-
syntheticEvent:
|
|
196
|
-
nativeEvent:
|
|
197
|
-
target:
|
|
197
|
+
syntheticEvent: e,
|
|
198
|
+
nativeEvent: e.nativeEvent,
|
|
199
|
+
target: e.currentTarget
|
|
198
200
|
});
|
|
199
201
|
break;
|
|
200
202
|
case "call":
|
|
@@ -204,283 +206,289 @@ const Ve = e.forwardRef((He, T) => {
|
|
|
204
206
|
window.open(s.value);
|
|
205
207
|
break;
|
|
206
208
|
}
|
|
207
|
-
(
|
|
209
|
+
(c = Re.current) == null || c.focusInput();
|
|
208
210
|
}
|
|
209
211
|
},
|
|
210
|
-
[
|
|
211
|
-
),
|
|
212
|
-
|
|
213
|
-
}, []),
|
|
214
|
-
const s =
|
|
215
|
-
return
|
|
216
|
-
var
|
|
217
|
-
if (
|
|
218
|
-
return /* @__PURE__ */
|
|
219
|
-
if (
|
|
220
|
-
const
|
|
221
|
-
allowMessageCollapse:
|
|
222
|
-
messageWidthMode:
|
|
223
|
-
showAvatar:
|
|
224
|
-
showUsername:
|
|
212
|
+
[A, y, m]
|
|
213
|
+
), pt = t.useCallback(() => {
|
|
214
|
+
l.current && (l.current.scrollTop = l.current.scrollHeight - l.current.clientHeight);
|
|
215
|
+
}, []), dt = t.useCallback(() => Ue("k-chat", V, { "k-rtl": R }), [V, R]), ft = t.useCallback(() => {
|
|
216
|
+
const s = g.length - 1;
|
|
217
|
+
return g.map((e, n) => {
|
|
218
|
+
var c;
|
|
219
|
+
if (e.type === "date-marker")
|
|
220
|
+
return /* @__PURE__ */ t.createElement(wt, { item: e, key: e.trackBy, timestampTemplate: j });
|
|
221
|
+
if (e.type === "message-group") {
|
|
222
|
+
const C = {
|
|
223
|
+
allowMessageCollapse: z,
|
|
224
|
+
messageWidthMode: J,
|
|
225
|
+
showAvatar: Q,
|
|
226
|
+
showUsername: X,
|
|
225
227
|
messageTemplate: D,
|
|
226
|
-
messageContentTemplate:
|
|
227
|
-
messageToolbarActions:
|
|
228
|
-
messageContextMenuActions:
|
|
229
|
-
fileActions:
|
|
230
|
-
},
|
|
231
|
-
(
|
|
228
|
+
messageContentTemplate: O,
|
|
229
|
+
messageToolbarActions: K,
|
|
230
|
+
messageContextMenuActions: $,
|
|
231
|
+
fileActions: S
|
|
232
|
+
}, r = Ht(
|
|
233
|
+
(c = e == null ? void 0 : e.messages) == null ? void 0 : c[0],
|
|
232
234
|
i,
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
C,
|
|
236
|
+
Z,
|
|
237
|
+
_
|
|
236
238
|
);
|
|
237
|
-
return /* @__PURE__ */
|
|
238
|
-
|
|
239
|
+
return /* @__PURE__ */ t.createElement(
|
|
240
|
+
Ft,
|
|
239
241
|
{
|
|
240
|
-
group:
|
|
241
|
-
itemTemplate:
|
|
242
|
-
contentTemplate:
|
|
242
|
+
group: e,
|
|
243
|
+
itemTemplate: r.messageTemplate,
|
|
244
|
+
contentTemplate: r.messageContentTemplate,
|
|
243
245
|
attachmentTemplate: x,
|
|
244
|
-
user:
|
|
245
|
-
selectedItemIndex:
|
|
246
|
-
onRequestSelection:
|
|
246
|
+
user: m,
|
|
247
|
+
selectedItemIndex: u,
|
|
248
|
+
onRequestSelection: b,
|
|
247
249
|
isLastGroup: n === s,
|
|
248
|
-
key:
|
|
249
|
-
message:
|
|
250
|
-
allowMessageCollapse:
|
|
251
|
-
messageToolbarActions:
|
|
252
|
-
messageContextMenuActions:
|
|
253
|
-
fileActions:
|
|
254
|
-
messageWidthMode:
|
|
255
|
-
showAvatar:
|
|
256
|
-
showUsername:
|
|
250
|
+
key: e.messages[0].selectionIndex,
|
|
251
|
+
message: q,
|
|
252
|
+
allowMessageCollapse: r.allowMessageCollapse,
|
|
253
|
+
messageToolbarActions: r.messageToolbarActions,
|
|
254
|
+
messageContextMenuActions: r.messageContextMenuActions,
|
|
255
|
+
fileActions: r.fileActions,
|
|
256
|
+
messageWidthMode: r.messageWidthMode,
|
|
257
|
+
showAvatar: r.showAvatar,
|
|
258
|
+
showUsername: r.showUsername
|
|
257
259
|
}
|
|
258
260
|
);
|
|
259
261
|
} else {
|
|
260
|
-
if (
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
|
|
262
|
+
if (e.type === "attachment-group")
|
|
263
|
+
return /* @__PURE__ */ t.createElement(
|
|
264
|
+
At,
|
|
263
265
|
{
|
|
264
|
-
group:
|
|
266
|
+
group: e,
|
|
265
267
|
itemTemplate: x,
|
|
266
|
-
onRequestSelection:
|
|
267
|
-
selected:
|
|
268
|
+
onRequestSelection: b,
|
|
269
|
+
selected: e.selectionIndex === u,
|
|
268
270
|
isLastGroup: n === s,
|
|
269
|
-
key:
|
|
271
|
+
key: e.selectionIndex
|
|
270
272
|
}
|
|
271
273
|
);
|
|
272
|
-
if (
|
|
273
|
-
return /* @__PURE__ */
|
|
274
|
-
|
|
274
|
+
if (e.type === "action-group")
|
|
275
|
+
return /* @__PURE__ */ t.createElement(
|
|
276
|
+
xt,
|
|
275
277
|
{
|
|
276
|
-
group:
|
|
278
|
+
group: e,
|
|
277
279
|
onActionExecute: Be,
|
|
278
|
-
onRequestSelection:
|
|
279
|
-
selected:
|
|
280
|
-
key:
|
|
281
|
-
quickActionsLayout:
|
|
282
|
-
dir:
|
|
280
|
+
onRequestSelection: b,
|
|
281
|
+
selected: e.selectionIndex === u,
|
|
282
|
+
key: e.selectionIndex,
|
|
283
|
+
quickActionsLayout: H,
|
|
284
|
+
dir: d
|
|
283
285
|
}
|
|
284
286
|
);
|
|
285
287
|
}
|
|
286
288
|
return null;
|
|
287
289
|
});
|
|
288
290
|
}, [
|
|
289
|
-
|
|
290
|
-
|
|
291
|
+
g,
|
|
292
|
+
j,
|
|
291
293
|
D,
|
|
292
|
-
|
|
294
|
+
O,
|
|
293
295
|
x,
|
|
296
|
+
m,
|
|
294
297
|
u,
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
+
b,
|
|
299
|
+
q,
|
|
300
|
+
z,
|
|
298
301
|
K,
|
|
299
302
|
$,
|
|
303
|
+
S,
|
|
300
304
|
J,
|
|
301
|
-
C,
|
|
302
305
|
Q,
|
|
303
306
|
X,
|
|
304
|
-
Y,
|
|
305
307
|
i,
|
|
308
|
+
Z,
|
|
306
309
|
_,
|
|
307
|
-
ee,
|
|
308
310
|
Be,
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
]),
|
|
312
|
-
|
|
313
|
-
const s =
|
|
314
|
-
|
|
315
|
-
}, [
|
|
316
|
-
clearTimeout(
|
|
317
|
-
}, []),
|
|
318
|
-
if (!
|
|
311
|
+
H,
|
|
312
|
+
d
|
|
313
|
+
]), ht = t.useCallback(() => f ? typeof f == "function" ? f() : f : null, [f]), yt = t.useCallback(() => h ? typeof h == "function" ? h() : h : null, [h]);
|
|
314
|
+
t.useEffect(() => {
|
|
315
|
+
const s = d !== void 0 ? d === "rtl" : L.current && getComputedStyle(L.current).direction === "rtl";
|
|
316
|
+
nt(!!s);
|
|
317
|
+
}, [d]), t.useEffect(() => () => {
|
|
318
|
+
clearTimeout(I.current);
|
|
319
|
+
}, []), t.useEffect(() => {
|
|
320
|
+
if (!w || !l.current)
|
|
319
321
|
return;
|
|
320
|
-
let s;
|
|
321
|
-
const
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
322
|
+
let s, e;
|
|
323
|
+
const n = () => {
|
|
324
|
+
s = void 0;
|
|
325
|
+
const Ne = l.current;
|
|
326
|
+
if (!Ne)
|
|
327
|
+
return;
|
|
328
|
+
const { scrollHeight: De, scrollTop: Tt, clientHeight: Oe } = Ne;
|
|
329
|
+
!(De > Oe) || De - Tt - Oe <= 100 ? (e !== void 0 && (clearTimeout(e), e = void 0), we(!1)) : e != null || (e = setTimeout(() => {
|
|
330
|
+
e = void 0, we(!0);
|
|
331
|
+
}, 300));
|
|
332
|
+
}, c = () => {
|
|
333
|
+
s === void 0 && (s = requestAnimationFrame(n));
|
|
334
|
+
}, C = l.current;
|
|
335
|
+
C.addEventListener("scroll", c, { passive: !0 });
|
|
336
|
+
const r = new MutationObserver(c);
|
|
337
|
+
return r.observe(C, { childList: !0, subtree: !0, characterData: !0 }), () => {
|
|
338
|
+
C.removeEventListener("scroll", c), r.disconnect(), s !== void 0 && cancelAnimationFrame(s), e !== void 0 && clearTimeout(e);
|
|
331
339
|
};
|
|
332
|
-
}, [
|
|
333
|
-
const
|
|
334
|
-
replyToMessage:
|
|
335
|
-
setReplyToMessage:
|
|
340
|
+
}, [w]);
|
|
341
|
+
const Ct = t.useMemo(() => ({
|
|
342
|
+
replyToMessage: Ee,
|
|
343
|
+
setReplyToMessage: xe,
|
|
336
344
|
messages: a,
|
|
337
|
-
user:
|
|
345
|
+
user: m,
|
|
338
346
|
internalScrollContainerRef: Fe,
|
|
339
|
-
messageListScrollContainerRef:
|
|
340
|
-
onToolbarAction:
|
|
341
|
-
onContextMenuAction:
|
|
342
|
-
onFileAction:
|
|
343
|
-
setShowCopyNotification:
|
|
344
|
-
onDownload:
|
|
345
|
-
onResendMessage:
|
|
346
|
-
fileActions:
|
|
347
|
-
speechToTextConfig:
|
|
348
|
-
uploadConfig:
|
|
349
|
-
statusTemplate:
|
|
350
|
-
userStatusTemplate:
|
|
351
|
-
messageFilesLayout:
|
|
352
|
-
timestampVisibility:
|
|
347
|
+
messageListScrollContainerRef: l,
|
|
348
|
+
onToolbarAction: ee,
|
|
349
|
+
onContextMenuAction: te,
|
|
350
|
+
onFileAction: se,
|
|
351
|
+
setShowCopyNotification: ve,
|
|
352
|
+
onDownload: oe,
|
|
353
|
+
onResendMessage: ke,
|
|
354
|
+
fileActions: S,
|
|
355
|
+
speechToTextConfig: ne,
|
|
356
|
+
uploadConfig: ae,
|
|
357
|
+
statusTemplate: W,
|
|
358
|
+
userStatusTemplate: G,
|
|
359
|
+
messageFilesLayout: re,
|
|
360
|
+
timestampVisibility: Y
|
|
353
361
|
}), [
|
|
354
|
-
|
|
355
|
-
|
|
362
|
+
Ee,
|
|
363
|
+
xe,
|
|
356
364
|
a,
|
|
357
|
-
|
|
365
|
+
m,
|
|
366
|
+
ee,
|
|
358
367
|
te,
|
|
359
368
|
se,
|
|
369
|
+
ve,
|
|
360
370
|
oe,
|
|
361
|
-
|
|
371
|
+
ke,
|
|
372
|
+
S,
|
|
362
373
|
ne,
|
|
363
|
-
Ee,
|
|
364
|
-
C,
|
|
365
374
|
ae,
|
|
366
|
-
|
|
375
|
+
W,
|
|
367
376
|
G,
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
Z
|
|
377
|
+
re,
|
|
378
|
+
Y
|
|
371
379
|
]);
|
|
372
|
-
return /* @__PURE__ */
|
|
380
|
+
return /* @__PURE__ */ t.createElement(Nt.Provider, { value: Ct }, /* @__PURE__ */ t.createElement(
|
|
373
381
|
"div",
|
|
374
382
|
{
|
|
375
383
|
style: {
|
|
376
|
-
width:
|
|
377
|
-
height:
|
|
384
|
+
width: We,
|
|
385
|
+
height: Ge,
|
|
378
386
|
position: "relative",
|
|
379
387
|
overflow: "hidden",
|
|
380
|
-
|
|
388
|
+
...$e
|
|
381
389
|
},
|
|
382
|
-
onKeyDown:
|
|
383
|
-
className:
|
|
390
|
+
onKeyDown: gt,
|
|
391
|
+
className: dt(),
|
|
384
392
|
ref: (s) => {
|
|
385
|
-
|
|
393
|
+
L.current = s, Fe.current = s, typeof T == "function" ? T(s) : T && (T.current = s);
|
|
386
394
|
},
|
|
387
|
-
...
|
|
395
|
+
...ot
|
|
388
396
|
},
|
|
389
|
-
|
|
390
|
-
/* @__PURE__ */
|
|
397
|
+
f !== void 0 && /* @__PURE__ */ t.createElement(Lt, null, ht()),
|
|
398
|
+
/* @__PURE__ */ t.createElement(
|
|
391
399
|
"div",
|
|
392
400
|
{
|
|
393
401
|
className: "k-message-list",
|
|
394
|
-
onBlur:
|
|
395
|
-
onFocus:
|
|
402
|
+
onBlur: mt,
|
|
403
|
+
onFocus: ut,
|
|
396
404
|
role: "log",
|
|
397
|
-
"aria-label":
|
|
398
|
-
|
|
399
|
-
|
|
405
|
+
"aria-label": M.toLanguageString(
|
|
406
|
+
Ve,
|
|
407
|
+
v[Ve]
|
|
400
408
|
),
|
|
401
409
|
"aria-live": "polite",
|
|
402
|
-
ref:
|
|
410
|
+
ref: l
|
|
403
411
|
},
|
|
404
|
-
|
|
405
|
-
/* @__PURE__ */
|
|
412
|
+
Ie && /* @__PURE__ */ t.createElement(It, { message: Ie, onUnpin: Ze, user: m }),
|
|
413
|
+
/* @__PURE__ */ t.createElement(
|
|
406
414
|
"div",
|
|
407
415
|
{
|
|
408
|
-
className:
|
|
416
|
+
className: Ue("k-message-list-content", {
|
|
409
417
|
"k-message-list-content-empty": a.length === 0
|
|
410
418
|
})
|
|
411
419
|
},
|
|
412
|
-
a.length === 0 && h !== void 0 &&
|
|
413
|
-
a.length > 0 &&
|
|
420
|
+
a.length === 0 && h !== void 0 && yt(),
|
|
421
|
+
a.length > 0 && ft()
|
|
414
422
|
),
|
|
415
|
-
|
|
416
|
-
|
|
423
|
+
w && rt && /* @__PURE__ */ t.createElement("div", { className: "k-chat-scroll-to-bottom-container" }, /* @__PURE__ */ t.createElement(
|
|
424
|
+
kt,
|
|
417
425
|
{
|
|
418
|
-
svgIcon:
|
|
426
|
+
svgIcon: vt,
|
|
419
427
|
size: "small",
|
|
420
428
|
themeColor: "light",
|
|
421
429
|
rounded: "full",
|
|
422
|
-
onClick:
|
|
423
|
-
"aria-label":
|
|
430
|
+
onClick: pt,
|
|
431
|
+
"aria-label": M.toLanguageString(
|
|
424
432
|
E,
|
|
425
|
-
|
|
433
|
+
v[E]
|
|
426
434
|
),
|
|
427
|
-
title:
|
|
435
|
+
title: M.toLanguageString(
|
|
428
436
|
E,
|
|
429
|
-
|
|
437
|
+
v[E]
|
|
430
438
|
)
|
|
431
439
|
}
|
|
432
440
|
))
|
|
433
441
|
),
|
|
434
|
-
|
|
435
|
-
/* @__PURE__ */
|
|
436
|
-
|
|
442
|
+
ct && /* @__PURE__ */ t.createElement("div", { className: "k-separator" }),
|
|
443
|
+
/* @__PURE__ */ t.createElement(
|
|
444
|
+
Rt,
|
|
437
445
|
{
|
|
438
|
-
onSendMessage: (s,
|
|
446
|
+
onSendMessage: (s, e) => {
|
|
439
447
|
y && y({
|
|
440
448
|
message: s,
|
|
441
|
-
syntheticEvent:
|
|
442
|
-
nativeEvent:
|
|
443
|
-
target:
|
|
449
|
+
syntheticEvent: e,
|
|
450
|
+
nativeEvent: e.nativeEvent,
|
|
451
|
+
target: e.currentTarget
|
|
444
452
|
});
|
|
445
453
|
},
|
|
446
454
|
onSuggestionClick: (s) => {
|
|
447
|
-
|
|
455
|
+
U && U(s);
|
|
448
456
|
},
|
|
449
457
|
isDirectionRightToLeft: R,
|
|
450
|
-
ref:
|
|
451
|
-
placeholder:
|
|
452
|
-
MessageBox:
|
|
453
|
-
suggestions:
|
|
454
|
-
suggestionTemplate:
|
|
455
|
-
inputValue:
|
|
458
|
+
ref: Re,
|
|
459
|
+
placeholder: Ke,
|
|
460
|
+
MessageBox: ze,
|
|
461
|
+
suggestions: Je,
|
|
462
|
+
suggestionTemplate: Qe,
|
|
463
|
+
inputValue: Ye,
|
|
456
464
|
onInputValueChange: (s) => {
|
|
457
465
|
P && P(s);
|
|
458
466
|
},
|
|
459
467
|
onInputClick: () => {
|
|
460
|
-
|
|
468
|
+
B.current = !1;
|
|
461
469
|
},
|
|
462
|
-
sendButtonConfig:
|
|
463
|
-
suggestionsLayout:
|
|
464
|
-
dir:
|
|
465
|
-
messageBoxSettings:
|
|
466
|
-
loading:
|
|
470
|
+
sendButtonConfig: _e,
|
|
471
|
+
suggestionsLayout: Xe,
|
|
472
|
+
dir: d,
|
|
473
|
+
messageBoxSettings: tt,
|
|
474
|
+
loading: st
|
|
467
475
|
}
|
|
468
476
|
),
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
-
|
|
477
|
+
/* @__PURE__ */ t.createElement(
|
|
478
|
+
Bt,
|
|
471
479
|
{
|
|
472
|
-
show:
|
|
473
|
-
text:
|
|
474
|
-
|
|
475
|
-
|
|
480
|
+
show: at,
|
|
481
|
+
text: M.toLanguageString(
|
|
482
|
+
qe,
|
|
483
|
+
v[qe]
|
|
476
484
|
)
|
|
477
485
|
}
|
|
478
486
|
),
|
|
479
|
-
|
|
487
|
+
lt && /* @__PURE__ */ t.createElement(bt, { message: it })
|
|
480
488
|
));
|
|
481
489
|
});
|
|
482
|
-
|
|
483
|
-
|
|
490
|
+
He.displayName = "Chat";
|
|
491
|
+
He.propTypes = {
|
|
484
492
|
messages: o.arrayOf(o.object),
|
|
485
493
|
user: o.object,
|
|
486
494
|
messageTemplate: o.any,
|
|
@@ -503,5 +511,5 @@ Ve.propTypes = {
|
|
|
503
511
|
receiverMessageSettings: o.object
|
|
504
512
|
};
|
|
505
513
|
export {
|
|
506
|
-
|
|
514
|
+
He as Chat
|
|
507
515
|
};
|