Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@af-utils/react-virtual-headless

Package Overview
Dependencies
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@af-utils/react-virtual-headless - npm Package Compare versions

Comparing version 0.0.31 to 0.0.32

8

lib/bundlesize.index.js

@@ -1,4 +0,4 @@

export const raw = 8050;
export const min = 4670;
export const minGz = 2078;
export const minBrotli = 1880;
export const raw = 7783;
export const min = 4559;
export const minGz = 2051;
export const minBrotli = 1861;

@@ -10,4 +10,4 @@ import { useRef as t, useEffect as s, useLayoutEffect as i, useCallback as h } from "react";

return h;
}, r = (t, s) => t.length ? Math.round(s / t.length) : 40, n = 3, c = 200, l = 0, a = 1, f = 2, u = 3, m = [ 0, 1, 2, 3 ], p = Uint32Array, d = ResizeObserver, w = t => {
const s = t.length + 1, i = new p(s);
}, r = (t, s) => t.length ? Math.round(s / t.length) : 40, n = 3, c = 200, l = 0, a = 1, u = 2, f = [ 0, 1, 2 ], m = Uint32Array, d = ResizeObserver, p = t => {
const s = t.length + 1, i = new m(s);
i.set(t, 1);

@@ -18,3 +18,3 @@ for (let t, h = 1; s > h; h++) t = h + (h & -h), s > t && (i[t] += i[h]);

for (;h > s; s += s & -s) t[s] += i;
};
}, w = t => t();

@@ -25,9 +25,9 @@ class z {

this.l = new d((() => this.setWidgetSize(this.u[this.o]))), this.m = 0, this.p = 0,
this.g = 0, this.M = 0, this.S = n, this.u = null, this.v = c, this.C = new p(0),
this._ = new p(0), this.T = 0, this.scrollSize = 0, this.from = 0, this.to = 0,
this.g = 0, this.M = 0, this.S = n, this.u = null, this.v = c, this._ = new m(0),
this.C = new m(0), this.T = 0, this.scrollSize = 0, this.from = 0, this.to = 0,
this.sizesHash = 0, this.H = new Map, this.I = new Map, this.F = new d((t => {
let s = this.from, i = 0, h = 0, e = !1, o = s + 1;
for (;o < this.to; o += o & -o) ;
for (const {target: r} of t) s = this.H.get(r), i = r[this.o] - this.C[s], i && (e = !0,
this.C[s] += i, h += i, g(this._, s + 1, i, o));
for (const {target: r} of t) s = this.H.get(r), i = r[this.o] - this._[s], i && (e = !0,
this._[s] += i, h += i, g(this.C, s + 1, i, o));
e && (

@@ -41,3 +41,3 @@ /*@__INLINE__*/

*/
this.sizesHash = this.sizesHash + 1 & 1073741823, this.R(3), 0 !== h && (g(this._, o, h, this._.length),
this.sizesHash = this.sizesHash + 1 & 1073741823, this.R(2), 0 !== h && (g(this.C, o, h, this.C.length),
this.W(this.scrollSize + h), 0 > h &&

@@ -49,8 +49,9 @@ /*

this.B()), this.A());
})), this.G = m.map((() => [])), this.L = new Set, this.O = 0, this.U = t => {
})), this.G = f.map((() => [])), this.L = new Set, this.O = 0, this.U = t => this.L.add(t),
this.$ = t => {
const s = this.M, i = this.u[this.h];
i !== s && (this.M = i, this.p = t.timeStamp, i > s ? this.B() : this.$());
i !== s && (this.M = i, this.p = t.timeStamp, i > s ? this.B() : this.j());
}, this.setOuterNode = t => {
this.u && (this.l.unobserve(this.u), this.u.removeEventListener("scroll", this.U)),
(this.u = t) ? (this.l.observe(t), t.addEventListener("scroll", this.U, {
this.u && (this.l.unobserve(this.u), this.u.removeEventListener("scroll", this.$)),
(this.u = t) ? (this.l.observe(t), t.addEventListener("scroll", this.$, {
passive: !0

@@ -64,17 +65,13 @@ })) : (this.F.disconnect(), clearTimeout(this.g));

R(t) {
if ("production" !== process.env.NODE_ENV && 0 === this.O) throw Error("Can't run actions while not in batch");
for (const s of this.G[t]) this.L.add(s);
this.G[t].forEach(0 === this.O ? w : this.U);
}
/* inspired by mobx */ j() {
/* inspired by mobx */ k() {
this.O++;
}
A() {
if (!--this.O) {
for (const t of this.L)
/*
These callbacks must not call _startBatch from inside.
*/
t();
this.L.clear();
}
0 == --this.O && (
/*
calls must not call _startBatch from inside.
*/
this.L.forEach(w), this.L.clear());
}

@@ -87,4 +84,4 @@ setWidgetSize(t) {

t = Math.min(t, this.scrollSize);
for (let i = this.T, h = 0; i > 0; i >>= 1) (h = s + i) <= this.m && t > this._[h] && (s = h,
t -= this._[h]);
for (let i = this.T, h = 0; i > 0; i >>= 1) (h = s + i) <= this.m && t > this.C[h] && (s = h,
t -= this.C[h]);
return s;

@@ -95,12 +92,12 @@ }

let s = 0;
for (;t > 0; t -= t & -t) s += this._[t];
for (;t > 0; t -= t & -t) s += this.C[t];
return s;
}
getSize(t) {
if ("production" !== process.env.NODE_ENV && t >= this.C.length) throw Error("itemIndex must be < itemCount in getSize");
return this.C[t];
if ("production" !== process.env.NODE_ENV && t >= this._.length) throw Error("itemIndex must be < itemCount in getSize");
return this._[t];
}
get visibleFrom() {
const t = this.getIndex(this.M);
return t + (this.M - this.getOffset(t)) / this.C[t];
return t + (this.M - this.getOffset(t)) / this._[t];
}

@@ -119,19 +116,13 @@ el(t, s) {

const t = 1 + this.getIndex(this.M + this.v);
if (t > this.to) {
this.O++, this.to = Math.min(this.m, t + this.S), this.R(1);
const s = this.getIndex(this.M);
s !== this.from && (this.from = s, this.R(0)), this.A();
}
t > this.to && (this.to = Math.min(this.m, t + this.S), this.from = this.getIndex(this.M),
this.R(0));
}
$() {
j() {
const t = this.getIndex(this.M);
if (t < this.from) {
this.O++, this.from = Math.max(0, t - this.S), this.R(0);
const s = this.m && 1 + this.getIndex(this.M + this.v);
s !== this.to && (this.to = s, this.R(1)), this.A();
}
t < this.from && (this.from = Math.max(0, t - this.S), this.to = this.m && 1 + this.getIndex(this.M + this.v),
this.R(0));
}
scrollTo(t, s, i) {
if (clearTimeout(this.g), this.u) {
const h = 0 | t, e = Math.min(this.scrollSize - this.v, this.getOffset(h) + Math.round(this.C[h] * (t - h)));
const h = 0 | t, e = Math.min(this.scrollSize - this.v, this.getOffset(h) + Math.round(this._[h] * (t - h)));
e !== this.M && (i ||= 5, s && 128 >= performance.now() - this.p || (this.u.scroll({

@@ -144,3 +135,3 @@ [this.t]: e,

W(t) {
this.scrollSize !== t && (this.scrollSize = t, this.R(2));
this.scrollSize !== t && (this.scrollSize = t, this.R(1));
}

@@ -157,6 +148,6 @@ setHorizontal(t) {

this.T = (this.m = t) && 1 << 31 - Math.clz32(t);
const i = this.C, h = i.length;
t > h && (this.C = new p(Math.min(t + 32, 2147483647)), this.C.set(i), this._ =
const i = this._, h = i.length;
t > h && (this._ = new m(Math.min(t + 32, 2147483647)), this._.set(i), this.C =
/*@__NOINLINE__*/
w(this.C.fill(s(i, this.scrollSize, t), h)))
p(this._.fill(s(i, this.scrollSize, t), h)))
/*@__INLINE__*/ , this.O++, this.W(this.getOffset(t)), this.to > t && (

@@ -182,21 +173,25 @@ // Forcing shift range to end

}));
}, v = i, b = t => {
}, v = i, _ = t => {
const s = S(t);
return v((() => {
s.j(), s.setOverscan(t.overscanCount ?? n), s.setHorizontal(!!t.horizontal), s.setItemCount(t.itemCount, t.getEstimatedItemSize),
s.k(), s.setOverscan(t.overscanCount ?? n), s.setHorizontal(!!t.horizontal), s.setItemCount(t.itemCount, t.getEstimatedItemSize),
s.A();
})), s;
}, C = (t, i, h) => s((() => {
}, b = (t, i, h) => s((() => {
if (h) return h(), t.on(h, i);
}), [ h, i ])
/* TODO: dirty; based on evt constants. Maybe macro to evaluate build-time? */ , _ = [ "from", "to", "scrollSize", "sizesHash" ], E = (t, s) => {
s ||= m;
const i = () => s.reduce(((s, i) => s + t[_[i]] + "_"), "");
/*
TODO: dirty; based on evt constants. Maybe macro to evaluate build-time?
only 'to' is safe to use for EVT_RANGE, because from is never changed without 'to'
*/ , C = [ "to", "scrollSize", "sizesHash" ], T = (t, s) => {
s ||= f;
const i = () => s.reduce(((s, i) => s + t[C[i]] + "_"), "");
e(h((i => t.on(i, s)), [ s ]), i, i);
}, T = t => {
}, x = t => {
let {model: s, children: i, events: h} = t;
return E(s, h), i();
return T(s, h), i();
};
export { m as EVT_ALL, l as EVT_FROM, f as EVT_SCROLL_SIZE, u as EVT_SIZES, a as EVT_TO, T as Subscription, o as mapVisibleRange, E as useComponentSubscription, M as useOnce, C as useSubscription, b as useVirtual, S as useVirtualModel };
export { f as EVT_ALL, l as EVT_RANGE, a as EVT_SCROLL_SIZE, u as EVT_SIZES, x as Subscription, o as mapVisibleRange, T as useComponentSubscription, M as useOnce, b as useSubscription, _ as useVirtual, S as useVirtualModel };
//# sourceMappingURL=index.js.map

@@ -10,8 +10,8 @@ import { useRef as t, useEffect as s, useLayoutEffect as i, useCallback as h } from "react";

return h;
}, r = (t, s) => t.length ? Math.round(s / t.length) : 40, n = 3, c = 200, l = 0, a = 1, f = 2, u = 3, m = [ 0, 1, 2, 3 ], d = Uint32Array, p = class {
}, r = (t, s) => t.length ? Math.round(s / t.length) : 40, n = 3, c = 200, l = 0, a = 1, u = 2, f = [ 0, 1, 2 ], m = Uint32Array, d = class {
observe() {}
unobserve() {}
disconnect() {}
}, w = t => {
const s = t.length + 1, i = new d(s);
}, p = t => {
const s = t.length + 1, i = new m(s);
i.set(t, 1);

@@ -22,3 +22,3 @@ for (let t, h = 1; s > h; h++) t = h + (h & -h), s > t && (i[t] += i[h]);

for (;h > s; s += s & -s) t[s] += i;
};
}, w = t => t();

@@ -28,10 +28,10 @@ class z {

this.horizontal = !1, this.t = "top", this.h = "scrollTop", this.o = "offsetHeight",
this.l = new p((() => this.setWidgetSize(this.u[this.o]))), this.m = 0, this.p = 0,
this.g = 0, this.M = 0, this.S = n, this.u = null, this.v = c, this.C = new d(0),
this._ = new d(0), this.T = 0, this.scrollSize = 0, this.from = 0, this.to = 0,
this.sizesHash = 0, this.H = new Map, this.I = new Map, this.F = new p((t => {
this.l = new d((() => this.setWidgetSize(this.u[this.o]))), this.m = 0, this.p = 0,
this.g = 0, this.M = 0, this.S = n, this.u = null, this.v = c, this._ = new m(0),
this.C = new m(0), this.T = 0, this.scrollSize = 0, this.from = 0, this.to = 0,
this.sizesHash = 0, this.H = new Map, this.I = new Map, this.F = new d((t => {
let s = this.from, i = 0, h = 0, e = !1, o = s + 1;
for (;o < this.to; o += o & -o) ;
for (const {target: r} of t) s = this.H.get(r), i = r[this.o] - this.C[s], i && (e = !0,
this.C[s] += i, h += i, g(this._, s + 1, i, o));
for (const {target: r} of t) s = this.H.get(r), i = r[this.o] - this._[s], i && (e = !0,
this._[s] += i, h += i, g(this.C, s + 1, i, o));
e && (

@@ -45,3 +45,3 @@ /*@__INLINE__*/

*/
this.sizesHash = this.sizesHash + 1 & 1073741823, this.B(3), 0 !== h && (g(this._, o, h, this._.length),
this.sizesHash = this.sizesHash + 1 & 1073741823, this.B(2), 0 !== h && (g(this.C, o, h, this.C.length),
this.O(this.scrollSize + h), 0 > h &&

@@ -53,8 +53,9 @@ /*

this.R()), this.A());
})), this.G = m.map((() => [])), this.L = new Set, this.W = 0, this.U = t => {
})), this.G = f.map((() => [])), this.L = new Set, this.W = 0, this.U = t => this.L.add(t),
this.$ = t => {
const s = this.M, i = this.u[this.h];
i !== s && (this.M = i, this.p = t.timeStamp, i > s ? this.R() : this.$());
i !== s && (this.M = i, this.p = t.timeStamp, i > s ? this.R() : this.j());
}, this.setOuterNode = t => {
this.u && (this.l.unobserve(this.u), this.u.removeEventListener("scroll", this.U)),
(this.u = t) ? (this.l.observe(t), t.addEventListener("scroll", this.U, {
this.u && (this.l.unobserve(this.u), this.u.removeEventListener("scroll", this.$)),
(this.u = t) ? (this.l.observe(t), t.addEventListener("scroll", this.$, {
passive: !0

@@ -68,17 +69,13 @@ })) : (this.F.disconnect(), clearTimeout(this.g));

B(t) {
if ("production" !== process.env.NODE_ENV && 0 === this.W) throw Error("Can't run actions while not in batch");
for (const s of this.G[t]) this.L.add(s);
this.G[t].forEach(0 === this.W ? w : this.U);
}
/* inspired by mobx */ j() {
/* inspired by mobx */ k() {
this.W++;
}
A() {
if (!--this.W) {
for (const t of this.L)
/*
These callbacks must not call _startBatch from inside.
*/
t();
this.L.clear();
}
0 == --this.W && (
/*
calls must not call _startBatch from inside.
*/
this.L.forEach(w), this.L.clear());
}

@@ -91,4 +88,4 @@ setWidgetSize(t) {

t = Math.min(t, this.scrollSize);
for (let i = this.T, h = 0; i > 0; i >>= 1) (h = s + i) <= this.m && t > this._[h] && (s = h,
t -= this._[h]);
for (let i = this.T, h = 0; i > 0; i >>= 1) (h = s + i) <= this.m && t > this.C[h] && (s = h,
t -= this.C[h]);
return s;

@@ -99,12 +96,12 @@ }

let s = 0;
for (;t > 0; t -= t & -t) s += this._[t];
for (;t > 0; t -= t & -t) s += this.C[t];
return s;
}
getSize(t) {
if ("production" !== process.env.NODE_ENV && t >= this.C.length) throw Error("itemIndex must be < itemCount in getSize");
return this.C[t];
if ("production" !== process.env.NODE_ENV && t >= this._.length) throw Error("itemIndex must be < itemCount in getSize");
return this._[t];
}
get visibleFrom() {
const t = this.getIndex(this.M);
return t + (this.M - this.getOffset(t)) / this.C[t];
return t + (this.M - this.getOffset(t)) / this._[t];
}

@@ -123,19 +120,13 @@ el(t, s) {

const t = 1 + this.getIndex(this.M + this.v);
if (t > this.to) {
this.W++, this.to = Math.min(this.m, t + this.S), this.B(1);
const s = this.getIndex(this.M);
s !== this.from && (this.from = s, this.B(0)), this.A();
}
t > this.to && (this.to = Math.min(this.m, t + this.S), this.from = this.getIndex(this.M),
this.B(0));
}
$() {
j() {
const t = this.getIndex(this.M);
if (t < this.from) {
this.W++, this.from = Math.max(0, t - this.S), this.B(0);
const s = this.m && 1 + this.getIndex(this.M + this.v);
s !== this.to && (this.to = s, this.B(1)), this.A();
}
t < this.from && (this.from = Math.max(0, t - this.S), this.to = this.m && 1 + this.getIndex(this.M + this.v),
this.B(0));
}
scrollTo(t, s, i) {
if (clearTimeout(this.g), this.u) {
const h = 0 | t, e = Math.min(this.scrollSize - this.v, this.getOffset(h) + Math.round(this.C[h] * (t - h)));
const h = 0 | t, e = Math.min(this.scrollSize - this.v, this.getOffset(h) + Math.round(this._[h] * (t - h)));
e !== this.M && (i ||= 5, s && 128 >= performance.now() - this.p || (this.u.scroll({

@@ -148,3 +139,3 @@ [this.t]: e,

O(t) {
this.scrollSize !== t && (this.scrollSize = t, this.B(2));
this.scrollSize !== t && (this.scrollSize = t, this.B(1));
}

@@ -161,6 +152,6 @@ setHorizontal(t) {

this.T = (this.m = t) && 1 << 31 - Math.clz32(t);
const i = this.C, h = i.length;
t > h && (this.C = new d(Math.min(t + 32, 2147483647)), this.C.set(i), this._ =
const i = this._, h = i.length;
t > h && (this._ = new m(Math.min(t + 32, 2147483647)), this._.set(i), this.C =
/*@__NOINLINE__*/
w(this.C.fill(s(i, this.scrollSize, t), h)))
p(this._.fill(s(i, this.scrollSize, t), h)))
/*@__INLINE__*/ , this.W++, this.O(this.getOffset(t)), this.to > t && (

@@ -189,17 +180,21 @@ // Forcing shift range to end

return v((() => {
s.j(), s.setOverscan(t.overscanCount ?? n), s.setHorizontal(!!t.horizontal), s.setItemCount(t.itemCount, t.getEstimatedItemSize),
s.k(), s.setOverscan(t.overscanCount ?? n), s.setHorizontal(!!t.horizontal), s.setItemCount(t.itemCount, t.getEstimatedItemSize),
s.A();
})), s;
}, C = (t, i, h) => s((() => {
}, _ = (t, i, h) => s((() => {
if (h) return h(), t.on(h, i);
}), [ h, i ])
/* TODO: dirty; based on evt constants. Maybe macro to evaluate build-time? */ , _ = [ "from", "to", "scrollSize", "sizesHash" ], E = (t, s) => {
s ||= m;
const i = () => s.reduce(((s, i) => s + t[_[i]] + "_"), "");
/*
TODO: dirty; based on evt constants. Maybe macro to evaluate build-time?
only 'to' is safe to use for EVT_RANGE, because from is never changed without 'to'
*/ , C = [ "to", "scrollSize", "sizesHash" ], T = (t, s) => {
s ||= f;
const i = () => s.reduce(((s, i) => s + t[C[i]] + "_"), "");
e(h((i => t.on(i, s)), [ s ]), i, i);
}, T = t => {
}, x = t => {
let {model: s, children: i, events: h} = t;
return E(s, h), i();
return T(s, h), i();
};
export { m as EVT_ALL, l as EVT_FROM, f as EVT_SCROLL_SIZE, u as EVT_SIZES, a as EVT_TO, T as Subscription, o as mapVisibleRange, E as useComponentSubscription, M as useOnce, C as useSubscription, b as useVirtual, S as useVirtualModel };
export { f as EVT_ALL, l as EVT_RANGE, a as EVT_SCROLL_SIZE, u as EVT_SIZES, x as Subscription, o as mapVisibleRange, T as useComponentSubscription, M as useOnce, _ as useSubscription, b as useVirtual, S as useVirtualModel };
{
"name": "@af-utils/react-virtual-headless",
"private": false,
"version": "0.0.31",
"version": "0.0.32",
"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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc