@tanstack/react-virtual 3.0.0-beta.6 → 3.0.0-beta.60
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/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +27 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js +31 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +27 -0
- package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
- package/build/lib/index.d.ts +4 -0
- package/build/lib/index.esm.js +61 -0
- package/build/lib/index.esm.js.map +1 -0
- package/build/lib/index.js +91 -0
- package/build/lib/index.js.map +1 -0
- package/build/lib/index.mjs +61 -0
- package/build/lib/index.mjs.map +1 -0
- package/build/umd/index.development.js +663 -470
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +22 -2
- package/build/umd/index.production.js.map +1 -1
- package/package.json +23 -10
- package/src/index.tsx +11 -5
- package/build/cjs/react-virtual/src/index.js +0 -90
- package/build/cjs/react-virtual/src/index.js.map +0 -1
- package/build/cjs/virtual-core/build/esm/index.js +0 -583
- package/build/cjs/virtual-core/build/esm/index.js.map +0 -1
- package/build/esm/index.js +0 -610
- package/build/esm/index.js.map +0 -1
- package/build/stats-html.html +0 -2689
- package/build/stats.json +0 -90
- package/build/types/react-virtual/src/index.d.ts +0 -4
- package/build/types/virtual-core/src/utils.d.ts +0 -7
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -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,61 @@
|
|
|
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 { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
14
|
+
export * from '@tanstack/virtual-core';
|
|
15
|
+
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
19
|
+
function useVirtualizerBase(options) {
|
|
20
|
+
var rerender = React.useReducer(function () {
|
|
21
|
+
return {};
|
|
22
|
+
}, {})[1];
|
|
23
|
+
var resolvedOptions = _extends({}, options, {
|
|
24
|
+
onChange: function onChange(instance) {
|
|
25
|
+
rerender();
|
|
26
|
+
options.onChange == null ? void 0 : options.onChange(instance);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _React$useState = React.useState(function () {
|
|
30
|
+
return new Virtualizer(resolvedOptions);
|
|
31
|
+
}),
|
|
32
|
+
instance = _React$useState[0];
|
|
33
|
+
instance.setOptions(resolvedOptions);
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
return instance._didMount();
|
|
36
|
+
}, []);
|
|
37
|
+
useIsomorphicLayoutEffect(function () {
|
|
38
|
+
return instance._willUpdate();
|
|
39
|
+
});
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
function useVirtualizer(options) {
|
|
43
|
+
return useVirtualizerBase(_extends({
|
|
44
|
+
observeElementRect: observeElementRect,
|
|
45
|
+
observeElementOffset: observeElementOffset,
|
|
46
|
+
scrollToFn: elementScroll
|
|
47
|
+
}, options));
|
|
48
|
+
}
|
|
49
|
+
function useWindowVirtualizer(options) {
|
|
50
|
+
return useVirtualizerBase(_extends({
|
|
51
|
+
getScrollElement: function getScrollElement() {
|
|
52
|
+
return typeof document !== 'undefined' ? window : null;
|
|
53
|
+
},
|
|
54
|
+
observeElementRect: observeWindowRect,
|
|
55
|
+
observeElementOffset: observeWindowOffset,
|
|
56
|
+
scrollToFn: windowScroll
|
|
57
|
+
}, options));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { useVirtualizer, useWindowVirtualizer };
|
|
61
|
+
//# sourceMappingURL=index.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\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) => {\n rerender()\n options.onChange?.(instance)\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 ...options,\n })\n}\n"],"names":["useIsomorphicLayoutEffect","document","React","useLayoutEffect","useEffect","useVirtualizerBase","options","rerender","useReducer","resolvedOptions","onChange","instance","useState","Virtualizer","setOptions","_didMount","_willUpdate","useVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;AAcA;;AAEA,IAAMA,yBAAyB,GAC7B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,KAAK,CAACC,eAAe,GAAGD,KAAK,CAACE,SAAS,CAAA;AAE3E,SAASC,kBAAkB,CAIzBC,OAAyD,EACd;AAC3C,EAAA,IAAMC,QAAQ,GAAGL,KAAK,CAACM,UAAU,CAAC,YAAA;AAAA,IAAA,OAAO,EAAE,CAAA;AAA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AAO,OAAOtB,QAAQ,KAAK,WAAW,GAAGuB,MAAM,GAAG,IAAI,CAAA;KAAC;AACzEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAAA;AAAY,GAAA,EACrBrB,OAAO,CACV,CAAA,CAAA;AACJ;;;;"}
|
|
@@ -0,0 +1,91 @@
|
|
|
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 virtualCore = require('@tanstack/virtual-core');
|
|
18
|
+
|
|
19
|
+
function _interopNamespace(e) {
|
|
20
|
+
if (e && e.__esModule) return e;
|
|
21
|
+
var n = Object.create(null);
|
|
22
|
+
if (e) {
|
|
23
|
+
Object.keys(e).forEach(function (k) {
|
|
24
|
+
if (k !== 'default') {
|
|
25
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
26
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function () { return e[k]; }
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
n["default"] = e;
|
|
34
|
+
return Object.freeze(n);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
|
|
41
|
+
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React__namespace.useLayoutEffect : React__namespace.useEffect;
|
|
42
|
+
function useVirtualizerBase(options) {
|
|
43
|
+
var rerender = React__namespace.useReducer(function () {
|
|
44
|
+
return {};
|
|
45
|
+
}, {})[1];
|
|
46
|
+
var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, options, {
|
|
47
|
+
onChange: function onChange(instance) {
|
|
48
|
+
rerender();
|
|
49
|
+
options.onChange == null ? void 0 : options.onChange(instance);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
var _React$useState = React__namespace.useState(function () {
|
|
53
|
+
return new virtualCore.Virtualizer(resolvedOptions);
|
|
54
|
+
}),
|
|
55
|
+
instance = _React$useState[0];
|
|
56
|
+
instance.setOptions(resolvedOptions);
|
|
57
|
+
React__namespace.useEffect(function () {
|
|
58
|
+
return instance._didMount();
|
|
59
|
+
}, []);
|
|
60
|
+
useIsomorphicLayoutEffect(function () {
|
|
61
|
+
return instance._willUpdate();
|
|
62
|
+
});
|
|
63
|
+
return instance;
|
|
64
|
+
}
|
|
65
|
+
function useVirtualizer(options) {
|
|
66
|
+
return useVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
67
|
+
observeElementRect: virtualCore.observeElementRect,
|
|
68
|
+
observeElementOffset: virtualCore.observeElementOffset,
|
|
69
|
+
scrollToFn: virtualCore.elementScroll
|
|
70
|
+
}, options));
|
|
71
|
+
}
|
|
72
|
+
function useWindowVirtualizer(options) {
|
|
73
|
+
return useVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
74
|
+
getScrollElement: function getScrollElement() {
|
|
75
|
+
return typeof document !== 'undefined' ? window : null;
|
|
76
|
+
},
|
|
77
|
+
observeElementRect: virtualCore.observeWindowRect,
|
|
78
|
+
observeElementOffset: virtualCore.observeWindowOffset,
|
|
79
|
+
scrollToFn: virtualCore.windowScroll
|
|
80
|
+
}, options));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.useVirtualizer = useVirtualizer;
|
|
84
|
+
exports.useWindowVirtualizer = useWindowVirtualizer;
|
|
85
|
+
Object.keys(virtualCore).forEach(function (k) {
|
|
86
|
+
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
87
|
+
enumerable: true,
|
|
88
|
+
get: function () { return virtualCore[k]; }
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\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) => {\n rerender()\n options.onChange?.(instance)\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 ...options,\n })\n}\n"],"names":["useIsomorphicLayoutEffect","document","React","useLayoutEffect","useEffect","useVirtualizerBase","options","rerender","useReducer","resolvedOptions","onChange","instance","useState","Virtualizer","setOptions","_didMount","_willUpdate","useVirtualizer","_extends","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA;;AAEA,IAAMA,yBAAyB,GAC7B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,gBAAK,CAACC,eAAe,GAAGD,gBAAK,CAACE,SAAS,CAAA;AAE3E,SAASC,kBAAkB,CAIzBC,OAAyD,EACd;AAC3C,EAAA,IAAMC,QAAQ,GAAGL,gBAAK,CAACM,UAAU,CAAC,YAAA;AAAA,IAAA,OAAO,EAAE,CAAA;AAAA,GAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;EAEpD,IAAMC,eAAiE,4CAClEH,OAAO,EAAA;IACVI,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;AACtBJ,MAAAA,QAAQ,EAAE,CAAA;MACVD,OAAO,CAACI,QAAQ,IAAhBJ,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACI,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,KAAA;GACD,CAAA,CAAA;EA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|
+
*
|
|
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 { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
14
|
+
export * from '@tanstack/virtual-core';
|
|
15
|
+
|
|
16
|
+
//
|
|
17
|
+
|
|
18
|
+
var useIsomorphicLayoutEffect = typeof document !== 'undefined' ? React.useLayoutEffect : React.useEffect;
|
|
19
|
+
function useVirtualizerBase(options) {
|
|
20
|
+
var rerender = React.useReducer(function () {
|
|
21
|
+
return {};
|
|
22
|
+
}, {})[1];
|
|
23
|
+
var resolvedOptions = _extends({}, options, {
|
|
24
|
+
onChange: function onChange(instance) {
|
|
25
|
+
rerender();
|
|
26
|
+
options.onChange == null ? void 0 : options.onChange(instance);
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
var _React$useState = React.useState(function () {
|
|
30
|
+
return new Virtualizer(resolvedOptions);
|
|
31
|
+
}),
|
|
32
|
+
instance = _React$useState[0];
|
|
33
|
+
instance.setOptions(resolvedOptions);
|
|
34
|
+
React.useEffect(function () {
|
|
35
|
+
return instance._didMount();
|
|
36
|
+
}, []);
|
|
37
|
+
useIsomorphicLayoutEffect(function () {
|
|
38
|
+
return instance._willUpdate();
|
|
39
|
+
});
|
|
40
|
+
return instance;
|
|
41
|
+
}
|
|
42
|
+
function useVirtualizer(options) {
|
|
43
|
+
return useVirtualizerBase(_extends({
|
|
44
|
+
observeElementRect: observeElementRect,
|
|
45
|
+
observeElementOffset: observeElementOffset,
|
|
46
|
+
scrollToFn: elementScroll
|
|
47
|
+
}, options));
|
|
48
|
+
}
|
|
49
|
+
function useWindowVirtualizer(options) {
|
|
50
|
+
return useVirtualizerBase(_extends({
|
|
51
|
+
getScrollElement: function getScrollElement() {
|
|
52
|
+
return typeof document !== 'undefined' ? window : null;
|
|
53
|
+
},
|
|
54
|
+
observeElementRect: observeWindowRect,
|
|
55
|
+
observeElementOffset: observeWindowOffset,
|
|
56
|
+
scrollToFn: windowScroll
|
|
57
|
+
}, options));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export { useVirtualizer, useWindowVirtualizer };
|
|
61
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.tsx"],"sourcesContent":["import * as React from 'react'\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) => {\n rerender()\n options.onChange?.(instance)\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 ...options,\n })\n}\n"],"names":["useIsomorphicLayoutEffect","document","React","useLayoutEffect","useEffect","useVirtualizerBase","options","rerender","useReducer","resolvedOptions","onChange","instance","useState","Virtualizer","setOptions","_didMount","_willUpdate","useVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;AAcA;;AAEA,IAAMA,yBAAyB,GAC7B,OAAOC,QAAQ,KAAK,WAAW,GAAGC,KAAK,CAACC,eAAe,GAAGD,KAAK,CAACE,SAAS,CAAA;AAE3E,SAASC,kBAAkB,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;EAEpD,IAAMC,eAAiE,gBAClEH,OAAO,EAAA;IACVI,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;AACtBJ,MAAAA,QAAQ,EAAE,CAAA;MACVD,OAAO,CAACI,QAAQ,IAAhBJ,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACI,QAAQ,CAAGC,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