@virtuoso.dev/message-list
Advanced tools
Comparing version 1.7.0 to 1.7.1
@@ -0,1 +1,8 @@ | ||
## [1.7.1](https://github.com/virtuoso-dev/message-list/compare/v1.7.0...v1.7.1) (2024-05-21) | ||
### Bug Fixes | ||
* clamp scroll location ([4404740](https://github.com/virtuoso-dev/message-list/commit/44047400fced3f11560f088ce8bcae5c4d0a6aad)) | ||
# [1.7.0](https://github.com/virtuoso-dev/message-list/compare/v1.6.1...v1.7.0) (2024-05-14) | ||
@@ -2,0 +9,0 @@ |
import { jsxs as Et, jsx as k, Fragment as Ln } from "react/jsx-runtime"; | ||
import g from "react"; | ||
import { Cell as l, Signal as S, withLatestFrom as y, map as a, mapTo as A, delayWithMicrotask as ve, filter as b, throttleTime as ne, onNext as tt, debounceTime as Ie, scan as P, useRealm as gt, useCellValue as F, Realm as wn, RealmContext as Rn, useCellValues as Dn } from "@mdxeditor/gurx"; | ||
import { Cell as l, Signal as $, withLatestFrom as I, map as a, mapTo as A, delayWithMicrotask as ve, filter as b, throttleTime as ne, onNext as tt, debounceTime as Ie, scan as P, useRealm as gt, useCellValue as F, Realm as wn, RealmContext as Rn, useCellValues as Dn } from "@mdxeditor/gurx"; | ||
function oe(e, t) { | ||
@@ -31,6 +31,6 @@ const n = l(e, (o) => { | ||
const [i, r] = Lt(o); | ||
return Be(x(e, { k: i, l: wt(o), v: r })); | ||
return Be(S(e, { k: i, l: wt(o), v: r })); | ||
} | ||
} else | ||
return t < n ? Be(x(e, { l: nt(o, t) })) : Be(x(e, { r: nt(s, t) })); | ||
return t < n ? Be(S(e, { l: nt(o, t) })) : Be(S(e, { r: nt(s, t) })); | ||
} | ||
@@ -49,3 +49,3 @@ function ie(e, t, n = "k") { | ||
function G(e, t, n) { | ||
return v(e) ? Mt(t, n, 1) : t === e.k ? x(e, { k: t, v: n }) : t < e.k ? yt(x(e, { l: G(e.l, t, n) })) : yt(x(e, { r: G(e.r, t, n) })); | ||
return v(e) ? Mt(t, n, 1) : t === e.k ? S(e, { k: t, v: n }) : t < e.k ? yt(S(e, { l: G(e.l, t, n) })) : yt(S(e, { r: G(e.r, t, n) })); | ||
} | ||
@@ -66,5 +66,5 @@ function ot(e, t, n) { | ||
function wt(e) { | ||
return v(e.r) ? e.l : Be(x(e, { r: wt(e.r) })); | ||
return v(e.r) ? e.l : Be(S(e, { r: wt(e.r) })); | ||
} | ||
function x(e, t) { | ||
function S(e, t) { | ||
return Mt(t.k ?? e.k, t.v ?? e.v, t.lvl ?? e.lvl, t.l ?? e.l, t.r ?? e.r); | ||
@@ -84,8 +84,8 @@ } | ||
if (Xe(t)) | ||
return At(x(e, { lvl: o - 1 })); | ||
return At(S(e, { lvl: o - 1 })); | ||
if (!v(t) && !v(t.r)) | ||
return x(t.r, { | ||
l: x(t, { r: t.r.l }), | ||
return S(t.r, { | ||
l: S(t, { r: t.r.l }), | ||
lvl: o, | ||
r: x(e, { | ||
r: S(e, { | ||
l: t.r.r, | ||
@@ -98,7 +98,7 @@ lvl: o - 1 | ||
if (Xe(e)) | ||
return st(x(e, { lvl: o - 1 })); | ||
return st(S(e, { lvl: o - 1 })); | ||
if (!v(n) && !v(n.l)) { | ||
const s = n.l, i = Xe(s) ? n.lvl - 1 : n.lvl; | ||
return x(s, { | ||
l: x(e, { | ||
return S(s, { | ||
l: S(e, { | ||
lvl: o - 1, | ||
@@ -108,3 +108,3 @@ r: s.l | ||
lvl: s.lvl + 1, | ||
r: st(x(n, { l: s.r, lvl: i })) | ||
r: st(S(n, { l: s.r, lvl: i })) | ||
}); | ||
@@ -138,7 +138,7 @@ } else | ||
const { r: t, lvl: n } = e; | ||
return !v(t) && !v(t.r) && t.lvl === n && t.r.lvl === n ? x(t, { l: x(e, { r: t.l }), lvl: n + 1 }) : e; | ||
return !v(t) && !v(t.r) && t.lvl === n && t.r.lvl === n ? S(t, { l: S(e, { r: t.l }), lvl: n + 1 }) : e; | ||
} | ||
function At(e) { | ||
const { l: t } = e; | ||
return !v(t) && t.lvl === e.lvl ? x(t, { r: x(e, { l: t.r }) }) : e; | ||
return !v(t) && t.lvl === e.lvl ? S(t, { r: S(e, { l: t.r }) }) : e; | ||
} | ||
@@ -283,12 +283,12 @@ function Cn(e) { | ||
i -= u + c; | ||
let $ = Nn(d, n) + r - u; | ||
f === "end" ? $ = $ - i + w() : f === "center" && ($ = $ - i / 2 + w() / 2), p && ($ += p); | ||
let y = Nn(d, n) + r - u; | ||
f === "end" ? y = y - i + w() : f === "center" && (y = y - i / 2 + w() / 2), p && (y += p); | ||
let O = 0; | ||
return f === "start" && (O = Math.max(0, Math.min($ - (o - i)))), { top: $, behavior: h, align: f, forceBottomSpace: O }; | ||
return f === "start" && (O = Math.max(0, Math.min(y - (o - i)))), y = Math.max(0, y), { top: y, behavior: h, align: f, forceBottomSpace: O }; | ||
} | ||
const Ae = l(null), zn = l(!1), Qe = l(!0), U = S((e) => { | ||
const Ae = l(null), zn = l(!1), Qe = l(!0), U = $((e) => { | ||
e.link(U, Ae), e.link( | ||
e.pipe( | ||
U, | ||
y( | ||
I( | ||
N, | ||
@@ -332,3 +332,3 @@ mt, | ||
ve(), | ||
y(Qe, Ae), | ||
I(Qe, Ae), | ||
b(([, t, n]) => !t && n !== null), | ||
@@ -356,3 +356,3 @@ a(([, , t]) => t) | ||
Fe, | ||
tt(I), | ||
tt(x), | ||
a(() => 0) | ||
@@ -372,3 +372,3 @@ ), | ||
e.combine(ke, N), | ||
y(de), | ||
I(de), | ||
b(([[n, o], s]) => n !== null && !v(o) && s !== null), | ||
@@ -467,3 +467,3 @@ tt(Kt), | ||
w, | ||
$, | ||
y, | ||
O | ||
@@ -488,3 +488,3 @@ ]) => { | ||
stickyHeaderHeight: w, | ||
stickyFooterHeight: $ | ||
stickyFooterHeight: y | ||
}).top ?? 0); | ||
@@ -528,3 +528,3 @@ const j = Math.max( | ||
}), qn = oe([], (e) => e.pipe( | ||
e.combine(Se, I), | ||
e.combine(Se, x), | ||
a(([t, n]) => { | ||
@@ -557,4 +557,4 @@ const o = t.items.slice(); | ||
const _t = l(!0); | ||
S(); | ||
const Jn = S((e) => { | ||
$(); | ||
const Jn = $((e) => { | ||
e.link(e.pipe(_t, ne(50)), Jn); | ||
@@ -564,3 +564,3 @@ }), Xn = l(4), Qn = l(Zn, (e) => { | ||
e.pipe( | ||
e.combine(I, Qn), | ||
e.combine(x, Qn), | ||
a(([t, n]) => t <= n) | ||
@@ -571,3 +571,3 @@ ), | ||
}), ye = l(!1, (e) => { | ||
e.link(e.pipe(I, It(1), A(!0)), ye), e.link(e.pipe(I, It(1), A(!1), Ie(100)), ye); | ||
e.link(e.pipe(x, It(1), A(!0)), ye), e.link(e.pipe(x, It(1), A(!1), Ie(100)), ye); | ||
}), it = l(!1, (e) => { | ||
@@ -580,3 +580,3 @@ e.link(e.pipe(Z, A(!0)), it), e.link(e.pipe(Z, A(!1), Ie(200)), it); | ||
e.pipe( | ||
e.combine(Ee, I, K, Gt, Xn, Ke, N), | ||
e.combine(Ee, x, K, Gt, Xn, Ke, N), | ||
b(([, , , , , , t]) => !v(t)), | ||
@@ -630,3 +630,3 @@ P((t, [n, o, s, i, r]) => { | ||
K, | ||
y(Oe), | ||
I(Oe), | ||
P( | ||
@@ -649,3 +649,3 @@ (t, [n, o]) => { | ||
e.pipe( | ||
e.combine(I, Ee, K), | ||
e.combine(x, Ee, K), | ||
P( | ||
@@ -685,3 +685,3 @@ (t, [n, o, s]) => { | ||
e.pipe( | ||
I, | ||
x, | ||
P( | ||
@@ -694,9 +694,9 @@ (t, n) => e.getValue(it) ? { direction: t.direction, prevScrollTop: n } : { direction: n < t.prevScrollTop ? Ft : et, prevScrollTop: n }, | ||
rt | ||
), e.link(e.pipe(I, ne(50), A(Un)), rt); | ||
), e.link(e.pipe(x, ne(50), A(Un)), rt); | ||
}), xt = l(0, (e) => { | ||
e.link(e.pipe(ye, b(Ot), A(0)), xt), e.link( | ||
e.pipe( | ||
I, | ||
x, | ||
ne(100), | ||
y(ye), | ||
I(ye), | ||
b(([, t]) => !!t), | ||
@@ -708,7 +708,7 @@ P(([, t], [n]) => [t, n], [0, 0]), | ||
); | ||
}), C = l(!1), Ve = S((e) => { | ||
}), C = l(!1), Ve = $((e) => { | ||
e.link( | ||
e.pipe( | ||
Se, | ||
y(Nt, ee), | ||
I(Nt, ee), | ||
b(([, , t]) => !t), | ||
@@ -724,3 +724,3 @@ P( | ||
b(([t]) => t !== 0), | ||
y(I, rt, Te), | ||
I(x, rt, Te), | ||
b(([, t, n, o]) => !o && t !== 0 && n === Ft), | ||
@@ -730,5 +730,5 @@ a(([[t]]) => t) | ||
Ve | ||
), Bt() ? (e.sub(e.pipe(Ve, y(H, I)), ([t, n]) => { | ||
), Bt() ? (e.sub(e.pipe(Ve, I(H, x)), ([t, n]) => { | ||
e.pub(H, n - t); | ||
}), e.sub(e.pipe(e.combine(I, H, ee)), ([t, n, o]) => { | ||
}), e.sub(e.pipe(e.combine(x, H, ee)), ([t, n, o]) => { | ||
o || (n > 0 && t < n ? (e.pub(C, !0), e.pub(le, { top: 0, behavior: "instant" }), setTimeout(() => { | ||
@@ -778,3 +778,3 @@ e.pubIn({ | ||
); | ||
}), eo = 4, te = S((e) => { | ||
}), eo = 4, te = $((e) => { | ||
e.link(e.pipe(te, A(!0)), ee); | ||
@@ -785,3 +785,3 @@ const t = Bt(); | ||
te, | ||
y(se), | ||
I(se), | ||
a(([n, o]) => o * n.length) | ||
@@ -793,3 +793,3 @@ ), | ||
te, | ||
y(se), | ||
I(se), | ||
a(([n, o]) => ({ | ||
@@ -813,3 +813,3 @@ top: o * n.length, | ||
te, | ||
y(N, se), | ||
I(N, se), | ||
a(([n, o, s]) => { | ||
@@ -833,7 +833,7 @@ const i = n.length, r = s; | ||
); | ||
}), zt = S((e) => { | ||
}), zt = $((e) => { | ||
e.link( | ||
e.pipe( | ||
zt, | ||
y(je, ut, Pe, N), | ||
I(je, ut, Pe, N), | ||
b(([, , , , t]) => !v(t)), | ||
@@ -866,5 +866,5 @@ a(([{ data: t, scrollToBottom: n }, o, s, i]) => { | ||
); | ||
}), lt = S((e) => { | ||
}), lt = $((e) => { | ||
e.changeWith(B, lt, (t, n) => t ? [...t, ...n.data] : n.data.slice()), e.link(lt, zt); | ||
}), We = S((e) => { | ||
}), We = $((e) => { | ||
e.changeWith(B, We, (t, n) => n.data.slice()), e.link( | ||
@@ -877,9 +877,9 @@ e.pipe( | ||
), e.link(e.pipe(We, A(ze)), ue); | ||
}), St = S((e) => { | ||
}), St = $((e) => { | ||
e.changeWith(B, St, (t, n) => t ? t.slice(n) : []), e.changeWith(ue, St, ([t], n) => [be(t).reduce((s, { k: i, v: r }) => G(s, Math.max(0, i - n), r), xe()), 0]); | ||
}), $t = S((e) => { | ||
}), $t = $((e) => { | ||
e.changeWith(B, $t, (t, n) => t ? t.slice(0, t.length - n) : []), e.link( | ||
e.pipe( | ||
$t, | ||
y(ce, se), | ||
I(ce, se), | ||
a(([, t, n]) => [ | ||
@@ -895,6 +895,6 @@ { | ||
); | ||
}), Yt = S((e) => { | ||
}), Yt = $((e) => { | ||
const t = e.pipe( | ||
Yt, | ||
y(B), | ||
I(B), | ||
a(([n, o]) => { | ||
@@ -910,3 +910,3 @@ if (!o) | ||
e.changeWith(B, t, (n, o) => n ? n.filter((s, i) => !o.includes(i)) : []), e.changeWith(ue, t, ([n], o) => [Yn(n, o), 0]); | ||
}), ct = S((e) => { | ||
}), ct = $((e) => { | ||
e.changeWith(B, ct, (t, { mapper: n }) => t ? t.map(n) : []), e.link( | ||
@@ -916,3 +916,3 @@ e.pipe( | ||
ne(40), | ||
y(Pt), | ||
I(Pt), | ||
b(([{ autoscrollToBottomBehavior: t }, n]) => n && !!t), | ||
@@ -923,7 +923,7 @@ a(([{ autoscrollToBottomBehavior: t }]) => ({ index: "LAST", align: "end", behavior: t })) | ||
); | ||
}), $e = S(); | ||
}), $e = $(); | ||
l([]); | ||
l([]); | ||
l(0); | ||
const Kt = S(); | ||
const Kt = $(); | ||
l(null); | ||
@@ -936,3 +936,3 @@ l(NaN); | ||
b((t) => t.length > 0), | ||
y(N), | ||
I(N), | ||
a(([t, n]) => Bn(n, [t, []])) | ||
@@ -952,3 +952,3 @@ ), | ||
$e, | ||
y(N), | ||
I(N), | ||
P( | ||
@@ -977,3 +977,3 @@ ({ sizeTree: t }, [, n]) => ({ | ||
N, | ||
y(jt), | ||
I(jt), | ||
P(([t], [n, o]) => _n(t, [n, o]), re) | ||
@@ -1019,5 +1019,5 @@ ), | ||
); | ||
}), Te = S(), ut = l(!1), Ne = S((e) => { | ||
}), Te = $(), ut = l(!1), Ne = $((e) => { | ||
e.link(e.pipe(Ne, A(!1)), Te); | ||
}), I = l(0), K = l(0), Gt = l(0), Ee = l(0), to = I, Fe = l(0), Me = l(0), Le = l(0), we = l(0), bt = l(0), at = l(null), Ye = oe(0, (e) => e.pipe( | ||
}), x = l(0), K = l(0), Gt = l(0), Ee = l(0), to = x, Fe = l(0), Me = l(0), Le = l(0), we = l(0), bt = l(0), at = l(null), Ye = oe(0, (e) => e.pipe( | ||
e.combine(Me, Le), | ||
@@ -1029,6 +1029,6 @@ a(([t, n]) => t + n) | ||
)), no = oe(0, (e) => e.pipe( | ||
e.combine(Me, Le, I), | ||
e.combine(Me, Le, x), | ||
a(([t, n, o]) => t + Math.max(n - o, 0)) | ||
)), oo = oe(0, (e) => e.pipe( | ||
e.combine(we, bt, I, K, Ee), | ||
e.combine(we, bt, x, K, Ee), | ||
a(([t, n, o, s, i]) => { | ||
@@ -1049,3 +1049,3 @@ const r = Math.max(n - (i - (o + s)), 0); | ||
); | ||
}), le = S((e) => { | ||
}), le = $((e) => { | ||
e.link( | ||
@@ -1060,3 +1060,3 @@ e.pipe( | ||
le, | ||
y(I), | ||
I(x), | ||
b(([t, n]) => t.top !== n), | ||
@@ -1076,3 +1076,3 @@ A(!0) | ||
e.combine( | ||
I, | ||
x, | ||
Ye, | ||
@@ -1099,8 +1099,8 @@ Zt, | ||
) | ||
), pt = S((e) => { | ||
), pt = $((e) => { | ||
e.link( | ||
e.pipe( | ||
I, | ||
x, | ||
Ie(0), | ||
y(je), | ||
I(je), | ||
b(([, t]) => t.scrollHeight > 0), | ||
@@ -1111,3 +1111,3 @@ a(([, t]) => t) | ||
); | ||
}), Z = S(), H = l(0), ft = l(0), Qt = l(""); | ||
}), Z = $(), H = l(0), ft = l(0), Qt = l(""); | ||
function so(e) { | ||
@@ -1147,3 +1147,3 @@ const t = g.useRef(null), n = g.useRef(null), o = gt(), s = g.useCallback( | ||
(p) => { | ||
var d, w, $, O; | ||
var d, w, y, O; | ||
if (p.top === ((d = t.current) == null ? void 0 : d.scrollTop)) { | ||
@@ -1154,3 +1154,3 @@ o.pub(Ne, (w = t.current) == null ? void 0 : w.scrollTop); | ||
if (p.top !== void 0 && (n.current = p.top, o.pub(ut, !0)), p.forceBottomSpace !== void 0) { | ||
const V = ($ = t.current) == null ? void 0 : $.querySelector('[data-role="virtuoso-list"]'); | ||
const V = (y = t.current) == null ? void 0 : y.querySelector('[data-role="virtuoso-list"]'); | ||
V && (V.style.paddingBottom = `${p.forceBottomSpace}px`); | ||
@@ -1585,3 +1585,3 @@ } | ||
now: /* @__PURE__ */ new Date(), | ||
packageTimestamp: 1715677996964 | ||
packageTimestamp: 1716283017874 | ||
}); | ||
@@ -1657,3 +1657,3 @@ return /* @__PURE__ */ k(yn.Provider, { value: n, children: t }); | ||
StickyHeaderWrapper: w = fn, | ||
FooterWrapper: $ = pn, | ||
FooterWrapper: y = pn, | ||
StickyFooterWrapper: O = hn, | ||
@@ -1679,3 +1679,3 @@ ScrollElement: V = "div", | ||
[gn]: w, | ||
[vn]: $, | ||
[vn]: y, | ||
[dn]: d, | ||
@@ -1735,3 +1735,3 @@ [dt]: s | ||
un | ||
), $ = g.useCallback( | ||
), y = g.useCallback( | ||
(m, xn) => { | ||
@@ -1741,3 +1741,3 @@ const kt = m.querySelector('[data-role="virtuoso-list"]'), Sn = m.querySelector('[data-role="virtuoso-header"]'), $n = m.querySelector('[data-role="virtuoso-sticky-header"]'), Tn = m.querySelector('[data-role="virtuoso-footer"]'), En = m.querySelector('[data-role="virtuoso-sticky-footer"]'), Mn = kt && xn === "resize" ? io(kt.children) : []; | ||
[$e]: Mn, | ||
[I]: m.scrollTop, | ||
[x]: m.scrollTop, | ||
[Ee]: m.scrollHeight, | ||
@@ -1753,7 +1753,7 @@ [K]: he(m), | ||
[n] | ||
), { elRef: O, callbackRef: V, listCallbackRef: j, observer: z, scrollBy: W, scrollTo: Y } = so($), R = He(z), Ue = He(z), _ = He(z), Re = He(z), { items: pe } = F(Se); | ||
), { elRef: O, callbackRef: V, listCallbackRef: j, observer: z, scrollBy: W, scrollTo: Y } = so(y), R = He(z), Ue = He(z), _ = He(z), Re = He(z), { items: pe } = F(Se); | ||
g.useLayoutEffect(() => { | ||
const m = O.current; | ||
m && $(m, "resize"); | ||
}, [pe, O, $, p]), g.useLayoutEffect(() => n.sub(le, Y), [Y, n]), g.useLayoutEffect(() => n.sub(Z, W), [W, n]); | ||
m && y(m, "resize"); | ||
}, [pe, O, y, p]), g.useLayoutEffect(() => n.sub(le, Y), [Y, n]), g.useLayoutEffect(() => n.sub(Z, W), [W, n]); | ||
const Ge = F(H), Ze = F(C), De = F(ft), q = F(Ke), fe = F(Qt), D = F(Pe), J = F(nn), Je = F(ce), X = F(ae); | ||
@@ -1760,0 +1760,0 @@ return /* @__PURE__ */ k(Ln, { children: /* @__PURE__ */ Et( |
@@ -23,3 +23,3 @@ { | ||
}, | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"type": "module", | ||
@@ -26,0 +26,0 @@ "module": "dist/index.js", |
73095