@progress/kendo-react-conversational-ui 14.3.3-develop.2 → 14.4.0-develop.2

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.
@@ -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 s from "react";
9
- const I = 250, P = 100, y = "20%", z = (e) => {
10
- const r = e.querySelector(".k-message-pinned");
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
- }, U = (e, r) => {
13
- const n = e != null ? e : y;
14
- let c;
12
+ }, G = (t, r) => {
13
+ const n = t != null ? t : j;
14
+ let s;
15
15
  if (typeof n == "number")
16
- c = n;
16
+ s = n;
17
17
  else {
18
18
  const l = /^(-?\d+(?:\.\d+)?)%$/.exec(String(n));
19
19
  if (l)
20
- c = Number.parseFloat(l[1]) / 100 * r;
20
+ s = Number.parseFloat(l[1]) / 100 * r;
21
21
  else {
22
22
  const u = Number.parseFloat(String(n));
23
- c = Number.isNaN(u) ? 0.2 * r : u;
23
+ s = Number.isNaN(u) ? 0.2 * r : u;
24
24
  }
25
25
  }
26
- return Math.min(c, r);
27
- }, V = (e) => {
28
- const { scrollHeight: r, scrollTop: n, clientHeight: c } = e;
29
- return !(r > c) || r - n - c <= P;
30
- }, v = (e) => {
31
- e.scrollTop = e.scrollHeight - e.clientHeight;
32
- }, Y = (e) => {
33
- const r = e.querySelectorAll(".k-message");
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
- }, j = ({
36
- viewItemsWrapperRef: e,
35
+ }, Y = ({
36
+ viewItemsWrapperRef: t,
37
37
  isKeyboardNavigationActiveRef: r,
38
38
  processedMessages: n,
39
- authorId: c,
40
- autoScrollThreshold: l
39
+ authorId: s,
40
+ autoScrollThreshold: l,
41
+ isEndless: u = !1,
42
+ isOnLastBatch: h = !0,
43
+ skipAutoScrollRef: d
41
44
  }) => {
42
- var O;
43
- const u = s.useRef(c), h = s.useRef(l);
44
- s.useEffect(() => {
45
- u.current = c;
46
- }), s.useEffect(() => {
47
- h.current = l;
48
- }), s.useEffect(() => {
49
- const t = globalThis.setTimeout(() => {
50
- e.current && v(e.current);
51
- }, I);
52
- return () => clearTimeout(t);
53
- }, [e]);
54
- const L = s.useRef(void 0), p = s.useRef(0), M = s.useRef(!0), E = s.useRef(!0), a = s.useRef(!1), f = s.useRef(null), _ = (n.length > 0 ? (O = n.at(-1)) == null ? void 0 : O.id : void 0) !== L.current, N = n.length > p.current;
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
- s.useEffect(() => {
60
- var A, F;
61
- const t = n.length, m = t > 0 ? (A = n[t - 1]) == null ? void 0 : A.id : void 0, H = L.current, T = p.current, S = M.current;
62
- if (L.current = m, p.current = t, M.current = !1, t === 0)
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 o = e.current;
65
- if (!o || r.current)
64
+ const c = t.current;
65
+ if (!c || r.current)
66
66
  return;
67
- if (!(!S && m !== H)) {
68
- (S || t > T) && (v(o), a.current = !1, f.current = null);
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
- const i = n[t - 1];
72
- if (u.current !== void 0 && ((F = i == null ? void 0 : i.author) == null ? void 0 : F.id) !== void 0 && String(i.author.id) === String(u.current)) {
73
- v(o), a.current = !1, f.current = null;
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 (!E.current) {
82
+ if (!B.current) {
77
83
  a.current = !1, f.current = null;
78
84
  return;
79
85
  }
80
- const d = Y(o);
81
- if (!d)
86
+ const b = Q(c);
87
+ if (!b)
82
88
  return;
83
- const b = z(o), B = Math.max(0, o.clientHeight - b), D = U(h.current, B), k = d.getBoundingClientRect().top - o.getBoundingClientRect().top + o.scrollTop, C = Math.max(0, k - D - b), q = Math.max(0, o.scrollHeight - o.clientHeight), x = Math.min(C, q);
84
- x > o.scrollTop && o.scrollTo({
85
- top: x,
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 = C, a.current = !0;
88
- }, [n, e, r]), s.useEffect(() => {
89
- const t = e.current;
90
- if (!t)
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 = t.querySelectorAll(".k-message").length, H = t.scrollHeight, T = t.scrollTop;
93
- const S = () => {
94
- const g = t.scrollTop;
95
- a.current && g < T && (a.current = !1, f.current = null), T = g;
96
- }, o = new MutationObserver(() => {
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 = t.querySelectorAll(".k-message").length, i = t.scrollHeight;
100
- if (g === m && i > H && a.current) {
101
- const R = i - t.clientHeight, d = f.current, b = d === null ? R : Math.min(R, d);
102
- b > t.scrollTop && (t.scrollTop = b), T = t.scrollTop;
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, H = i;
110
+ m = g, v = i;
105
111
  });
106
- return o.observe(t, {
112
+ return c.observe(e, {
107
113
  childList: !0,
108
114
  subtree: !0,
109
115
  characterData: !0
110
- }), t.addEventListener("scroll", S, { passive: !0 }), () => {
111
- o.disconnect(), t.removeEventListener("scroll", S);
116
+ }), e.addEventListener("scroll", T, { passive: !0 }), () => {
117
+ c.disconnect(), e.removeEventListener("scroll", T);
112
118
  };
113
- }, [e, r]);
114
- }, w = ({ elementRef: e }) => {
115
- const [r, n] = s.useState(!1);
116
- return s.useEffect(() => {
117
- const c = e.current;
118
- if (!c)
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(c.scrollHeight > c.clientHeight);
127
+ n(s.scrollHeight > s.clientHeight);
122
128
  };
123
129
  l();
124
130
  const u = new ResizeObserver(l);
125
- u.observe(c);
131
+ u.observe(s);
126
132
  const h = new MutationObserver(() => {
127
133
  requestAnimationFrame(l);
128
134
  });
129
- return h.observe(c, {
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
- }, [e]), r;
142
+ }, [t]), r;
137
143
  };
138
144
  export {
139
- j as useChatScroll,
140
- w as useHasScrollbar
145
+ Z as useHasScrollbar,
146
+ Y as useMessageAutoScroll
141
147
  };