@af-utils/virtual-react
Advanced tools
Comparing version 0.0.24 to 0.0.25
@@ -1,4 +0,4 @@ | ||
export declare const raw = 3608; | ||
export declare const raw = 3607; | ||
export declare const min = 2382; | ||
export declare const minGz = 1156; | ||
export declare const minBrotli = 1036; | ||
export declare const minGz = 1154; | ||
export declare const minBrotli = 1028; |
@@ -1,4 +0,4 @@ | ||
export const raw = 3608; | ||
export const raw = 3607; | ||
export const min = 2382; | ||
export const minGz = 1156; | ||
export const minBrotli = 1036; | ||
export const minGz = 1154; | ||
export const minBrotli = 1028; |
@@ -98,3 +98,3 @@ /** | ||
* Usually {@link Subscription} is a better alternative. | ||
* This hook might be used in {@link https://af-utils.vercel.app/virtual/examples/react/hook/grid | grid} scenario. | ||
* This hook might be used in {@link https://af-utils.com/virtual/examples/react/hook/grid | grid} scenario. | ||
*/ | ||
@@ -136,5 +136,8 @@ export declare const useComponentSubscription: (model: VirtualScroller, events: readonly VirtualScrollerEvent[] | VirtualScrollerEvent[]) => void; | ||
* @remarks | ||
* An example could be found {@link https://af-utils.vercel.app/virtual/examples/react/hook/simple | here} | ||
* An example could be found {@link https://af-utils.com/virtual/examples/react/hook/simple | here} | ||
*/ | ||
export declare const useSyncedStyles: (model: VirtualScroller) => [(outerRef: HTMLElement | null) => void, (innerRef: HTMLElement | null) => void]; | ||
export declare const useSyncedStyles: (model: VirtualScroller) => [ | ||
(outerRef: HTMLElement | null) => void, | ||
(innerRef: HTMLElement | null) => void | ||
]; | ||
@@ -141,0 +144,0 @@ /** |
import { jsxs as t, jsx as e } from "react/jsx-runtime"; | ||
import { useState as o, useLayoutEffect as r, useMemo as n, useCallback as i, useEffect as s, useRef as l } from "react"; | ||
import { useLayoutEffect as o, useEffect as r, useState as n, useMemo as i, useCallback as s, useRef as l } from "react"; | ||
@@ -17,3 +17,3 @@ import { VirtualScrollerEvent as c, VirtualScroller as a } from "@af-utils/virtual-core"; | ||
return o; | ||
}, u = { | ||
}, u = "undefined" != typeof window ? o : r, m = { | ||
position: "relative", | ||
@@ -23,9 +23,9 @@ overflow: "hidden", | ||
zIndex: -1 | ||
}, m = { | ||
...u, | ||
}, p = { | ||
...m, | ||
height: "100%" | ||
}, p = { | ||
...u, | ||
}, y = { | ||
...m, | ||
width: "100%" | ||
}, y = { | ||
}, S = { | ||
position: "absolute", | ||
@@ -36,29 +36,29 @@ contain: "strict", | ||
left: 0 | ||
}, S = { | ||
...y, | ||
}, g = { | ||
...S, | ||
display: "flex", | ||
height: "100%" | ||
}, g = { | ||
...y, | ||
}, w = { | ||
...S, | ||
display: "block", | ||
width: "100%" | ||
}, w = t => { | ||
const [e, n] = o(null), [i, s] = o(null); | ||
return r((() => { | ||
if (t && e && i) { | ||
}, x = t => { | ||
const [e, o] = n(null), [r, i] = n(null); | ||
return u((() => { | ||
if (t && e && r) { | ||
const o = () => { | ||
e.style[t.horizontal ? "width" : "height"] = t.scrollSize + "px"; | ||
}, r = () => { | ||
}, n = () => { | ||
const e = t.getOffset(t.from), o = t.getOffset(t.to); | ||
i.style.transform = `translate${t.horizontal ? "X" : "Y"}(${e}px)`, i.style[t.horizontal ? "width" : "height"] = o - e + "px"; | ||
}, n = t.on(o, [ c.SCROLL_SIZE ]), s = t.on(r, [ c.RANGE, c.SIZES ]); | ||
return Object.assign(e.style, t.horizontal ? m : p), Object.assign(i.style, t.horizontal ? S : g), | ||
o(), r(), () => { | ||
n(), s(); | ||
r.style.transform = `translate${t.horizontal ? "X" : "Y"}(${e}px)`, r.style[t.horizontal ? "width" : "height"] = o - e + "px"; | ||
}, i = t.on(o, [ c.SCROLL_SIZE ]), s = t.on(n, [ c.RANGE, c.SIZES ]); | ||
return Object.assign(e.style, t.horizontal ? p : y), Object.assign(r.style, t.horizontal ? g : w), | ||
o(), n(), () => { | ||
i(), s(); | ||
}; | ||
} | ||
}), [ t, e, i ]), [ n, s ]; | ||
}), [ t, e, r ]), [ o, i ]; | ||
}; | ||
function x(t) { | ||
function v(t) { | ||
switch (t) { | ||
@@ -76,7 +76,7 @@ case c.RANGE: | ||
const v = (t, e) => { | ||
const [o, r] = n((() => [ o => t.on(o, e), () => e.map(x, t).join() ]), [ t, e ]); | ||
const z = (t, e) => { | ||
const [o, r] = i((() => [ o => t.on(o, e), () => e.map(v, t).join() ]), [ t, e ]); | ||
h(o, r, r); | ||
}, z = t => (v(t.model, t.events), t.children()), O = o => { | ||
const {model: r, children: n, itemData: s, component: l = "div", header: a = null, footer: h = null, getKey: f = (t => t), tabIndex: u = -1, style: m, ...p} = o, [y, S] = w(r); | ||
}, O = t => (z(t.model, t.events), t.children()), b = o => { | ||
const {model: r, children: n, itemData: i, component: l = "div", header: a = null, footer: h = null, getKey: f = (t => t), tabIndex: u = -1, style: m, ...p} = o, [y, S] = x(r); | ||
return t(l, { | ||
@@ -89,3 +89,3 @@ ...p, | ||
}, | ||
ref: i((t => r.setScroller(t)), [ r ]), | ||
ref: s((t => r.setScroller(t)), [ r ]), | ||
tabIndex: u, | ||
@@ -96,3 +96,3 @@ children: [ a, e("div", { | ||
ref: S, | ||
children: e(z, { | ||
children: e(O, { | ||
model: r, | ||
@@ -103,4 +103,4 @@ events: [ c.RANGE ], | ||
i: t, | ||
data: s | ||
}, f(t, s)))) | ||
data: i | ||
}, f(t, i)))) | ||
}) | ||
@@ -110,11 +110,10 @@ }) | ||
}); | ||
}, b = "undefined" != typeof window ? r : s, E = (t, e) => b((() => (t.setScroller(e), | ||
() => t.setScroller(null))), [ t, e ]), I = (t, e, o) => s((() => { | ||
}, E = (t, e) => u((() => (t.setScroller(e), () => t.setScroller(null))), [ t, e ]), I = (t, e, o) => r((() => { | ||
if (o) return o(), t.on(o, e); | ||
}), [ t, o, e ]), j = t => l().current ||= new a(t), R = t => { | ||
const e = j(t); | ||
return b((() => e.set(t))), e; | ||
return u((() => e.set(t))), e; | ||
}; | ||
export { O as List, z as Subscription, d as mapVisibleRange, f as mapVisibleRangeWithOffset, v as useComponentSubscription, E as useScroller, I as useSubscription, w as useSyncedStyles, R as useVirtual, j as useVirtualModel }; | ||
export { b as List, O as Subscription, d as mapVisibleRange, f as mapVisibleRangeWithOffset, z as useComponentSubscription, E as useScroller, I as useSubscription, x as useSyncedStyles, R as useVirtual, j as useVirtualModel }; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@af-utils/virtual-react", | ||
"private": false, | ||
"version": "0.0.24", | ||
"version": "0.0.25", | ||
"description": "React components and hooks for rendering large scrollable data", | ||
@@ -11,3 +11,3 @@ "repository": { | ||
}, | ||
"homepage": "https://af-utils.vercel.app/virtual", | ||
"homepage": "https://af-utils.com/virtual", | ||
"bugs": "https://github.com/nowaalex/af-utils/issues", | ||
@@ -42,3 +42,3 @@ "author": "Alex Fomin <nowaalex@gmail.com> (https://github.com/nowaalex/)", | ||
"@rollup/plugin-typescript": "^11.1.6", | ||
"rollup": "^4.13.0", | ||
"rollup": "^4.14.0", | ||
"ts-jest": "^29.1.2", | ||
@@ -45,0 +45,0 @@ "@af-utils/rollup-plugin-export-bundle-size": "0.0.5" |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
28303
265