@tanstack/react-virtual 3.0.3 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +77 -0
- package/{build/lib/index.mjs.map → dist/cjs/index.cjs.map} +1 -1
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +54 -0
- package/{build/lib → dist/esm}/index.js.map +1 -1
- package/package.json +36 -25
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +0 -27
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +0 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +0 -31
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +0 -27
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +0 -1
- package/build/lib/index.esm.js +0 -67
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -97
- package/build/lib/index.mjs +0 -67
- package/build/umd/index.development.js +0 -838
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -42
- package/build/umd/index.production.js.map +0 -1
- /package/{build/lib/index.d.ts → dist/cjs/index.d.cts} +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const React = require("react");
|
|
4
|
+
const reactDom = require("react-dom");
|
|
5
|
+
const virtualCore = require("@tanstack/virtual-core");
|
|
6
|
+
function _interopNamespaceDefault(e) {
|
|
7
|
+
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
8
|
+
if (e) {
|
|
9
|
+
for (const k in e) {
|
|
10
|
+
if (k !== "default") {
|
|
11
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
12
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: () => e[k]
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
n.default = e;
|
|
20
|
+
return Object.freeze(n);
|
|
21
|
+
}
|
|
22
|
+
const React__namespace = /* @__PURE__ */ _interopNamespaceDefault(React);
|
|
23
|
+
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
24
|
+
function useVirtualizerBase(options) {
|
|
25
|
+
const rerender = React__namespace.useReducer(() => ({}), {})[1];
|
|
26
|
+
const resolvedOptions = {
|
|
27
|
+
...options,
|
|
28
|
+
onChange: (instance2, sync) => {
|
|
29
|
+
var _a;
|
|
30
|
+
if (sync) {
|
|
31
|
+
reactDom.flushSync(rerender);
|
|
32
|
+
} else {
|
|
33
|
+
rerender();
|
|
34
|
+
}
|
|
35
|
+
(_a = options.onChange) == null ? void 0 : _a.call(options, instance2, sync);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const [instance] = React__namespace.useState(
|
|
39
|
+
() => new virtualCore.Virtualizer(resolvedOptions)
|
|
40
|
+
);
|
|
41
|
+
instance.setOptions(resolvedOptions);
|
|
42
|
+
React__namespace.useEffect(() => {
|
|
43
|
+
return instance._didMount();
|
|
44
|
+
}, []);
|
|
45
|
+
useIsomorphicLayoutEffect(() => {
|
|
46
|
+
return instance._willUpdate();
|
|
47
|
+
});
|
|
48
|
+
return instance;
|
|
49
|
+
}
|
|
50
|
+
function useVirtualizer(options) {
|
|
51
|
+
return useVirtualizerBase({
|
|
52
|
+
observeElementRect: virtualCore.observeElementRect,
|
|
53
|
+
observeElementOffset: virtualCore.observeElementOffset,
|
|
54
|
+
scrollToFn: virtualCore.elementScroll,
|
|
55
|
+
...options
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function useWindowVirtualizer(options) {
|
|
59
|
+
return useVirtualizerBase({
|
|
60
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
61
|
+
observeElementRect: virtualCore.observeWindowRect,
|
|
62
|
+
observeElementOffset: virtualCore.observeWindowOffset,
|
|
63
|
+
scrollToFn: virtualCore.windowScroll,
|
|
64
|
+
initialOffset: typeof document !== "undefined" ? window.scrollY : void 0,
|
|
65
|
+
...options
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
exports.useVirtualizer = useVirtualizer;
|
|
69
|
+
exports.useWindowVirtualizer = useWindowVirtualizer;
|
|
70
|
+
Object.keys(virtualCore).forEach((k) => {
|
|
71
|
+
if (k !== "default" && !Object.prototype.hasOwnProperty.call(exports, k))
|
|
72
|
+
Object.defineProperty(exports, k, {
|
|
73
|
+
enumerable: true,
|
|
74
|
+
get: () => virtualCore[k]
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n PartialKeys,\n Virtualizer,\n VirtualizerOptions,\n windowScroll,\n} from '@tanstack/virtual-core'\nexport * from '@tanstack/virtual-core'\n\n//\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 React.useEffect(() => {\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 : undefined,\n ...options,\n })\n}\n"],"names":["React","instance","flushSync","Virtualizer","observeElementRect","observeElementOffset","elementScroll","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAiBA,MAAM,4BACJ,OAAO,aAAa,cAAcA,iBAAM,kBAAkBA,iBAAM;AAElE,SAAS,mBAIP,SAC2C;AACrC,QAAA,WAAWA,iBAAM,WAAW,OAAO,CAAK,IAAA,CAAE,CAAA,EAAE,CAAC;AAEnD,QAAM,kBAAoE;AAAA,IACxE,GAAG;AAAA,IACH,UAAU,CAACC,WAAU,SAAS;;AAC5B,UAAI,MAAM;AACRC,iBAAA,UAAU,QAAQ;AAAA,MAAA,OACb;AACI;MACX;AACQ,oBAAA,aAAA,iCAAWD,WAAU;AAAA,IAC/B;AAAA,EAAA;AAGI,QAAA,CAAC,QAAQ,IAAID,iBAAM;AAAA,IACvB,MAAM,IAAIG,YAAA,YAA0C,eAAe;AAAA,EAAA;AAGrE,WAAS,WAAW,eAAe;AAEnCH,mBAAM,UAAU,MAAM;AACpB,WAAO,SAAS;EAClB,GAAG,CAAE,CAAA;AAEL,4BAA0B,MAAM;AAC9B,WAAO,SAAS;EAAY,CAC7B;AAEM,SAAA;AACT;AAEO,SAAS,eAId,SAI2C;AAC3C,SAAO,mBAAiD;AAAA,IAAA,oBACtDI,YAAA;AAAA,IAAA,sBACAC,YAAA;AAAA,IACA,YAAYC,YAAA;AAAA,IACZ,GAAG;AAAA,EAAA,CACJ;AACH;AAEO,SAAS,qBACd,SAOmC;AACnC,SAAO,mBAAyC;AAAA,IAC9C,kBAAkB,MAAO,OAAO,aAAa,cAAc,SAAS;AAAA,IACpE,oBAAoBC,YAAA;AAAA,IACpB,sBAAsBC,YAAA;AAAA,IACtB,YAAYC,YAAA;AAAA,IACZ,eAAe,OAAO,aAAa,cAAc,OAAO,UAAU;AAAA,IAClE,GAAG;AAAA,EAAA,CACJ;AACH;;;;;;;;;;"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { PartialKeys, Virtualizer, VirtualizerOptions } from '@tanstack/virtual-core';
|
|
2
|
+
export * from '@tanstack/virtual-core';
|
|
3
|
+
export declare function useVirtualizer<TScrollElement extends Element, TItemElement extends Element>(options: PartialKeys<VirtualizerOptions<TScrollElement, TItemElement>, 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'>): Virtualizer<TScrollElement, TItemElement>;
|
|
4
|
+
export declare function useWindowVirtualizer<TItemElement extends Element>(options: PartialKeys<VirtualizerOptions<Window, TItemElement>, 'getScrollElement' | 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'>): Virtualizer<Window, TItemElement>;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { flushSync } from "react-dom";
|
|
3
|
+
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from "@tanstack/virtual-core";
|
|
4
|
+
export * from "@tanstack/virtual-core";
|
|
5
|
+
const useIsomorphicLayoutEffect = typeof document !== "undefined" ? React.useLayoutEffect : React.useEffect;
|
|
6
|
+
function useVirtualizerBase(options) {
|
|
7
|
+
const rerender = React.useReducer(() => ({}), {})[1];
|
|
8
|
+
const resolvedOptions = {
|
|
9
|
+
...options,
|
|
10
|
+
onChange: (instance2, sync) => {
|
|
11
|
+
var _a;
|
|
12
|
+
if (sync) {
|
|
13
|
+
flushSync(rerender);
|
|
14
|
+
} else {
|
|
15
|
+
rerender();
|
|
16
|
+
}
|
|
17
|
+
(_a = options.onChange) == null ? void 0 : _a.call(options, instance2, sync);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const [instance] = React.useState(
|
|
21
|
+
() => new Virtualizer(resolvedOptions)
|
|
22
|
+
);
|
|
23
|
+
instance.setOptions(resolvedOptions);
|
|
24
|
+
React.useEffect(() => {
|
|
25
|
+
return instance._didMount();
|
|
26
|
+
}, []);
|
|
27
|
+
useIsomorphicLayoutEffect(() => {
|
|
28
|
+
return instance._willUpdate();
|
|
29
|
+
});
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
function useVirtualizer(options) {
|
|
33
|
+
return useVirtualizerBase({
|
|
34
|
+
observeElementRect,
|
|
35
|
+
observeElementOffset,
|
|
36
|
+
scrollToFn: elementScroll,
|
|
37
|
+
...options
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
function useWindowVirtualizer(options) {
|
|
41
|
+
return useVirtualizerBase({
|
|
42
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
43
|
+
observeElementRect: observeWindowRect,
|
|
44
|
+
observeElementOffset: observeWindowOffset,
|
|
45
|
+
scrollToFn: windowScroll,
|
|
46
|
+
initialOffset: typeof document !== "undefined" ? window.scrollY : void 0,
|
|
47
|
+
...options
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
useVirtualizer,
|
|
52
|
+
useWindowVirtualizer
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n PartialKeys,\n Virtualizer,\n VirtualizerOptions,\n windowScroll,\n} from '@tanstack/virtual-core'\nexport * from '@tanstack/virtual-core'\n\n//\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 React.useEffect(() => {\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 : undefined,\n ...options,\n })\n}\n"],"names":["
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n PartialKeys,\n Virtualizer,\n VirtualizerOptions,\n windowScroll,\n} from '@tanstack/virtual-core'\nexport * from '@tanstack/virtual-core'\n\n//\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 React.useEffect(() => {\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 : undefined,\n ...options,\n })\n}\n"],"names":["instance"],"mappings":";;;;AAiBA,MAAM,4BACJ,OAAO,aAAa,cAAc,MAAM,kBAAkB,MAAM;AAElE,SAAS,mBAIP,SAC2C;AACrC,QAAA,WAAW,MAAM,WAAW,OAAO,CAAK,IAAA,CAAE,CAAA,EAAE,CAAC;AAEnD,QAAM,kBAAoE;AAAA,IACxE,GAAG;AAAA,IACH,UAAU,CAACA,WAAU,SAAS;;AAC5B,UAAI,MAAM;AACR,kBAAU,QAAQ;AAAA,MAAA,OACb;AACI;MACX;AACQ,oBAAA,aAAA,iCAAWA,WAAU;AAAA,IAC/B;AAAA,EAAA;AAGI,QAAA,CAAC,QAAQ,IAAI,MAAM;AAAA,IACvB,MAAM,IAAI,YAA0C,eAAe;AAAA,EAAA;AAGrE,WAAS,WAAW,eAAe;AAEnC,QAAM,UAAU,MAAM;AACpB,WAAO,SAAS;EAClB,GAAG,CAAE,CAAA;AAEL,4BAA0B,MAAM;AAC9B,WAAO,SAAS;EAAY,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,OAAO,aAAa,cAAc,OAAO,UAAU;AAAA,IAClE,GAAG;AAAA,EAAA,CACJ;AACH;"}
|
package/package.json
CHANGED
|
@@ -1,59 +1,70 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/react-virtual",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.3",
|
|
3
|
+
"version": "3.1.0",
|
|
5
4
|
"description": "Headless UI for virtualizing scrollable elements in React",
|
|
5
|
+
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
7
|
-
"homepage": "https://github.com/tanstack/virtual#readme",
|
|
8
7
|
"repository": {
|
|
9
8
|
"type": "git",
|
|
10
9
|
"url": "git+https://github.com/tanstack/virtual.git"
|
|
11
10
|
},
|
|
12
|
-
"
|
|
13
|
-
"registry": "https://registry.npmjs.org/"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"react",
|
|
17
|
-
"vue",
|
|
18
|
-
"solid",
|
|
19
|
-
"virtual",
|
|
20
|
-
"virtual-core",
|
|
21
|
-
"datagrid"
|
|
22
|
-
],
|
|
11
|
+
"homepage": "https://github.com/tanstack/virtual#readme",
|
|
23
12
|
"funding": {
|
|
24
13
|
"type": "github",
|
|
25
14
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
26
15
|
},
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
16
|
+
"type": "module",
|
|
17
|
+
"types": "dist/esm/index.d.ts",
|
|
18
|
+
"main": "dist/cjs/index.cjs",
|
|
19
|
+
"module": "dist/esm/index.js",
|
|
30
20
|
"exports": {
|
|
31
21
|
".": {
|
|
32
|
-
"
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
"import": {
|
|
23
|
+
"types": "./dist/esm/index.d.ts",
|
|
24
|
+
"default": "./dist/esm/index.js"
|
|
25
|
+
},
|
|
26
|
+
"require": {
|
|
27
|
+
"types": "./dist/cjs/index.d.cts",
|
|
28
|
+
"default": "./dist/cjs/index.cjs"
|
|
29
|
+
}
|
|
35
30
|
},
|
|
36
31
|
"./package.json": "./package.json"
|
|
37
32
|
},
|
|
38
33
|
"sideEffects": false,
|
|
34
|
+
"keywords": [
|
|
35
|
+
"react",
|
|
36
|
+
"vue",
|
|
37
|
+
"solid",
|
|
38
|
+
"virtual",
|
|
39
|
+
"virtual-core",
|
|
40
|
+
"datagrid"
|
|
41
|
+
],
|
|
39
42
|
"files": [
|
|
40
|
-
"
|
|
41
|
-
"build/umd/*",
|
|
43
|
+
"dist",
|
|
42
44
|
"src"
|
|
43
45
|
],
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@tanstack/virtual-core": "3.1.0"
|
|
48
|
+
},
|
|
44
49
|
"devDependencies": {
|
|
45
50
|
"@testing-library/react": "^13.4.0",
|
|
46
51
|
"@types/react": "18.0.26",
|
|
47
52
|
"@types/react-dom": "18.0.10",
|
|
53
|
+
"@vitejs/plugin-react": "^4.2.1",
|
|
48
54
|
"react": "^18.2.0",
|
|
49
55
|
"react-dom": "^18.2.0",
|
|
50
56
|
"resize-observer-polyfill": "^1.5.1"
|
|
51
57
|
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"@tanstack/virtual-core": "3.0.0"
|
|
54
|
-
},
|
|
55
58
|
"peerDependencies": {
|
|
56
59
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
|
57
60
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"clean": "rimraf ./dist && rimraf ./coverage",
|
|
64
|
+
"test:types": "tsc",
|
|
65
|
+
"test:lib": "vitest",
|
|
66
|
+
"test:lib:dev": "pnpm run test:lib --watch",
|
|
67
|
+
"test:build": "publint --strict",
|
|
68
|
+
"build": "vite build"
|
|
58
69
|
}
|
|
59
70
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
function _extends() {
|
|
12
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
-
var source = arguments[i];
|
|
15
|
-
for (var key in source) {
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
-
target[key] = source[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return target;
|
|
22
|
-
};
|
|
23
|
-
return _extends.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { _extends as extends };
|
|
27
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
function _extends() {
|
|
16
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
17
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
18
|
-
var source = arguments[i];
|
|
19
|
-
for (var key in source) {
|
|
20
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
21
|
-
target[key] = source[key];
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
return target;
|
|
26
|
-
};
|
|
27
|
-
return _extends.apply(this, arguments);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
exports["extends"] = _extends;
|
|
31
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
function _extends() {
|
|
12
|
-
_extends = Object.assign ? Object.assign.bind() : function (target) {
|
|
13
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
14
|
-
var source = arguments[i];
|
|
15
|
-
for (var key in source) {
|
|
16
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
17
|
-
target[key] = source[key];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return target;
|
|
22
|
-
};
|
|
23
|
-
return _extends.apply(this, arguments);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export { _extends as extends };
|
|
27
|
-
//# sourceMappingURL=_rollupPluginBabelHelpers.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/lib/index.esm.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
12
|
-
import * as React from 'react';
|
|
13
|
-
import { flushSync } from 'react-dom';
|
|
14
|
-
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
15
|
-
export * from '@tanstack/virtual-core';
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
20
|
-
function useVirtualizerBase(options) {
|
|
21
|
-
var rerender = React.useReducer(function () {
|
|
22
|
-
return {};
|
|
23
|
-
}, {})[1];
|
|
24
|
-
var resolvedOptions = _extends({}, options, {
|
|
25
|
-
onChange: function onChange(instance, sync) {
|
|
26
|
-
if (sync) {
|
|
27
|
-
flushSync(rerender);
|
|
28
|
-
} else {
|
|
29
|
-
rerender();
|
|
30
|
-
}
|
|
31
|
-
options.onChange == null || options.onChange(instance, sync);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
var _React$useState = React.useState(function () {
|
|
35
|
-
return new Virtualizer(resolvedOptions);
|
|
36
|
-
}),
|
|
37
|
-
instance = _React$useState[0];
|
|
38
|
-
instance.setOptions(resolvedOptions);
|
|
39
|
-
React.useEffect(function () {
|
|
40
|
-
return instance._didMount();
|
|
41
|
-
}, []);
|
|
42
|
-
useIsomorphicLayoutEffect(function () {
|
|
43
|
-
return instance._willUpdate();
|
|
44
|
-
});
|
|
45
|
-
return instance;
|
|
46
|
-
}
|
|
47
|
-
function useVirtualizer(options) {
|
|
48
|
-
return useVirtualizerBase(_extends({
|
|
49
|
-
observeElementRect: observeElementRect,
|
|
50
|
-
observeElementOffset: observeElementOffset,
|
|
51
|
-
scrollToFn: elementScroll
|
|
52
|
-
}, options));
|
|
53
|
-
}
|
|
54
|
-
function useWindowVirtualizer(options) {
|
|
55
|
-
return useVirtualizerBase(_extends({
|
|
56
|
-
getScrollElement: function getScrollElement() {
|
|
57
|
-
return typeof document !== 'undefined' ? window : null;
|
|
58
|
-
},
|
|
59
|
-
observeElementRect: observeWindowRect,
|
|
60
|
-
observeElementOffset: observeWindowOffset,
|
|
61
|
-
scrollToFn: windowScroll,
|
|
62
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
63
|
-
}, options));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { useVirtualizer, useWindowVirtualizer };
|
|
67
|
-
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\nimport { flushSync } from 'react-dom'\nimport {\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n PartialKeys,\n Virtualizer,\n VirtualizerOptions,\n windowScroll,\n} from '@tanstack/virtual-core'\nexport * from '@tanstack/virtual-core'\n\n//\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 React.useEffect(() => {\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 : undefined,\n ...options,\n })\n}\n"],"names":["useIsomorphicLayoutEffect","document","React","useLayoutEffect","useEffect","useVirtualizerBase","options","rerender","useReducer","resolvedOptions","_extends","onChange","instance","sync","flushSync","_React$useState","useState","Virtualizer","setOptions","_didMount","_willUpdate","useVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll","initialOffset","scrollY","undefined"],"mappings":";;;;;;;;;;;;;;;;AAeA;;AAEA,IAAMA,yBAAyB,GAC7B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,KAAK,CAACC,eAAe,GAAGD,KAAK,CAACE,SAAS,CAAA;AAE3E,SAASC,kBAAkBA,CAIzBC,OAAyD,EACd;AAC3C,EAAA,IAAMC,QAAQ,GAAGL,KAAK,CAACM,UAAU,CAAC,YAAA;AAAA,IAAA,OAAO,EAAE,CAAA;AAAA,GAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;AAEpD,EAAA,IAAMC,eAAiE,GAAAC,QAAA,CAAA,EAAA,EAClEJ,OAAO,EAAA;AACVK,IAAAA,QAAQ,EAAE,SAAAA,QAAAA,CAACC,QAAQ,EAAEC,IAAI,EAAK;AAC5B,MAAA,IAAIA,IAAI,EAAE;QACRC,SAAS,CAACP,QAAQ,CAAC,CAAA;AACrB,OAAC,MAAM;AACLA,QAAAA,QAAQ,EAAE,CAAA;AACZ,OAAA;MACAD,OAAO,CAACK,QAAQ,IAAA,IAAA,IAAhBL,OAAO,CAACK,QAAQ,CAAGC,QAAQ,EAAEC,IAAI,CAAC,CAAA;AACpC,KAAA;GACD,CAAA,CAAA;AAED,EAAA,IAAAE,eAAA,GAAmBb,KAAK,CAACc,QAAQ,CAC/B,YAAA;AAAA,MAAA,OAAM,IAAIC,WAAW,CAA+BR,eAAe,CAAC,CAAA;AAAA,KACtE,CAAC;AAFMG,IAAAA,QAAQ,GAAAG,eAAA,CAAA,CAAA,CAAA,CAAA;AAIfH,EAAAA,QAAQ,CAACM,UAAU,CAACT,eAAe,CAAC,CAAA;EAEpCP,KAAK,CAACE,SAAS,CAAC,YAAM;AACpB,IAAA,OAAOQ,QAAQ,CAACO,SAAS,EAAE,CAAA;GAC5B,EAAE,EAAE,CAAC,CAAA;AAENnB,EAAAA,yBAAyB,CAAC,YAAM;AAC9B,IAAA,OAAOY,QAAQ,CAACQ,WAAW,EAAE,CAAA;AAC/B,GAAC,CAAC,CAAA;AAEF,EAAA,OAAOR,QAAQ,CAAA;AACjB,CAAA;AAEO,SAASS,cAAcA,CAI5Bf,OAGC,EAC0C;EAC3C,OAAOD,kBAAkB,CAAAK,QAAA,CAAA;AACvBY,IAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,IAAAA,UAAU,EAAEC,aAAAA;GACTnB,EAAAA,OAAO,CACX,CAAC,CAAA;AACJ,CAAA;AAEO,SAASoB,oBAAoBA,CAClCpB,OAMC,EACkC;EACnC,OAAOD,kBAAkB,CAAAK,QAAA,CAAA;IACvBiB,gBAAgB,EAAE,SAAAA,gBAAA,GAAA;AAAA,MAAA,OAAO,OAAO1B,QAAQ,KAAK,WAAW,GAAG2B,MAAM,GAAG,IAAI,CAAA;KAAC;AACzEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAY;IACxBC,aAAa,EAAE,OAAO/B,QAAQ,KAAK,WAAW,GAAG2B,MAAM,CAACK,OAAO,GAAGC,SAAAA;GAC/D5B,EAAAA,OAAO,CACX,CAAC,CAAA;AACJ;;;;"}
|
package/build/lib/index.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
'use strict';
|
|
12
|
-
|
|
13
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
|
-
|
|
15
|
-
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
16
|
-
var React = require('react');
|
|
17
|
-
var reactDom = require('react-dom');
|
|
18
|
-
var virtualCore = require('@tanstack/virtual-core');
|
|
19
|
-
|
|
20
|
-
function _interopNamespace(e) {
|
|
21
|
-
if (e && e.__esModule) return e;
|
|
22
|
-
var n = Object.create(null);
|
|
23
|
-
if (e) {
|
|
24
|
-
Object.keys(e).forEach(function (k) {
|
|
25
|
-
if (k !== 'default') {
|
|
26
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
27
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
28
|
-
enumerable: true,
|
|
29
|
-
get: function () { return e[k]; }
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
n["default"] = e;
|
|
35
|
-
return Object.freeze(n);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
39
|
-
|
|
40
|
-
//
|
|
41
|
-
|
|
42
|
-
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
43
|
-
function useVirtualizerBase(options) {
|
|
44
|
-
var rerender = React__namespace.useReducer(function () {
|
|
45
|
-
return {};
|
|
46
|
-
}, {})[1];
|
|
47
|
-
var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, options, {
|
|
48
|
-
onChange: function onChange(instance, sync) {
|
|
49
|
-
if (sync) {
|
|
50
|
-
reactDom.flushSync(rerender);
|
|
51
|
-
} else {
|
|
52
|
-
rerender();
|
|
53
|
-
}
|
|
54
|
-
options.onChange == null || options.onChange(instance, sync);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
var _React$useState = React__namespace.useState(function () {
|
|
58
|
-
return new virtualCore.Virtualizer(resolvedOptions);
|
|
59
|
-
}),
|
|
60
|
-
instance = _React$useState[0];
|
|
61
|
-
instance.setOptions(resolvedOptions);
|
|
62
|
-
React__namespace.useEffect(function () {
|
|
63
|
-
return instance._didMount();
|
|
64
|
-
}, []);
|
|
65
|
-
useIsomorphicLayoutEffect(function () {
|
|
66
|
-
return instance._willUpdate();
|
|
67
|
-
});
|
|
68
|
-
return instance;
|
|
69
|
-
}
|
|
70
|
-
function useVirtualizer(options) {
|
|
71
|
-
return useVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
72
|
-
observeElementRect: virtualCore.observeElementRect,
|
|
73
|
-
observeElementOffset: virtualCore.observeElementOffset,
|
|
74
|
-
scrollToFn: virtualCore.elementScroll
|
|
75
|
-
}, options));
|
|
76
|
-
}
|
|
77
|
-
function useWindowVirtualizer(options) {
|
|
78
|
-
return useVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
79
|
-
getScrollElement: function getScrollElement() {
|
|
80
|
-
return typeof document !== 'undefined' ? window : null;
|
|
81
|
-
},
|
|
82
|
-
observeElementRect: virtualCore.observeWindowRect,
|
|
83
|
-
observeElementOffset: virtualCore.observeWindowOffset,
|
|
84
|
-
scrollToFn: virtualCore.windowScroll,
|
|
85
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
86
|
-
}, options));
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
exports.useVirtualizer = useVirtualizer;
|
|
90
|
-
exports.useWindowVirtualizer = useWindowVirtualizer;
|
|
91
|
-
Object.keys(virtualCore).forEach(function (k) {
|
|
92
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
93
|
-
enumerable: true,
|
|
94
|
-
get: function () { return virtualCore[k]; }
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
//# sourceMappingURL=index.js.map
|
package/build/lib/index.mjs
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* react-virtual
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) TanStack
|
|
5
|
-
*
|
|
6
|
-
* This source code is licensed under the MIT license found in the
|
|
7
|
-
* LICENSE.md file in the root directory of this source tree.
|
|
8
|
-
*
|
|
9
|
-
* @license MIT
|
|
10
|
-
*/
|
|
11
|
-
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
12
|
-
import * as React from 'react';
|
|
13
|
-
import { flushSync } from 'react-dom';
|
|
14
|
-
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
15
|
-
export * from '@tanstack/virtual-core';
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
20
|
-
function useVirtualizerBase(options) {
|
|
21
|
-
var rerender = React.useReducer(function () {
|
|
22
|
-
return {};
|
|
23
|
-
}, {})[1];
|
|
24
|
-
var resolvedOptions = _extends({}, options, {
|
|
25
|
-
onChange: function onChange(instance, sync) {
|
|
26
|
-
if (sync) {
|
|
27
|
-
flushSync(rerender);
|
|
28
|
-
} else {
|
|
29
|
-
rerender();
|
|
30
|
-
}
|
|
31
|
-
options.onChange == null || options.onChange(instance, sync);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
var _React$useState = React.useState(function () {
|
|
35
|
-
return new Virtualizer(resolvedOptions);
|
|
36
|
-
}),
|
|
37
|
-
instance = _React$useState[0];
|
|
38
|
-
instance.setOptions(resolvedOptions);
|
|
39
|
-
React.useEffect(function () {
|
|
40
|
-
return instance._didMount();
|
|
41
|
-
}, []);
|
|
42
|
-
useIsomorphicLayoutEffect(function () {
|
|
43
|
-
return instance._willUpdate();
|
|
44
|
-
});
|
|
45
|
-
return instance;
|
|
46
|
-
}
|
|
47
|
-
function useVirtualizer(options) {
|
|
48
|
-
return useVirtualizerBase(_extends({
|
|
49
|
-
observeElementRect: observeElementRect,
|
|
50
|
-
observeElementOffset: observeElementOffset,
|
|
51
|
-
scrollToFn: elementScroll
|
|
52
|
-
}, options));
|
|
53
|
-
}
|
|
54
|
-
function useWindowVirtualizer(options) {
|
|
55
|
-
return useVirtualizerBase(_extends({
|
|
56
|
-
getScrollElement: function getScrollElement() {
|
|
57
|
-
return typeof document !== 'undefined' ? window : null;
|
|
58
|
-
},
|
|
59
|
-
observeElementRect: observeWindowRect,
|
|
60
|
-
observeElementOffset: observeWindowOffset,
|
|
61
|
-
scrollToFn: windowScroll,
|
|
62
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
63
|
-
}, options));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export { useVirtualizer, useWindowVirtualizer };
|
|
67
|
-
//# sourceMappingURL=index.mjs.map
|