This commit is contained in:
4
node_modules/@tanstack/react-virtual/dist/esm/index.d.ts
generated
vendored
Normal file
4
node_modules/@tanstack/react-virtual/dist/esm/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
import { Virtualizer, PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core';
|
||||
export * from '@tanstack/virtual-core';
|
||||
export declare function useVirtualizer<TScrollElement extends Element, TItemElement extends Element>(options: PartialKeys<VirtualizerOptions<TScrollElement, TItemElement>, 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'>): Virtualizer<TScrollElement, TItemElement>;
|
||||
export declare function useWindowVirtualizer<TItemElement extends Element>(options: PartialKeys<VirtualizerOptions<Window, TItemElement>, 'getScrollElement' | 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'>): Virtualizer<Window, TItemElement>;
|
||||
54
node_modules/@tanstack/react-virtual/dist/esm/index.js
generated
vendored
Normal file
54
node_modules/@tanstack/react-virtual/dist/esm/index.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
import * as React from "react";
|
||||
import { flushSync } from "react-dom";
|
||||
import { Virtualizer, elementScroll, observeElementOffset, observeElementRect, windowScroll, observeWindowOffset, observeWindowRect } from "@tanstack/virtual-core";
|
||||
export * from "@tanstack/virtual-core";
|
||||
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
||||
function useVirtualizerBase(options) {
|
||||
const rerender = React.useReducer(() => ({}), {})[1];
|
||||
const resolvedOptions = {
|
||||
...options,
|
||||
onChange: (instance2, sync) => {
|
||||
var _a;
|
||||
if (sync) {
|
||||
flushSync(rerender);
|
||||
} else {
|
||||
rerender();
|
||||
}
|
||||
(_a = options.onChange) == null ? void 0 : _a.call(options, instance2, sync);
|
||||
}
|
||||
};
|
||||
const [instance] = React.useState(
|
||||
() => new Virtualizer(resolvedOptions)
|
||||
);
|
||||
instance.setOptions(resolvedOptions);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
return instance._didMount();
|
||||
}, []);
|
||||
useIsomorphicLayoutEffect(() => {
|
||||
return instance._willUpdate();
|
||||
});
|
||||
return instance;
|
||||
}
|
||||
function useVirtualizer(options) {
|
||||
return useVirtualizerBase({
|
||||
observeElementRect,
|
||||
observeElementOffset,
|
||||
scrollToFn: elementScroll,
|
||||
...options
|
||||
});
|
||||
}
|
||||
function useWindowVirtualizer(options) {
|
||||
return useVirtualizerBase({
|
||||
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
||||
observeElementRect: observeWindowRect,
|
||||
observeElementOffset: observeWindowOffset,
|
||||
scrollToFn: windowScroll,
|
||||
initialOffset: () => typeof document !== "undefined" ? window.scrollY : 0,
|
||||
...options
|
||||
});
|
||||
}
|
||||
export {
|
||||
useVirtualizer,
|
||||
useWindowVirtualizer
|
||||
};
|
||||
//# sourceMappingURL=index.js.map
|
||||
1
node_modules/@tanstack/react-virtual/dist/esm/index.js.map
generated
vendored
Normal file
1
node_modules/@tanstack/react-virtual/dist/esm/index.js.map
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n Virtualizer,\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n windowScroll,\n} from '@tanstack/virtual-core'\nimport type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'\n\nexport * from '@tanstack/virtual-core'\n\nconst useIsomorphicLayoutEffect =\n typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Virtualizer<TScrollElement, TItemElement> {\n const rerender = React.useReducer(() => ({}), {})[1]\n\n const resolvedOptions: VirtualizerOptions<TScrollElement, TItemElement> = {\n ...options,\n onChange: (instance, sync) => {\n if (sync) {\n flushSync(rerender)\n } else {\n rerender()\n }\n options.onChange?.(instance, sync)\n },\n }\n\n const [instance] = React.useState(\n () => new Virtualizer<TScrollElement, TItemElement>(resolvedOptions),\n )\n\n instance.setOptions(resolvedOptions)\n\n useIsomorphicLayoutEffect(() => {\n return instance._didMount()\n }, [])\n\n useIsomorphicLayoutEffect(() => {\n return instance._willUpdate()\n })\n\n return instance\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Virtualizer<TScrollElement, TItemElement> {\n return useVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Virtualizer<Window, TItemElement> {\n return useVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof document !== 'undefined' ? window : null),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n initialOffset: () => (typeof document !== 'undefined' ? window.scrollY : 0),\n ...options,\n })\n}\n"],"names":["instance"],"mappings":";;;;AAeA,MAAM,4BACJ,OAAO,aAAa,cAAc,MAAM,kBAAkB,MAAM;AAElE,SAAS,mBAIP,SAC2C;AACrC,QAAA,WAAW,MAAM,WAAW,OAAO,CAAA,IAAK,CAAA,CAAE,EAAE,CAAC;AAEnD,QAAM,kBAAoE;AAAA,IACxE,GAAG;AAAA,IACH,UAAU,CAACA,WAAU,SAAS;;AAC5B,UAAI,MAAM;AACR,kBAAU,QAAQ;AAAA,MAAA,OACb;AACI,iBAAA;AAAA,MAAA;AAEH,oBAAA,aAAA,iCAAWA,WAAU;AAAA,IAAI;AAAA,EAErC;AAEM,QAAA,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MAAM,IAAI,YAA0C,eAAe;AAAA,EACrE;AAEA,WAAS,WAAW,eAAe;AAEnC,4BAA0B,MAAM;AAC9B,WAAO,SAAS,UAAU;AAAA,EAC5B,GAAG,EAAE;AAEL,4BAA0B,MAAM;AAC9B,WAAO,SAAS,YAAY;AAAA,EAAA,CAC7B;AAEM,SAAA;AACT;AAEO,SAAS,eAId,SAI2C;AAC3C,SAAO,mBAAiD;AAAA,IACtD;AAAA,IACA;AAAA,IACA,YAAY;AAAA,IACZ,GAAG;AAAA,EAAA,CACJ;AACH;AAEO,SAAS,qBACd,SAOmC;AACnC,SAAO,mBAAyC;AAAA,IAC9C,kBAAkB,MAAO,OAAO,aAAa,cAAc,SAAS;AAAA,IACpE,oBAAoB;AAAA,IACpB,sBAAsB;AAAA,IACtB,YAAY;AAAA,IACZ,eAAe,MAAO,OAAO,aAAa,cAAc,OAAO,UAAU;AAAA,IACzE,GAAG;AAAA,EAAA,CACJ;AACH;"}
|
||||
Reference in New Issue
Block a user