@progress/kendo-react-conversational-ui 14.3.3-develop.1 → 14.4.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/AIPromptContent.js +1 -1
- package/ai-prompt/AIPromptContent.mjs +2 -2
- package/ai-prompt/views/AIPromptOutputView.js +1 -1
- package/ai-prompt/views/AIPromptOutputView.mjs +63 -36
- package/chat/ChatPropsAndState.d.ts +65 -0
- package/chat/Events.d.ts +19 -0
- package/chat/components/Chat.js +1 -1
- package/chat/components/Chat.mjs +373 -314
- package/chat/components/ChatContext.d.ts +2 -0
- package/chat/components/ChatMessage.js +1 -1
- package/chat/components/ChatMessage.mjs +174 -175
- package/chat/components/elements/PinnedMessage.d.ts +1 -0
- package/chat/components/elements/PinnedMessage.js +1 -1
- package/chat/components/elements/PinnedMessage.mjs +17 -21
- package/chat/hooks/useEndlessScroll.d.ts +49 -0
- package/chat/hooks/useEndlessScroll.js +8 -0
- package/chat/hooks/useEndlessScroll.mjs +267 -0
- package/chat/utils/scroll.d.ts +5 -2
- package/chat/utils/scroll.js +1 -1
- package/chat/utils/scroll.mjs +89 -83
- 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/utils/scroll.mjs
CHANGED
|
@@ -5,137 +5,143 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
const
|
|
10
|
-
const r =
|
|
8
|
+
import * as o from "react";
|
|
9
|
+
const $ = 100, j = "20%", k = (t) => {
|
|
10
|
+
const r = t.querySelector(".k-message-pinned");
|
|
11
11
|
return r ? r.offsetHeight : 0;
|
|
12
|
-
},
|
|
13
|
-
const n =
|
|
14
|
-
let
|
|
12
|
+
}, G = (t, r) => {
|
|
13
|
+
const n = t != null ? t : j;
|
|
14
|
+
let s;
|
|
15
15
|
if (typeof n == "number")
|
|
16
|
-
|
|
16
|
+
s = n;
|
|
17
17
|
else {
|
|
18
18
|
const l = /^(-?\d+(?:\.\d+)?)%$/.exec(String(n));
|
|
19
19
|
if (l)
|
|
20
|
-
|
|
20
|
+
s = Number.parseFloat(l[1]) / 100 * r;
|
|
21
21
|
else {
|
|
22
22
|
const u = Number.parseFloat(String(n));
|
|
23
|
-
|
|
23
|
+
s = Number.isNaN(u) ? 0.2 * r : u;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
return Math.min(
|
|
27
|
-
},
|
|
28
|
-
const { scrollHeight: r, scrollTop: n, clientHeight:
|
|
29
|
-
return !(r >
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
},
|
|
33
|
-
const r =
|
|
26
|
+
return Math.min(s, r);
|
|
27
|
+
}, J = (t) => {
|
|
28
|
+
const { scrollHeight: r, scrollTop: n, clientHeight: s } = t;
|
|
29
|
+
return !(r > s) || r - n - s <= $;
|
|
30
|
+
}, y = (t) => {
|
|
31
|
+
t.scrollTop = t.scrollHeight - t.clientHeight;
|
|
32
|
+
}, Q = (t) => {
|
|
33
|
+
const r = t.querySelectorAll(".k-message");
|
|
34
34
|
return r.length > 0 ? r[r.length - 1] : null;
|
|
35
|
-
},
|
|
36
|
-
viewItemsWrapperRef:
|
|
35
|
+
}, Y = ({
|
|
36
|
+
viewItemsWrapperRef: t,
|
|
37
37
|
isKeyboardNavigationActiveRef: r,
|
|
38
38
|
processedMessages: n,
|
|
39
|
-
authorId:
|
|
40
|
-
autoScrollThreshold: l
|
|
39
|
+
authorId: s,
|
|
40
|
+
autoScrollThreshold: l,
|
|
41
|
+
isEndless: u = !1,
|
|
42
|
+
isOnLastBatch: h = !0,
|
|
43
|
+
skipAutoScrollRef: d
|
|
41
44
|
}) => {
|
|
42
|
-
var
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
u.current =
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (_ || N) {
|
|
56
|
-
const t = e.current;
|
|
57
|
-
E.current = t ? V(t) : !0;
|
|
45
|
+
var D;
|
|
46
|
+
const R = o.useRef(s), E = o.useRef(l), L = o.useRef(u), x = o.useRef(h);
|
|
47
|
+
o.useEffect(() => {
|
|
48
|
+
R.current = s, E.current = l, L.current = u, x.current = h;
|
|
49
|
+
});
|
|
50
|
+
const C = o.useRef(!1);
|
|
51
|
+
o.useEffect(() => {
|
|
52
|
+
u || !t.current || n.length === 0 || C.current || (y(t.current), C.current = !0);
|
|
53
|
+
}, [t, u, n.length]);
|
|
54
|
+
const M = o.useRef(void 0), p = o.useRef(0), F = o.useRef(!0), B = o.useRef(!0), a = o.useRef(!1), f = o.useRef(null), z = (n.length > 0 ? (D = n.at(-1)) == null ? void 0 : D.id : void 0) !== M.current, A = n.length > p.current;
|
|
55
|
+
if (z || A) {
|
|
56
|
+
const e = t.current;
|
|
57
|
+
B.current = e ? J(e) : !0;
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
var
|
|
61
|
-
const
|
|
62
|
-
if (
|
|
59
|
+
o.useEffect(() => {
|
|
60
|
+
var q, P;
|
|
61
|
+
const e = n.length, m = e > 0 ? (q = n[e - 1]) == null ? void 0 : q.id : void 0, v = M.current, H = p.current, T = F.current;
|
|
62
|
+
if (M.current = m, p.current = e, F.current = !1, e === 0)
|
|
63
63
|
return;
|
|
64
|
-
const
|
|
65
|
-
if (!
|
|
64
|
+
const c = t.current;
|
|
65
|
+
if (!c || r.current)
|
|
66
66
|
return;
|
|
67
|
-
if (!(!
|
|
68
|
-
(
|
|
67
|
+
if (!(!T && m !== v)) {
|
|
68
|
+
!L.current && (T || e > H) && (y(c), a.current = !1, f.current = null);
|
|
69
69
|
return;
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
if (L.current && !x.current)
|
|
72
|
+
return;
|
|
73
|
+
if (d != null && d.current) {
|
|
74
|
+
d.current = !1;
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const i = n[e - 1];
|
|
78
|
+
if (R.current !== void 0 && ((P = i == null ? void 0 : i.author) == null ? void 0 : P.id) !== void 0 && String(i.author.id) === String(R.current)) {
|
|
79
|
+
c.scrollTo({ top: c.scrollHeight - c.clientHeight, behavior: "smooth" }), a.current = !1, f.current = null;
|
|
74
80
|
return;
|
|
75
81
|
}
|
|
76
|
-
if (!
|
|
82
|
+
if (!B.current) {
|
|
77
83
|
a.current = !1, f.current = null;
|
|
78
84
|
return;
|
|
79
85
|
}
|
|
80
|
-
const
|
|
81
|
-
if (!
|
|
86
|
+
const b = Q(c);
|
|
87
|
+
if (!b)
|
|
82
88
|
return;
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
top:
|
|
89
|
+
const S = k(c), U = Math.max(0, c.clientHeight - S), w = G(E.current, U), I = b.getBoundingClientRect().top - c.getBoundingClientRect().top + c.scrollTop, N = Math.max(0, I - w - S), V = Math.max(0, c.scrollHeight - c.clientHeight), _ = Math.min(N, V);
|
|
90
|
+
_ > c.scrollTop && c.scrollTo({
|
|
91
|
+
top: _,
|
|
86
92
|
behavior: "smooth"
|
|
87
|
-
}), f.current =
|
|
88
|
-
}, [n,
|
|
89
|
-
const
|
|
90
|
-
if (!
|
|
93
|
+
}), f.current = N, a.current = !0;
|
|
94
|
+
}, [n, t, r]), o.useEffect(() => {
|
|
95
|
+
const e = t.current;
|
|
96
|
+
if (!e)
|
|
91
97
|
return;
|
|
92
|
-
let m =
|
|
93
|
-
const
|
|
94
|
-
const g =
|
|
95
|
-
a.current && g <
|
|
96
|
-
},
|
|
98
|
+
let m = e.querySelectorAll(".k-message").length, v = e.scrollHeight, H = e.scrollTop;
|
|
99
|
+
const T = () => {
|
|
100
|
+
const g = e.scrollTop;
|
|
101
|
+
a.current && g < H && (a.current = !1, f.current = null), H = g;
|
|
102
|
+
}, c = new MutationObserver(() => {
|
|
97
103
|
if (r.current)
|
|
98
104
|
return;
|
|
99
|
-
const g =
|
|
100
|
-
if (g === m && i >
|
|
101
|
-
const
|
|
102
|
-
|
|
105
|
+
const g = e.querySelectorAll(".k-message").length, i = e.scrollHeight;
|
|
106
|
+
if (g === m && i > v && a.current) {
|
|
107
|
+
const O = i - e.clientHeight, b = f.current, S = b === null ? O : Math.min(O, b);
|
|
108
|
+
S > e.scrollTop && (e.scrollTop = S), H = e.scrollTop;
|
|
103
109
|
}
|
|
104
|
-
m = g,
|
|
110
|
+
m = g, v = i;
|
|
105
111
|
});
|
|
106
|
-
return
|
|
112
|
+
return c.observe(e, {
|
|
107
113
|
childList: !0,
|
|
108
114
|
subtree: !0,
|
|
109
115
|
characterData: !0
|
|
110
|
-
}),
|
|
111
|
-
|
|
116
|
+
}), e.addEventListener("scroll", T, { passive: !0 }), () => {
|
|
117
|
+
c.disconnect(), e.removeEventListener("scroll", T);
|
|
112
118
|
};
|
|
113
|
-
}, [
|
|
114
|
-
},
|
|
115
|
-
const [r, n] =
|
|
116
|
-
return
|
|
117
|
-
const
|
|
118
|
-
if (!
|
|
119
|
+
}, [t, r]);
|
|
120
|
+
}, Z = ({ elementRef: t }) => {
|
|
121
|
+
const [r, n] = o.useState(!1);
|
|
122
|
+
return o.useEffect(() => {
|
|
123
|
+
const s = t.current;
|
|
124
|
+
if (!s)
|
|
119
125
|
return;
|
|
120
126
|
const l = () => {
|
|
121
|
-
n(
|
|
127
|
+
n(s.scrollHeight > s.clientHeight);
|
|
122
128
|
};
|
|
123
129
|
l();
|
|
124
130
|
const u = new ResizeObserver(l);
|
|
125
|
-
u.observe(
|
|
131
|
+
u.observe(s);
|
|
126
132
|
const h = new MutationObserver(() => {
|
|
127
133
|
requestAnimationFrame(l);
|
|
128
134
|
});
|
|
129
|
-
return h.observe(
|
|
135
|
+
return h.observe(s, {
|
|
130
136
|
childList: !0,
|
|
131
137
|
subtree: !0,
|
|
132
138
|
characterData: !0
|
|
133
139
|
}), () => {
|
|
134
140
|
u.disconnect(), h.disconnect();
|
|
135
141
|
};
|
|
136
|
-
}, [
|
|
142
|
+
}, [t]), r;
|
|
137
143
|
};
|
|
138
144
|
export {
|
|
139
|
-
|
|
140
|
-
|
|
145
|
+
Z as useHasScrollbar,
|
|
146
|
+
Y as useMessageAutoScroll
|
|
141
147
|
};
|