@tanstack/virtual-core
Advanced tools
Comparing version 3.7.0 to 3.8.0
@@ -68,7 +68,7 @@ export * from './utils.js'; | ||
getItemKey?: (index: number) => Key; | ||
rangeExtractor?: (range: Range) => number[]; | ||
rangeExtractor?: (range: Range) => Array<number>; | ||
scrollMargin?: number; | ||
gap?: number; | ||
indexAttribute?: string; | ||
initialMeasurementsCache?: VirtualItem<TItemElement>[]; | ||
initialMeasurementsCache?: Array<VirtualItem<TItemElement>>; | ||
lanes?: number; | ||
@@ -85,3 +85,3 @@ isScrollingResetDelay?: number; | ||
private scrollToIndexTimeoutId; | ||
measurementsCache: VirtualItem<TItemElement>[]; | ||
measurementsCache: Array<VirtualItem<TItemElement>>; | ||
private itemSizeCache; | ||
@@ -88,0 +88,0 @@ private pendingMeasuredCacheIndexes; |
@@ -212,4 +212,3 @@ import { debounce, memo, notUndefined, approxEqual } from "./utils.js"; | ||
Object.entries(opts2).forEach(([key, value]) => { | ||
if (typeof value === "undefined") | ||
delete opts2[key]; | ||
if (typeof value === "undefined") delete opts2[key]; | ||
}); | ||
@@ -635,4 +634,3 @@ this.options = { | ||
const offsetAndAlign = this.getOffsetForIndex(index, initialAlign); | ||
if (!offsetAndAlign) | ||
return; | ||
if (!offsetAndAlign) return; | ||
const [offset, align] = offsetAndAlign; | ||
@@ -639,0 +637,0 @@ this._scrollToOffset(offset, { adjustments: void 0, behavior }); |
export type NoInfer<A extends any> = [A][A extends any ? 0 : never]; | ||
export type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>; | ||
export declare function memo<TDeps extends readonly any[], TResult>(getDeps: () => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts: { | ||
export declare function memo<TDeps extends ReadonlyArray<any>, TResult>(getDeps: () => [...TDeps], fn: (...args: NoInfer<[...TDeps]>) => TResult, opts: { | ||
key: false | string; | ||
@@ -11,2 +11,2 @@ debug?: () => any; | ||
export declare const approxEqual: (a: number, b: number) => boolean; | ||
export declare const debounce: (targetWindow: Window & typeof globalThis, fn: Function, ms: number) => (this: any, ...args: any[]) => void; | ||
export declare const debounce: (targetWindow: Window & typeof globalThis, fn: Function, ms: number) => (this: any, ...args: Array<any>) => void; |
@@ -7,4 +7,3 @@ function memo(getDeps, fn, opts) { | ||
let depTime; | ||
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) | ||
depTime = Date.now(); | ||
if (opts.key && ((_a = opts.debug) == null ? void 0 : _a.call(opts))) depTime = Date.now(); | ||
const newDeps = getDeps(); | ||
@@ -17,4 +16,3 @@ const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep); | ||
let resultTime; | ||
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) | ||
resultTime = Date.now(); | ||
if (opts.key && ((_b = opts.debug) == null ? void 0 : _b.call(opts))) resultTime = Date.now(); | ||
result = fn(...newDeps); | ||
@@ -21,0 +19,0 @@ if (opts.key && ((_c = opts.debug) == null ? void 0 : _c.call(opts))) { |
{ | ||
"name": "@tanstack/virtual-core", | ||
"version": "3.7.0", | ||
"version": "3.8.0", | ||
"description": "Headless UI for virtualizing scrollable elements in TS/JS + Frameworks", | ||
@@ -46,10 +46,3 @@ "author": "Tanner Linsley", | ||
], | ||
"scripts": { | ||
"clean": "rimraf ./dist && rimraf ./coverage", | ||
"test:types": "tsc", | ||
"test:lib": "vitest", | ||
"test:lib:dev": "pnpm run test:lib --watch", | ||
"test:build": "publint --strict", | ||
"build": "vite build" | ||
} | ||
"scripts": {} | ||
} |
@@ -1,2 +0,2 @@ | ||
import { approxEqual, memo, notUndefined, debounce } from './utils' | ||
import { approxEqual, debounce, memo, notUndefined } from './utils' | ||
@@ -315,7 +315,7 @@ export * from './utils' | ||
getItemKey?: (index: number) => Key | ||
rangeExtractor?: (range: Range) => number[] | ||
rangeExtractor?: (range: Range) => Array<number> | ||
scrollMargin?: number | ||
gap?: number | ||
indexAttribute?: string | ||
initialMeasurementsCache?: VirtualItem<TItemElement>[] | ||
initialMeasurementsCache?: Array<VirtualItem<TItemElement>> | ||
lanes?: number | ||
@@ -330,15 +330,15 @@ isScrollingResetDelay?: number | ||
> { | ||
private unsubs: (void | (() => void))[] = [] | ||
private unsubs: Array<void | (() => void)> = [] | ||
options!: Required<VirtualizerOptions<TScrollElement, TItemElement>> | ||
scrollElement: TScrollElement | null = null | ||
targetWindow: (Window & typeof globalThis) | null = null | ||
isScrolling: boolean = false | ||
isScrolling = false | ||
private scrollToIndexTimeoutId: number | null = null | ||
measurementsCache: VirtualItem<TItemElement>[] = [] | ||
measurementsCache: Array<VirtualItem<TItemElement>> = [] | ||
private itemSizeCache = new Map<Key, number>() | ||
private pendingMeasuredCacheIndexes: number[] = [] | ||
private pendingMeasuredCacheIndexes: Array<number> = [] | ||
scrollRect: Rect | null = null | ||
scrollOffset: number | null = null | ||
scrollDirection: ScrollDirection | null = null | ||
private scrollAdjustments: number = 0 | ||
private scrollAdjustments = 0 | ||
shouldAdjustScrollPositionOnItemSizeChange: | ||
@@ -524,3 +524,3 @@ | undefined | ||
private getFurthestMeasurement = ( | ||
measurements: VirtualItem<TItemElement>[], | ||
measurements: Array<VirtualItem<TItemElement>>, | ||
index: number, | ||
@@ -819,3 +819,3 @@ ) => { | ||
(indexes, measurements) => { | ||
const virtualItems: VirtualItem<TItemElement>[] = [] | ||
const virtualItems: Array<VirtualItem<TItemElement>> = [] | ||
@@ -1075,3 +1075,3 @@ for (let k = 0, len = indexes.length; k < len; k++) { | ||
}: { | ||
measurements: VirtualItem<TItemElement>[] | ||
measurements: Array<VirtualItem<TItemElement>> | ||
outerSize: number | ||
@@ -1078,0 +1078,0 @@ scrollOffset: number |
@@ -5,3 +5,3 @@ export type NoInfer<A extends any> = [A][A extends any ? 0 : never] | ||
export function memo<TDeps extends readonly any[], TResult>( | ||
export function memo<TDeps extends ReadonlyArray<any>, TResult>( | ||
getDeps: () => [...TDeps], | ||
@@ -68,3 +68,3 @@ fn: (...args: NoInfer<[...TDeps]>) => TResult, | ||
return result! | ||
return result | ||
} | ||
@@ -89,3 +89,3 @@ } | ||
let timeoutId: number | ||
return function (this: any, ...args: any[]) { | ||
return function (this: any, ...args: Array<any>) { | ||
targetWindow.clearTimeout(timeoutId) | ||
@@ -92,0 +92,0 @@ timeoutId = targetWindow.setTimeout(() => fn.apply(this, args), ms) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
198355
2752