@progress/kendo-react-conversational-ui 14.4.0-develop.1 → 14.4.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/NOTICE.txt +366 -82
- package/chat/ChatPropsAndState.d.ts +4 -4
- package/chat/Events.d.ts +2 -2
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +3 -3
- package/chat/components/NewMessage.js +1 -1
- package/chat/components/NewMessage.mjs +37 -41
- package/chat/hooks/useEndlessScroll.d.ts +4 -4
- package/chat/hooks/useEndlessScroll.js +1 -1
- package/chat/hooks/useEndlessScroll.mjs +108 -108
- 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
|
@@ -7,179 +7,179 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import * as r from "react";
|
|
9
9
|
import { scrollToMessageById as tt } from "../utils.mjs";
|
|
10
|
-
const nt = 50,
|
|
10
|
+
const nt = 50, s = 100, ct = ({
|
|
11
11
|
scrollMode: I,
|
|
12
12
|
processedMessages: n,
|
|
13
|
-
total:
|
|
13
|
+
total: C,
|
|
14
14
|
pageSize: i = nt,
|
|
15
|
-
startIndex:
|
|
16
|
-
endIndex:
|
|
17
|
-
|
|
18
|
-
onReferencedMessageClick:
|
|
15
|
+
startIndex: J,
|
|
16
|
+
endIndex: Z,
|
|
17
|
+
onLoadMoreMessages: T,
|
|
18
|
+
onReferencedMessageClick: b,
|
|
19
19
|
viewItemsWrapperRef: u,
|
|
20
|
-
authorId:
|
|
20
|
+
authorId: Y
|
|
21
21
|
}) => {
|
|
22
|
-
const
|
|
23
|
-
f && (
|
|
24
|
-
const [
|
|
25
|
-
|
|
26
|
-
const o = r.useRef(!1),
|
|
27
|
-
|
|
28
|
-
const
|
|
22
|
+
const F = r.useRef(!1), E = I === "endless", l = C != null ? C : n.length, a = E && n.length === l && !F.current, f = E && (n.length < l || F.current);
|
|
23
|
+
f && (F.current = !0);
|
|
24
|
+
const [D, B] = r.useState(-1), [S, A] = r.useState(-1), d = r.useRef(D), j = r.useRef(S);
|
|
25
|
+
d.current = D, j.current = S;
|
|
26
|
+
const o = r.useRef(!1), L = r.useRef(0), v = r.useRef(0), q = r.useRef(!1), g = r.useRef(l), k = r.useRef(Y);
|
|
27
|
+
k.current = Y;
|
|
28
|
+
const _ = r.useRef(!1), $ = r.useRef(null), G = r.useRef(!1), U = r.useRef(!1), K = r.useRef(!0), N = r.useRef(l);
|
|
29
29
|
r.useEffect(() => {
|
|
30
30
|
if (a) {
|
|
31
|
-
if (
|
|
32
|
-
(
|
|
31
|
+
if (F.current) {
|
|
32
|
+
(D === -1 || S === -1) && (B(0), A(n.length));
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
35
|
+
if (D === -1 || S === -1) {
|
|
36
36
|
const t = Math.max(0, n.length - i), c = n.length;
|
|
37
|
-
|
|
38
|
-
} else if (
|
|
39
|
-
const t =
|
|
40
|
-
if (
|
|
41
|
-
|
|
37
|
+
B(t), A(c);
|
|
38
|
+
} else if (S < n.length) {
|
|
39
|
+
const t = g.current;
|
|
40
|
+
if (j.current >= t)
|
|
41
|
+
A(n.length);
|
|
42
42
|
else if (n.length > t && n.slice(t).some(
|
|
43
43
|
(e) => {
|
|
44
|
-
var
|
|
45
|
-
return ((
|
|
44
|
+
var x;
|
|
45
|
+
return ((x = e.author) == null ? void 0 : x.id) !== void 0 && String(e.author.id) === String(k.current);
|
|
46
46
|
}
|
|
47
47
|
)) {
|
|
48
48
|
const e = Math.max(0, n.length - i);
|
|
49
|
-
|
|
49
|
+
B(e), A(n.length), G.current = !0;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
g.current = l;
|
|
53
53
|
}
|
|
54
|
-
}, [a, n.length, i,
|
|
55
|
-
const
|
|
54
|
+
}, [a, n.length, i, D, S, l]);
|
|
55
|
+
const O = J != null ? J : 0, H = Z != null ? Z : n.length, P = r.useCallback(() => {
|
|
56
56
|
const t = u.current;
|
|
57
|
-
t && (
|
|
58
|
-
}, [u]),
|
|
57
|
+
t && (L.current = t.scrollHeight, v.current = t.scrollTop);
|
|
58
|
+
}, [u]), y = r.useCallback(
|
|
59
59
|
(t) => {
|
|
60
|
-
var h, e,
|
|
61
|
-
const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"),
|
|
62
|
-
tt(t, c,
|
|
60
|
+
var h, e, x;
|
|
61
|
+
const c = (h = u.current) == null ? void 0 : h.closest(".k-chat"), m = ((x = (e = u.current) == null ? void 0 : e.querySelector(".k-message-pinned")) == null ? void 0 : x.offsetHeight) || 0;
|
|
62
|
+
tt(t, c, m);
|
|
63
63
|
},
|
|
64
64
|
[u]
|
|
65
65
|
);
|
|
66
66
|
r.useLayoutEffect(() => {
|
|
67
|
-
if (!
|
|
67
|
+
if (!q.current)
|
|
68
68
|
return;
|
|
69
69
|
const t = u.current;
|
|
70
70
|
if (!t) {
|
|
71
|
-
|
|
71
|
+
q.current = !1;
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
const c = t.scrollHeight -
|
|
75
|
-
c > 0 && (t.scrollTop =
|
|
74
|
+
const c = t.scrollHeight - L.current;
|
|
75
|
+
c > 0 && (t.scrollTop = v.current + c), q.current = !1, o.current = !1;
|
|
76
76
|
}), r.useLayoutEffect(() => {
|
|
77
|
-
if (!
|
|
77
|
+
if (!G.current)
|
|
78
78
|
return;
|
|
79
79
|
const t = u.current;
|
|
80
80
|
if (!t) {
|
|
81
|
-
|
|
81
|
+
G.current = !1;
|
|
82
82
|
return;
|
|
83
83
|
}
|
|
84
|
-
|
|
84
|
+
S >= n.length && S > 0 && (G.current = !1, t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
85
85
|
});
|
|
86
|
-
const
|
|
86
|
+
const w = r.useRef(!1);
|
|
87
87
|
r.useLayoutEffect(() => {
|
|
88
|
-
if (!
|
|
88
|
+
if (!E || w.current)
|
|
89
89
|
return;
|
|
90
90
|
const t = u.current;
|
|
91
|
-
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight,
|
|
91
|
+
t && t.querySelector("[data-message-id]") && (t.scrollTop = t.scrollHeight - t.clientHeight, w.current = !0);
|
|
92
92
|
}), r.useEffect(() => {
|
|
93
|
-
if (!
|
|
93
|
+
if (!E)
|
|
94
94
|
return;
|
|
95
95
|
const t = u.current;
|
|
96
96
|
if (!t)
|
|
97
97
|
return;
|
|
98
98
|
let c = t.scrollTop;
|
|
99
|
-
const
|
|
100
|
-
const { scrollTop: h, scrollHeight: e, clientHeight:
|
|
99
|
+
const m = () => {
|
|
100
|
+
const { scrollTop: h, scrollHeight: e, clientHeight: x } = t, V = h < c, p = h > c;
|
|
101
101
|
if (c = h, !o.current) {
|
|
102
|
-
if (
|
|
102
|
+
if (V && h <= s) {
|
|
103
103
|
if (a) {
|
|
104
|
-
const
|
|
105
|
-
if (
|
|
106
|
-
const
|
|
107
|
-
|
|
104
|
+
const R = d.current;
|
|
105
|
+
if (R > 0) {
|
|
106
|
+
const X = Math.max(0, R - i);
|
|
107
|
+
q.current = !0, P(), B(X);
|
|
108
108
|
}
|
|
109
|
-
} else if (f &&
|
|
109
|
+
} else if (f && O > 0) {
|
|
110
110
|
o.current = !0;
|
|
111
|
-
const
|
|
112
|
-
|
|
111
|
+
const R = Math.max(0, O - i);
|
|
112
|
+
q.current = !0, P(), T == null || T({ startIndex: R, endIndex: O });
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
-
if (p && e - h -
|
|
115
|
+
if (p && e - h - x <= s) {
|
|
116
116
|
if (a) {
|
|
117
|
-
const
|
|
118
|
-
if (
|
|
119
|
-
const
|
|
120
|
-
|
|
117
|
+
const R = j.current;
|
|
118
|
+
if (R < n.length) {
|
|
119
|
+
const X = Math.min(n.length, R + i);
|
|
120
|
+
U.current = !0, A(X);
|
|
121
121
|
}
|
|
122
|
-
} else if (f &&
|
|
123
|
-
o.current = !0,
|
|
124
|
-
const
|
|
125
|
-
|
|
122
|
+
} else if (f && H < l) {
|
|
123
|
+
o.current = !0, U.current = !0;
|
|
124
|
+
const R = Math.min(l, H + i);
|
|
125
|
+
T == null || T({ startIndex: H, endIndex: R });
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
return t.addEventListener("scroll",
|
|
130
|
+
return t.addEventListener("scroll", m, { passive: !0 }), () => t.removeEventListener("scroll", m);
|
|
131
131
|
}, [
|
|
132
|
-
|
|
132
|
+
E,
|
|
133
133
|
a,
|
|
134
134
|
f,
|
|
135
135
|
u,
|
|
136
136
|
i,
|
|
137
137
|
n.length,
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
O,
|
|
139
|
+
H,
|
|
140
140
|
l,
|
|
141
|
-
|
|
141
|
+
T
|
|
142
142
|
]), r.useEffect(() => {
|
|
143
143
|
var h;
|
|
144
|
-
const t =
|
|
144
|
+
const t = H >= l;
|
|
145
145
|
if (!f) {
|
|
146
|
-
|
|
146
|
+
N.current = l, K.current = t;
|
|
147
147
|
return;
|
|
148
148
|
}
|
|
149
|
-
const c =
|
|
150
|
-
if (
|
|
149
|
+
const c = N.current, m = K.current;
|
|
150
|
+
if (N.current = l, K.current = t, l > c && !m && t) {
|
|
151
151
|
const e = n[n.length - 1];
|
|
152
|
-
|
|
152
|
+
k.current !== void 0 && ((h = e == null ? void 0 : e.author) == null ? void 0 : h.id) !== void 0 && String(e.author.id) === String(k.current) && (_.current = !0, U.current = !0);
|
|
153
153
|
}
|
|
154
|
-
}, [f, l,
|
|
155
|
-
!f || !
|
|
154
|
+
}, [f, l, H, n]), r.useEffect(() => {
|
|
155
|
+
!f || !_.current || (_.current = !1, o.current = !1, requestAnimationFrame(() => {
|
|
156
156
|
const t = u.current;
|
|
157
157
|
t && (t.scrollTop = t.scrollHeight - t.clientHeight);
|
|
158
158
|
}));
|
|
159
159
|
}, [f, n, u]), r.useEffect(() => {
|
|
160
|
-
if (!f ||
|
|
160
|
+
if (!f || $.current === null)
|
|
161
161
|
return;
|
|
162
|
-
const t =
|
|
162
|
+
const t = $.current, c = u.current;
|
|
163
163
|
if (!c)
|
|
164
164
|
return;
|
|
165
|
-
c.querySelector(`[data-message-id="${t}"]`) && (
|
|
166
|
-
|
|
165
|
+
c.querySelector(`[data-message-id="${t}"]`) && ($.current = null, o.current = !1, requestAnimationFrame(() => {
|
|
166
|
+
y(t);
|
|
167
167
|
}));
|
|
168
|
-
}, [f, n, u,
|
|
169
|
-
f && o.current && !
|
|
170
|
-
}, [f,
|
|
168
|
+
}, [f, n, u, y]), r.useEffect(() => {
|
|
169
|
+
f && o.current && !q.current && (o.current = !1);
|
|
170
|
+
}, [f, O, H]);
|
|
171
171
|
const z = r.useMemo(() => {
|
|
172
172
|
if (a) {
|
|
173
|
-
const t = Math.max(0,
|
|
173
|
+
const t = Math.max(0, D), c = Math.min(n.length, S);
|
|
174
174
|
if (t >= c) {
|
|
175
|
-
const
|
|
176
|
-
return n.slice(
|
|
175
|
+
const m = Math.max(0, n.length - i);
|
|
176
|
+
return n.slice(m);
|
|
177
177
|
}
|
|
178
178
|
return n.slice(t, c);
|
|
179
179
|
}
|
|
180
180
|
return n;
|
|
181
|
-
}, [a, n,
|
|
182
|
-
if (!
|
|
181
|
+
}, [a, n, D, S, i]), Q = r.useMemo(() => E ? a ? S >= n.length : H >= l : !0, [E, a, S, n.length, H, l]), W = r.useCallback(() => {
|
|
182
|
+
if (!E || Q) {
|
|
183
183
|
const t = u.current;
|
|
184
184
|
t && t.scrollTo({ top: t.scrollHeight - t.clientHeight, behavior: "smooth" });
|
|
185
185
|
return;
|
|
@@ -187,34 +187,34 @@ const nt = 50, w = 100, ct = ({
|
|
|
187
187
|
if (!o.current) {
|
|
188
188
|
if (a) {
|
|
189
189
|
const t = Math.max(0, n.length - i);
|
|
190
|
-
|
|
190
|
+
B(t), A(n.length), requestAnimationFrame(() => {
|
|
191
191
|
const c = u.current;
|
|
192
192
|
c && (c.scrollTop = c.scrollHeight - c.clientHeight);
|
|
193
193
|
});
|
|
194
194
|
} else if (f) {
|
|
195
|
-
|
|
195
|
+
_.current = !0, q.current = !1, o.current = !0;
|
|
196
196
|
const t = Math.max(0, l - i);
|
|
197
|
-
|
|
197
|
+
T == null || T({ startIndex: t, endIndex: l });
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}, [
|
|
201
|
-
|
|
201
|
+
E,
|
|
202
202
|
a,
|
|
203
203
|
f,
|
|
204
|
-
|
|
204
|
+
Q,
|
|
205
205
|
n.length,
|
|
206
206
|
i,
|
|
207
207
|
l,
|
|
208
|
-
|
|
208
|
+
T,
|
|
209
209
|
u
|
|
210
210
|
]), M = r.useCallback(
|
|
211
211
|
(t) => {
|
|
212
|
-
if (!
|
|
213
|
-
|
|
212
|
+
if (!E)
|
|
213
|
+
y(t);
|
|
214
214
|
else if (a) {
|
|
215
215
|
const c = u.current;
|
|
216
216
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
217
|
-
|
|
217
|
+
y(t);
|
|
218
218
|
else {
|
|
219
219
|
if (o.current)
|
|
220
220
|
return;
|
|
@@ -222,10 +222,10 @@ const nt = 50, w = 100, ct = ({
|
|
|
222
222
|
(e) => e.id === t || String(e.id) === String(t)
|
|
223
223
|
);
|
|
224
224
|
if (h >= 0) {
|
|
225
|
-
const e = Math.floor(i / 2),
|
|
226
|
-
o.current = !0,
|
|
225
|
+
const e = Math.floor(i / 2), x = Math.max(0, h - e), V = Math.min(n.length, x + i);
|
|
226
|
+
o.current = !0, B(x), A(V), requestAnimationFrame(() => {
|
|
227
227
|
requestAnimationFrame(() => {
|
|
228
|
-
|
|
228
|
+
y(t), o.current = !1;
|
|
229
229
|
});
|
|
230
230
|
});
|
|
231
231
|
}
|
|
@@ -233,33 +233,33 @@ const nt = 50, w = 100, ct = ({
|
|
|
233
233
|
} else if (f) {
|
|
234
234
|
const c = u.current;
|
|
235
235
|
if (c == null ? void 0 : c.querySelector(`[data-message-id="${t}"]`))
|
|
236
|
-
|
|
236
|
+
y(t);
|
|
237
237
|
else {
|
|
238
238
|
if (o.current)
|
|
239
239
|
return;
|
|
240
|
-
|
|
240
|
+
$.current = t, q.current = !1, o.current = !0;
|
|
241
241
|
}
|
|
242
242
|
}
|
|
243
|
-
|
|
243
|
+
b == null || b({ id: t });
|
|
244
244
|
},
|
|
245
245
|
[
|
|
246
|
-
|
|
246
|
+
E,
|
|
247
247
|
a,
|
|
248
248
|
f,
|
|
249
249
|
u,
|
|
250
250
|
n,
|
|
251
251
|
i,
|
|
252
|
-
|
|
253
|
-
|
|
252
|
+
b,
|
|
253
|
+
y
|
|
254
254
|
]
|
|
255
255
|
);
|
|
256
256
|
return {
|
|
257
257
|
renderedMessages: z,
|
|
258
258
|
handleScrollToBottom: W,
|
|
259
259
|
handleReferencedMessageClick: M,
|
|
260
|
-
isEndless:
|
|
261
|
-
isOnLastBatch:
|
|
262
|
-
skipAutoScrollRef:
|
|
260
|
+
isEndless: E,
|
|
261
|
+
isOnLastBatch: Q,
|
|
262
|
+
skipAutoScrollRef: U
|
|
263
263
|
};
|
|
264
264
|
};
|
|
265
265
|
export {
|