@af-utils/react-virtual-headless
Advanced tools
Comparing version 0.0.43 to 0.0.44
@@ -1,4 +0,4 @@ | ||
export const raw = 8160; | ||
export const min = 4701; | ||
export const minGz = 2113; | ||
export const minBrotli = 1920; | ||
export const raw = 8165; | ||
export const min = 4648; | ||
export const minGz = 2096; | ||
export const minBrotli = 1892; |
146
lib/index.js
@@ -10,3 +10,3 @@ import { useRef as t, useEffect as s, useLayoutEffect as i, useCallback as h } from "react"; | ||
return h; | ||
}, r = 0, n = 1, c = 2, l = [ 0, 1, 2 ], f = ResizeObserver, u = t => t(), a = new Set, m = { | ||
}, r = 0, n = 1, l = 2, c = [ 0, 1, 2 ], f = ResizeObserver, u = t => t(), a = new Set, m = { | ||
t: 0, | ||
@@ -20,3 +20,3 @@ i() { | ||
o: t => a.add(t) | ||
}, p = Uint32Array, w = new p(0), d = t => { | ||
}, p = Uint32Array, d = new p(0), w = t => { | ||
const s = t.length + 1, i = new p(s); | ||
@@ -41,16 +41,16 @@ i.set(t, 1); | ||
constructor(t) { | ||
this.horizontal = !1, this._ = "top", this.M = "scrollTop", this.S = "offsetHeight", | ||
this.v = 0, this.u = 0, this.T = 0, this.k = 0, this.C = 0, this.F = 0, this.H = 3, | ||
this.O = null, this.I = w, this.R = w, this.q = 0, this.scrollSize = 0, this.from = 0, | ||
this.to = 0, this.sizesHash = 0, this.A = new Map, this.G = new Map, this.L = [ null, null ], | ||
this.U = [ 0, 0 ], this.W = new f((t => { | ||
this.horizontal = !1, this._ = "top", this.M = "scrollTop", this.v = "offsetHeight", | ||
this.S = 0, this.u = 0, this.T = 0, this.C = 0, this.k = 0, this.F = 0, this.H = 3, | ||
this.I = 40, this.O = null, this.R = d, this.q = d, this.A = 0, this.scrollSize = 0, | ||
this.from = 0, this.to = 0, this.sizesHash = 0, this.G = new Map, this.L = new Map, | ||
this.U = [ null, null ], this.W = [ 0, 0 ], this.$ = new f((t => { | ||
let s = 0, i = 0, h = 0; | ||
for (const {target: e} of t) s = this.L.indexOf(e), -1 !== s && (i = e[this.S] - this.U[s], | ||
i && (this.U[s] += i, h += i)); | ||
for (const {target: e} of t) s = this.U.indexOf(e), -1 !== s && (i = e[this.v] - this.W[s], | ||
i && (this.W[s] += i, h += i)); | ||
this.l(h); | ||
})), this.$ = new f((t => { | ||
})), this.j = new f((t => { | ||
let s = 0, i = 0, h = 0, e = !1, o = this.from + 1; | ||
for (;o < this.to; o += o & -o) ; | ||
o = Math.min(o, this.R.length); | ||
for (const {target: r} of t) s = this.A.get(r), | ||
o = Math.min(o, this.q.length); | ||
for (const {target: r} of t) s = this.G.get(r), | ||
/* | ||
@@ -61,5 +61,5 @@ ResizeObserver may give us elements, which are not in visible range => will be unmounted soon. | ||
*/ | ||
s >= this.from && s < this.to && (i = r[this.S] - this.I[s], i && (e = !0, this.I[s] += i, | ||
h += i, g(this.R, s + 1, i, o))); | ||
e && (m.i(), 0 !== h && (g(this.R, o, h, this.R.length), this.v += h, this.scrollSize += h, | ||
s >= this.from && s < this.to && (i = r[this.v] - this.R[s], i && (e = !0, this.R[s] += i, | ||
h += i, g(this.q, s + 1, i, o))); | ||
e && (m.i(), 0 !== h && (g(this.q, o, h, this.q.length), this.S += h, this.scrollSize += h, | ||
this.p(1), 0 > h && | ||
@@ -76,28 +76,28 @@ /* | ||
*/ , this.sizesHash = this.sizesHash + 1 & 65535, this.p(2), m.h()); | ||
})), this.j = l.map((() => [])), this.B = () => { | ||
const t = this.O[this.S] - this.u; | ||
})), this.B = c.map((() => [])), this.D = () => { | ||
const t = this.O[this.v] - this.u; | ||
t !== this.m && (this.m = t, this.g()); | ||
}, this.D = new f(this.B), this.J = t => { | ||
}, this.J = new f(this.D), this.K = t => { | ||
const s = this.F, i = this.O[this.M]; | ||
i !== s && (this.F = i, this.k = t.timeStamp, i > s ? this.g() : this.K()); | ||
i !== s && (this.F = i, this.C = t.timeStamp, i > s ? this.g() : this.N()); | ||
}, this.setOuterNode = t => { | ||
this.O && (this.D.unobserve(this.O), this.O.removeEventListener("scroll", this.J)), | ||
(this.O = t) ? (this.D.observe(t), t.addEventListener("scroll", this.J, { | ||
this.O && (this.J.unobserve(this.O), this.O.removeEventListener("scroll", this.K)), | ||
(this.O = t) ? (this.J.observe(t), t.addEventListener("scroll", this.K, { | ||
passive: !0 | ||
})) : (this.$.disconnect(), this.W.disconnect(), clearTimeout(this.C)); | ||
})) : (this.j.disconnect(), this.$.disconnect(), clearTimeout(this.k)); | ||
}, | ||
// stickyOffset is included; | ||
this.m = t ?? 200; | ||
this.m = t.estimatedWidgetSize ?? 200, this.set(t); | ||
} | ||
on(t, s) { | ||
return s.forEach((s => this.j[s].push(t))), () => s.forEach((s => this.j[s].splice(this.j[s].indexOf(t), 1))); | ||
return s.forEach((s => this.B[s].push(t))), () => s.forEach((s => this.B[s].splice(this.B[s].indexOf(t), 1))); | ||
} | ||
p(t) { | ||
this.j[t].forEach(0 === m.t ? u : m.o); | ||
this.B[t].forEach(0 === m.t ? u : m.o); | ||
} | ||
getIndex(t) { | ||
let s = 0; | ||
t = Math.min(t, this.v); | ||
for (let i = this.q, h = 0; i > 0; i >>= 1) (h = s + i) <= this.T && t > this.R[h] && (s = h, | ||
t -= this.R[h]); | ||
t = Math.min(t, this.S); | ||
for (let i = this.A, h = 0; i > 0; i >>= 1) (h = s + i) <= this.T && t > this.q[h] && (s = h, | ||
t -= this.q[h]); | ||
return s; | ||
@@ -108,28 +108,28 @@ } | ||
let s = 0; | ||
for (;t > 0; t -= t & -t) s += this.R[t]; | ||
for (;t > 0; t -= t & -t) s += this.q[t]; | ||
return s; | ||
} | ||
getSize(t) { | ||
if ("production" !== process.env.NODE_ENV && t >= this.I.length) throw Error("itemIndex must be < itemCount in getSize"); | ||
return this.I[t]; | ||
if ("production" !== process.env.NODE_ENV && t >= this.R.length) throw Error("itemIndex must be < itemCount in getSize"); | ||
return this.R[t]; | ||
} | ||
get visibleFrom() { | ||
const t = this.getIndex(this.F); | ||
return t + (this.F - this.getOffset(t)) / this.I[t]; | ||
return t + (this.F - this.getOffset(t)) / this.R[t]; | ||
} | ||
el(t, s) { | ||
const i = this.G.get(t); | ||
i && (this.G.delete(t), this.A.delete(i), this.$.unobserve(i)), s && (this.A.set(s, t), | ||
this.G.set(t, s), this.$.observe(s)); | ||
const i = this.L.get(t); | ||
i && (this.L.delete(t), this.G.delete(i), this.j.unobserve(i)), s && (this.G.set(s, t), | ||
this.L.set(t, s), this.j.observe(s)); | ||
} | ||
N(t, s) { | ||
const i = this.L[t]; | ||
i && (this.W.unobserve(i), this.l(-this.U[t]), this.L[t] = null, this.U[t] = 0), | ||
s && this.W.observe(this.L[t] = s); | ||
P(t, s) { | ||
const i = this.U[t]; | ||
i && (this.$.unobserve(i), this.l(-this.W[t]), this.U[t] = null, this.W[t] = 0), | ||
s && this.$.observe(this.U[t] = s); | ||
} | ||
setStickyHeader(t) { | ||
this.N(0, t); | ||
this.P(0, t); | ||
} | ||
setStickyFooter(t) { | ||
this.N(1, t); | ||
this.P(1, t); | ||
} | ||
@@ -144,3 +144,3 @@ g() { | ||
} | ||
K() { | ||
N() { | ||
const t = this.getIndex(this.F); | ||
@@ -151,49 +151,45 @@ t < this.from && (this.from = Math.max(0, t - this.H), this.to = this.T && 1 + this.getIndex(this.F + this.m), | ||
scrollTo(t, s, i) { | ||
if (clearTimeout(this.C), this.O) { | ||
const h = 0 | t, e = Math.min(this.scrollSize - this.m, this.getOffset(h) + Math.round(this.I[h] * (t - h))); | ||
e !== this.F && (i ||= 5, s && 128 >= performance.now() - this.k || (this.O.scroll({ | ||
if (clearTimeout(this.k), this.O) { | ||
const h = 0 | t, e = Math.min(this.scrollSize - this.m, this.getOffset(h) + Math.round(this.R[h] * (t - h))); | ||
e !== this.F && (i ||= 5, s && 128 >= performance.now() - this.C || (this.O.scroll({ | ||
[this._]: e, | ||
behavior: s ? "smooth" : "instant" | ||
}), i--), i && (this.C = setTimeout((() => this.scrollTo(t, s, i)), s ? 512 : 32))); | ||
}), i--), i && (this.k = setTimeout((() => this.scrollTo(t, s, i)), s ? 512 : 32))); | ||
} | ||
} | ||
setHorizontal(t) { | ||
t !== this.horizontal && (this._ = (this.horizontal = t) ? "left" : "top", this.M = t ? "scrollLeft" : "scrollTop", | ||
this.S = t ? "offsetWidth" : "offsetHeight", this.O && | ||
/* TODO: Needs testing */ | ||
this.B(), this.scrollTo(0)); | ||
} | ||
setItemCount(t, s) { | ||
if (t > 2147483647) throw Error(`itemCount must be <= 2147483647. Got: ${t}.`); | ||
if (t !== this.T) { | ||
this.q = (this.T = t) && 1 << 31 - Math.clz32(t); | ||
const i = this.I, h = i.length; | ||
t > h && (this.I = new p(Math.min(t + 32, 2147483647)), this.I.set(i), this.R = | ||
set(t) { | ||
let {overscanCount: s, horizontal: i, itemCount: h, estimatedItemSize: e} = t; | ||
if (m.i(), e && ( | ||
// must not be falsy, so not checking for undefined here. | ||
this.I = e), void 0 !== s && (this.H = s), void 0 !== h && this.T !== h) { | ||
if (h > 2147483647) throw Error(`itemCount must be <= 2147483647. Got: ${h}.`); | ||
this.A = (this.T = h) && 1 << 31 - Math.clz32(h); | ||
const t = this.R, s = t.length; | ||
h > s && (this.R = new p(Math.min(h + 32, 2147483647)), this.R.set(t), this.q = | ||
/*@__NOINLINE__*/ | ||
d(this.I.fill(s || 40, h))), m.i(), this.scrollSize = (this.v = this.getOffset(t)) + this.u, | ||
this.p(1), this.to > t && ( | ||
w(this.R.fill(this.I || 40, s))), this.scrollSize = (this.S = this.getOffset(h)) + this.u, | ||
this.p(1), this.to > h && ( | ||
// Forcing shift range to end | ||
this.to = -1), this.g(), m.h(); | ||
this.to = -1), this.g(); | ||
} | ||
void 0 !== i && this.horizontal !== i && (this._ = (this.horizontal = i) ? "left" : "top", | ||
this.M = i ? "scrollLeft" : "scrollTop", this.v = i ? "offsetWidth" : "offsetHeight", | ||
this.O && | ||
/* TODO: Needs testing */ | ||
this.D(), this.scrollTo(0)), m.h(); | ||
} | ||
setOverscan(t) { | ||
this.H = t; | ||
} | ||
} | ||
const M = (t, s) => (t.setOverscan(s.overscanCount ?? 3), t.setHorizontal(!!s.horizontal), | ||
t.setItemCount(s.itemCount || 0, s.estimatedItemSize || 40), t), S = s => t().current ||= M(new _(s.estimatedWidgetSize ?? 200), s), b = i, v = t => { | ||
const s = S(t); | ||
return b((() => { | ||
m.i(), M(s, t), m.h(); | ||
})), s; | ||
}, y = (t, i, h) => s((() => { | ||
const M = s => t().current ||= new _(s), v = i, S = t => { | ||
const s = M(t); | ||
return v((() => s.set(t))), s; | ||
}, b = (t, i, h) => s((() => { | ||
if (h) return h(), t.on(h, i); | ||
}), [ h, i ]), T = (t, s) => { | ||
s ||= l; | ||
}), [ h, i ]), y = (t, s) => { | ||
s ||= c; | ||
const i = () => s.reduce(((s, i) => "_" + s + (0 === i ? t.from + "_" + t.to : 1 === i ? t.scrollSize : t.sizesHash)), ""); | ||
e(h((i => t.on(i, s)), [ s ]), i, i); | ||
}, x = t => (T(t.model, t.events), t.children()); | ||
}, T = t => (y(t.model, t.events), t.children()); | ||
export { l as EVT_ALL, r as EVT_RANGE, n as EVT_SCROLL_SIZE, c as EVT_SIZES, x as Subscription, o as mapVisibleRange, T as useComponentSubscription, y as useSubscription, v as useVirtual, S as useVirtualModel }; | ||
export { c as EVT_ALL, r as EVT_RANGE, n as EVT_SCROLL_SIZE, l as EVT_SIZES, T as Subscription, o as mapVisibleRange, y as useComponentSubscription, b as useSubscription, S as useVirtual, M as useVirtualModel }; | ||
//# sourceMappingURL=index.js.map |
@@ -10,7 +10,7 @@ import { useRef as t, useEffect as s, useLayoutEffect as i, useCallback as h } from "react"; | ||
return h; | ||
}, r = 0, n = 1, c = 2, l = [ 0, 1, 2 ], f = class { | ||
}, r = 0, n = 1, c = 2, l = [ 0, 1, 2 ], u = class { | ||
observe() {} | ||
unobserve() {} | ||
disconnect() {} | ||
}, u = t => t(), a = new Set, m = { | ||
}, a = t => t(), f = new Set, m = { | ||
t: 0, | ||
@@ -21,5 +21,5 @@ i() { | ||
h() { | ||
0 == --this.t && (a.forEach(u), a.clear()); | ||
0 == --this.t && (f.forEach(a), f.clear()); | ||
}, | ||
o: t => a.add(t) | ||
o: t => f.add(t) | ||
}, p = Uint32Array, d = new p(0), w = t => { | ||
@@ -45,16 +45,16 @@ const s = t.length + 1, i = new p(s); | ||
constructor(t) { | ||
this.horizontal = !1, this._ = "top", this.M = "scrollTop", this.v = "offsetHeight", | ||
this.S = 0, this.u = 0, this.T = 0, this.k = 0, this.C = 0, this.F = 0, this.H = 3, | ||
this.I = null, this.O = d, this.R = d, this.q = 0, this.scrollSize = 0, this.from = 0, | ||
this.to = 0, this.sizesHash = 0, this.A = new Map, this.G = new Map, this.L = [ null, null ], | ||
this.U = [ 0, 0 ], this.W = new f((t => { | ||
this.horizontal = !1, this._ = "top", this.v = "scrollTop", this.M = "offsetHeight", | ||
this.S = 0, this.u = 0, this.T = 0, this.C = 0, this.k = 0, this.F = 0, this.H = 3, | ||
this.I = 40, this.O = null, this.R = d, this.q = d, this.A = 0, this.scrollSize = 0, | ||
this.from = 0, this.to = 0, this.sizesHash = 0, this.G = new Map, this.L = new Map, | ||
this.U = [ null, null ], this.W = [ 0, 0 ], this.$ = new u((t => { | ||
let s = 0, i = 0, h = 0; | ||
for (const {target: e} of t) s = this.L.indexOf(e), -1 !== s && (i = e[this.v] - this.U[s], | ||
i && (this.U[s] += i, h += i)); | ||
for (const {target: e} of t) s = this.U.indexOf(e), -1 !== s && (i = e[this.M] - this.W[s], | ||
i && (this.W[s] += i, h += i)); | ||
this.l(h); | ||
})), this.$ = new f((t => { | ||
})), this.j = new u((t => { | ||
let s = 0, i = 0, h = 0, e = !1, o = this.from + 1; | ||
for (;o < this.to; o += o & -o) ; | ||
o = Math.min(o, this.R.length); | ||
for (const {target: r} of t) s = this.A.get(r), | ||
o = Math.min(o, this.q.length); | ||
for (const {target: r} of t) s = this.G.get(r), | ||
/* | ||
@@ -65,5 +65,5 @@ ResizeObserver may give us elements, which are not in visible range => will be unmounted soon. | ||
*/ | ||
s >= this.from && s < this.to && (i = r[this.v] - this.O[s], i && (e = !0, this.O[s] += i, | ||
h += i, g(this.R, s + 1, i, o))); | ||
e && (m.i(), 0 !== h && (g(this.R, o, h, this.R.length), this.S += h, this.scrollSize += h, | ||
s >= this.from && s < this.to && (i = r[this.M] - this.R[s], i && (e = !0, this.R[s] += i, | ||
h += i, g(this.q, s + 1, i, o))); | ||
e && (m.i(), 0 !== h && (g(this.q, o, h, this.q.length), this.S += h, this.scrollSize += h, | ||
this.p(1), 0 > h && | ||
@@ -80,22 +80,22 @@ /* | ||
*/ , this.sizesHash = this.sizesHash + 1 & 65535, this.p(2), m.h()); | ||
})), this.j = l.map((() => [])), this.B = () => { | ||
const t = this.I[this.v] - this.u; | ||
})), this.B = l.map((() => [])), this.D = () => { | ||
const t = this.O[this.M] - this.u; | ||
t !== this.m && (this.m = t, this.g()); | ||
}, this.D = new f(this.B), this.J = t => { | ||
const s = this.F, i = this.I[this.M]; | ||
i !== s && (this.F = i, this.k = t.timeStamp, i > s ? this.g() : this.K()); | ||
}, this.J = new u(this.D), this.K = t => { | ||
const s = this.F, i = this.O[this.v]; | ||
i !== s && (this.F = i, this.C = t.timeStamp, i > s ? this.g() : this.N()); | ||
}, this.setOuterNode = t => { | ||
this.I && (this.D.unobserve(this.I), this.I.removeEventListener("scroll", this.J)), | ||
(this.I = t) ? (this.D.observe(t), t.addEventListener("scroll", this.J, { | ||
this.O && (this.J.unobserve(this.O), this.O.removeEventListener("scroll", this.K)), | ||
(this.O = t) ? (this.J.observe(t), t.addEventListener("scroll", this.K, { | ||
passive: !0 | ||
})) : (this.$.disconnect(), this.W.disconnect(), clearTimeout(this.C)); | ||
})) : (this.j.disconnect(), this.$.disconnect(), clearTimeout(this.k)); | ||
}, | ||
// stickyOffset is included; | ||
this.m = t ?? 200; | ||
this.m = t.estimatedWidgetSize ?? 200, this.set(t); | ||
} | ||
on(t, s) { | ||
return s.forEach((s => this.j[s].push(t))), () => s.forEach((s => this.j[s].splice(this.j[s].indexOf(t), 1))); | ||
return s.forEach((s => this.B[s].push(t))), () => s.forEach((s => this.B[s].splice(this.B[s].indexOf(t), 1))); | ||
} | ||
p(t) { | ||
this.j[t].forEach(0 === m.t ? u : m.o); | ||
this.B[t].forEach(0 === m.t ? a : m.o); | ||
} | ||
@@ -105,4 +105,4 @@ getIndex(t) { | ||
t = Math.min(t, this.S); | ||
for (let i = this.q, h = 0; i > 0; i >>= 1) (h = s + i) <= this.T && t > this.R[h] && (s = h, | ||
t -= this.R[h]); | ||
for (let i = this.A, h = 0; i > 0; i >>= 1) (h = s + i) <= this.T && t > this.q[h] && (s = h, | ||
t -= this.q[h]); | ||
return s; | ||
@@ -113,28 +113,28 @@ } | ||
let s = 0; | ||
for (;t > 0; t -= t & -t) s += this.R[t]; | ||
for (;t > 0; t -= t & -t) s += this.q[t]; | ||
return s; | ||
} | ||
getSize(t) { | ||
if ("production" !== process.env.NODE_ENV && t >= this.O.length) throw Error("itemIndex must be < itemCount in getSize"); | ||
return this.O[t]; | ||
if ("production" !== process.env.NODE_ENV && t >= this.R.length) throw Error("itemIndex must be < itemCount in getSize"); | ||
return this.R[t]; | ||
} | ||
get visibleFrom() { | ||
const t = this.getIndex(this.F); | ||
return t + (this.F - this.getOffset(t)) / this.O[t]; | ||
return t + (this.F - this.getOffset(t)) / this.R[t]; | ||
} | ||
el(t, s) { | ||
const i = this.G.get(t); | ||
i && (this.G.delete(t), this.A.delete(i), this.$.unobserve(i)), s && (this.A.set(s, t), | ||
this.G.set(t, s), this.$.observe(s)); | ||
const i = this.L.get(t); | ||
i && (this.L.delete(t), this.G.delete(i), this.j.unobserve(i)), s && (this.G.set(s, t), | ||
this.L.set(t, s), this.j.observe(s)); | ||
} | ||
N(t, s) { | ||
const i = this.L[t]; | ||
i && (this.W.unobserve(i), this.l(-this.U[t]), this.L[t] = null, this.U[t] = 0), | ||
s && this.W.observe(this.L[t] = s); | ||
P(t, s) { | ||
const i = this.U[t]; | ||
i && (this.$.unobserve(i), this.l(-this.W[t]), this.U[t] = null, this.W[t] = 0), | ||
s && this.$.observe(this.U[t] = s); | ||
} | ||
setStickyHeader(t) { | ||
this.N(0, t); | ||
this.P(0, t); | ||
} | ||
setStickyFooter(t) { | ||
this.N(1, t); | ||
this.P(1, t); | ||
} | ||
@@ -149,3 +149,3 @@ g() { | ||
} | ||
K() { | ||
N() { | ||
const t = this.getIndex(this.F); | ||
@@ -156,48 +156,44 @@ t < this.from && (this.from = Math.max(0, t - this.H), this.to = this.T && 1 + this.getIndex(this.F + this.m), | ||
scrollTo(t, s, i) { | ||
if (clearTimeout(this.C), this.I) { | ||
const h = 0 | t, e = Math.min(this.scrollSize - this.m, this.getOffset(h) + Math.round(this.O[h] * (t - h))); | ||
e !== this.F && (i ||= 5, s && 128 >= performance.now() - this.k || (this.I.scroll({ | ||
if (clearTimeout(this.k), this.O) { | ||
const h = 0 | t, e = Math.min(this.scrollSize - this.m, this.getOffset(h) + Math.round(this.R[h] * (t - h))); | ||
e !== this.F && (i ||= 5, s && 128 >= performance.now() - this.C || (this.O.scroll({ | ||
[this._]: e, | ||
behavior: s ? "smooth" : "instant" | ||
}), i--), i && (this.C = setTimeout((() => this.scrollTo(t, s, i)), s ? 512 : 32))); | ||
}), i--), i && (this.k = setTimeout((() => this.scrollTo(t, s, i)), s ? 512 : 32))); | ||
} | ||
} | ||
setHorizontal(t) { | ||
t !== this.horizontal && (this._ = (this.horizontal = t) ? "left" : "top", this.M = t ? "scrollLeft" : "scrollTop", | ||
this.v = t ? "offsetWidth" : "offsetHeight", this.I && | ||
/* TODO: Needs testing */ | ||
this.B(), this.scrollTo(0)); | ||
} | ||
setItemCount(t, s) { | ||
if (t > 2147483647) throw Error(`itemCount must be <= 2147483647. Got: ${t}.`); | ||
if (t !== this.T) { | ||
this.q = (this.T = t) && 1 << 31 - Math.clz32(t); | ||
const i = this.O, h = i.length; | ||
t > h && (this.O = new p(Math.min(t + 32, 2147483647)), this.O.set(i), this.R = | ||
set(t) { | ||
let {overscanCount: s, horizontal: i, itemCount: h, estimatedItemSize: e} = t; | ||
if (m.i(), e && ( | ||
// must not be falsy, so not checking for undefined here. | ||
this.I = e), void 0 !== s && (this.H = s), void 0 !== h && this.T !== h) { | ||
if (h > 2147483647) throw Error(`itemCount must be <= 2147483647. Got: ${h}.`); | ||
this.A = (this.T = h) && 1 << 31 - Math.clz32(h); | ||
const t = this.R, s = t.length; | ||
h > s && (this.R = new p(Math.min(h + 32, 2147483647)), this.R.set(t), this.q = | ||
/*@__NOINLINE__*/ | ||
w(this.O.fill(s || 40, h))), m.i(), this.scrollSize = (this.S = this.getOffset(t)) + this.u, | ||
this.p(1), this.to > t && ( | ||
w(this.R.fill(this.I || 40, s))), this.scrollSize = (this.S = this.getOffset(h)) + this.u, | ||
this.p(1), this.to > h && ( | ||
// Forcing shift range to end | ||
this.to = -1), this.g(), m.h(); | ||
this.to = -1), this.g(); | ||
} | ||
void 0 !== i && this.horizontal !== i && (this._ = (this.horizontal = i) ? "left" : "top", | ||
this.v = i ? "scrollLeft" : "scrollTop", this.M = i ? "offsetWidth" : "offsetHeight", | ||
this.O && | ||
/* TODO: Needs testing */ | ||
this.D(), this.scrollTo(0)), m.h(); | ||
} | ||
setOverscan(t) { | ||
this.H = t; | ||
} | ||
} | ||
const M = (t, s) => (t.setOverscan(s.overscanCount ?? 3), t.setHorizontal(!!s.horizontal), | ||
t.setItemCount(s.itemCount || 0, s.estimatedItemSize || 40), t), b = s => t().current ||= M(new _(s.estimatedWidgetSize ?? 200), s), v = s, S = t => { | ||
const s = b(t); | ||
return v((() => { | ||
m.i(), M(s, t), m.h(); | ||
})), s; | ||
}, y = (t, i, h) => s((() => { | ||
const v = s => t().current ||= new _(s), M = s, S = t => { | ||
const s = v(t); | ||
return M((() => s.set(t))), s; | ||
}, b = (t, i, h) => s((() => { | ||
if (h) return h(), t.on(h, i); | ||
}), [ h, i ]), T = (t, s) => { | ||
}), [ h, i ]), y = (t, s) => { | ||
s ||= l; | ||
const i = () => s.reduce(((s, i) => "_" + s + (0 === i ? t.from + "_" + t.to : 1 === i ? t.scrollSize : t.sizesHash)), ""); | ||
e(h((i => t.on(i, s)), [ s ]), i, i); | ||
}, x = t => (T(t.model, t.events), t.children()); | ||
}, T = t => (y(t.model, t.events), t.children()); | ||
export { l as EVT_ALL, r as EVT_RANGE, n as EVT_SCROLL_SIZE, c as EVT_SIZES, x as Subscription, o as mapVisibleRange, T as useComponentSubscription, y as useSubscription, S as useVirtual, b as useVirtualModel }; | ||
export { l as EVT_ALL, r as EVT_RANGE, n as EVT_SCROLL_SIZE, c as EVT_SIZES, T as Subscription, o as mapVisibleRange, y as useComponentSubscription, b as useSubscription, S as useVirtual, v as useVirtualModel }; |
{ | ||
"name": "@af-utils/react-virtual-headless", | ||
"private": false, | ||
"version": "0.0.43", | ||
"version": "0.0.44", | ||
"description": "React components for rendering large scrollable data", | ||
@@ -6,0 +6,0 @@ "repository": "https://github.com/nowaalex/af-virtual-scroll.git", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
47464
370