@tanstack/svelte-virtual 3.0.0-beta.30 → 3.0.0-beta.33
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.esm.js +19 -17
- package/build/lib/index.esm.js.map +1 -1
- package/build/lib/index.js +19 -17
- package/build/lib/index.js.map +1 -1
- package/build/lib/index.mjs +19 -17
- package/build/lib/index.mjs.map +1 -1
- package/build/umd/index.development.js +493 -432
- package/build/umd/index.development.js.map +1 -1
- package/build/umd/index.production.js +13 -3
- package/build/umd/index.production.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* svelte-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
|
+
* svelte-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
|
+
* svelte-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":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/lib/index.esm.js
CHANGED
|
@@ -8,41 +8,43 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
11
12
|
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
12
13
|
export * from '@tanstack/virtual-core';
|
|
13
14
|
import { readable } from 'svelte/store';
|
|
14
15
|
|
|
15
16
|
function createVirtualizerBase(options) {
|
|
16
|
-
|
|
17
|
-
return readable(virtualizer, set
|
|
18
|
-
|
|
17
|
+
var virtualizer = new Virtualizer(options);
|
|
18
|
+
return readable(virtualizer, function (set) {
|
|
19
|
+
var cleanup = virtualizer._didMount();
|
|
19
20
|
virtualizer._willUpdate();
|
|
20
|
-
virtualizer.setOptions({
|
|
21
|
-
|
|
22
|
-
onChange: instance => {
|
|
21
|
+
virtualizer.setOptions(_extends({}, options, {
|
|
22
|
+
onChange: function onChange(instance) {
|
|
23
23
|
set(instance);
|
|
24
24
|
options.onChange == null ? void 0 : options.onChange(instance);
|
|
25
25
|
}
|
|
26
|
-
});
|
|
27
|
-
return ()
|
|
26
|
+
}));
|
|
27
|
+
return function () {
|
|
28
|
+
return cleanup();
|
|
29
|
+
};
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
function createVirtualizer(options) {
|
|
31
|
-
return createVirtualizerBase({
|
|
33
|
+
return createVirtualizerBase(_extends({
|
|
32
34
|
observeElementRect: observeElementRect,
|
|
33
35
|
observeElementOffset: observeElementOffset,
|
|
34
|
-
scrollToFn: elementScroll
|
|
35
|
-
|
|
36
|
-
});
|
|
36
|
+
scrollToFn: elementScroll
|
|
37
|
+
}, options));
|
|
37
38
|
}
|
|
38
39
|
function createWindowVirtualizer(options) {
|
|
39
|
-
return createVirtualizerBase({
|
|
40
|
-
getScrollElement: ()
|
|
40
|
+
return createVirtualizerBase(_extends({
|
|
41
|
+
getScrollElement: function getScrollElement() {
|
|
42
|
+
return typeof window !== 'undefined' ? window : null;
|
|
43
|
+
},
|
|
41
44
|
observeElementRect: observeWindowRect,
|
|
42
45
|
observeElementOffset: observeWindowOffset,
|
|
43
|
-
scrollToFn: windowScroll
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
+
scrollToFn: windowScroll
|
|
47
|
+
}, options));
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export { createVirtualizer, createWindowVirtualizer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;AAeA,SAASA,qBAAqB,CAI5BC,OAAyD,EACJ;AACrD,EAAA,IAAMC,WAAW,GAAG,IAAIC,WAAW,CAACF,OAAO,CAAC,CAAA;AAE5C,EAAA,OAAOG,QAAQ,CAACF,WAAW,EAAE,UAACG,GAAG,EAAK;AACpC,IAAA,IAAMC,OAAO,GAAGJ,WAAW,CAACK,SAAS,EAAE,CAAA;IACvCL,WAAW,CAACM,WAAW,EAAE,CAAA;IACzBN,WAAW,CAACO,UAAU,CAAA,QAAA,CAAA,EAAA,EACjBR,OAAO,EAAA;MACVS,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAmD,EAAK;QACjEN,GAAG,CAACM,QAAQ,CAAC,CAAA;QACbV,OAAO,CAACS,QAAQ,IAAhBT,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACS,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEF,OAAO,YAAA;AAAA,MAAA,OAAML,OAAO,EAAE,CAAA;AAAA,KAAA,CAAA;AACxB,GAAC,CAAC,CAAA;AACJ,CAAA;AAEO,SAASM,iBAAiB,CAI/BX,OAGC,EACoD;AACrD,EAAA,OAAOD,qBAAqB,CAAA,QAAA,CAAA;AAC1Ba,IAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,IAAAA,UAAU,EAAEC,aAAAA;AAAa,GAAA,EACtBf,OAAO,CACV,CAAA,CAAA;AACJ,CAAA;AAEO,SAASgB,uBAAuB,CACrChB,OAMC,EAC4C;AAC7C,EAAA,OAAOD,qBAAqB,CAAA,QAAA,CAAA;AAC1BkB,IAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,MAAA,OAAO,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAG,IAAK,CAAA;KAAC;AACxEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAAA;AAAY,GAAA,EACrBrB,OAAO,CACV,CAAA,CAAA;AACJ;;;;"}
|
package/build/lib/index.js
CHANGED
|
@@ -12,40 +12,42 @@
|
|
|
12
12
|
|
|
13
13
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
14
14
|
|
|
15
|
+
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
15
16
|
var virtualCore = require('@tanstack/virtual-core');
|
|
16
17
|
var store = require('svelte/store');
|
|
17
18
|
|
|
18
19
|
function createVirtualizerBase(options) {
|
|
19
|
-
|
|
20
|
-
return store.readable(virtualizer, set
|
|
21
|
-
|
|
20
|
+
var virtualizer = new virtualCore.Virtualizer(options);
|
|
21
|
+
return store.readable(virtualizer, function (set) {
|
|
22
|
+
var cleanup = virtualizer._didMount();
|
|
22
23
|
virtualizer._willUpdate();
|
|
23
|
-
virtualizer.setOptions({
|
|
24
|
-
|
|
25
|
-
onChange: instance => {
|
|
24
|
+
virtualizer.setOptions(_rollupPluginBabelHelpers["extends"]({}, options, {
|
|
25
|
+
onChange: function onChange(instance) {
|
|
26
26
|
set(instance);
|
|
27
27
|
options.onChange == null ? void 0 : options.onChange(instance);
|
|
28
28
|
}
|
|
29
|
-
});
|
|
30
|
-
return ()
|
|
29
|
+
}));
|
|
30
|
+
return function () {
|
|
31
|
+
return cleanup();
|
|
32
|
+
};
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
35
|
function createVirtualizer(options) {
|
|
34
|
-
return createVirtualizerBase({
|
|
36
|
+
return createVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
35
37
|
observeElementRect: virtualCore.observeElementRect,
|
|
36
38
|
observeElementOffset: virtualCore.observeElementOffset,
|
|
37
|
-
scrollToFn: virtualCore.elementScroll
|
|
38
|
-
|
|
39
|
-
});
|
|
39
|
+
scrollToFn: virtualCore.elementScroll
|
|
40
|
+
}, options));
|
|
40
41
|
}
|
|
41
42
|
function createWindowVirtualizer(options) {
|
|
42
|
-
return createVirtualizerBase({
|
|
43
|
-
getScrollElement: ()
|
|
43
|
+
return createVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
44
|
+
getScrollElement: function getScrollElement() {
|
|
45
|
+
return typeof window !== 'undefined' ? window : null;
|
|
46
|
+
},
|
|
44
47
|
observeElementRect: virtualCore.observeWindowRect,
|
|
45
48
|
observeElementOffset: virtualCore.observeWindowOffset,
|
|
46
|
-
scrollToFn: virtualCore.windowScroll
|
|
47
|
-
|
|
48
|
-
});
|
|
49
|
+
scrollToFn: virtualCore.windowScroll
|
|
50
|
+
}, options));
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
exports.createVirtualizer = createVirtualizer;
|
package/build/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","_extends","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;;AAeA,SAASA,qBAAqB,CAI5BC,OAAyD,EACJ;AACrD,EAAA,IAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACF,OAAO,CAAC,CAAA;AAE5C,EAAA,OAAOG,cAAQ,CAACF,WAAW,EAAE,UAACG,GAAG,EAAK;AACpC,IAAA,IAAMC,OAAO,GAAGJ,WAAW,CAACK,SAAS,EAAE,CAAA;IACvCL,WAAW,CAACM,WAAW,EAAE,CAAA;IACzBN,WAAW,CAACO,UAAU,CAAAC,oCAAA,CAAA,EAAA,EACjBT,OAAO,EAAA;MACVU,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAmD,EAAK;QACjEP,GAAG,CAACO,QAAQ,CAAC,CAAA;QACbX,OAAO,CAACU,QAAQ,IAAhBV,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACU,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEF,OAAO,YAAA;AAAA,MAAA,OAAMN,OAAO,EAAE,CAAA;AAAA,KAAA,CAAA;AACxB,GAAC,CAAC,CAAA;AACJ,CAAA;AAEO,SAASO,iBAAiB,CAI/BZ,OAGC,EACoD;AACrD,EAAA,OAAOD,qBAAqB,CAAAU,oCAAA,CAAA;AAC1BI,IAAAA,kBAAkB,EAAEA,8BAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,gCAAoB;AAC1CC,IAAAA,UAAU,EAAEC,yBAAAA;AAAa,GAAA,EACtBhB,OAAO,CACV,CAAA,CAAA;AACJ,CAAA;AAEO,SAASiB,uBAAuB,CACrCjB,OAMC,EAC4C;AAC7C,EAAA,OAAOD,qBAAqB,CAAAU,oCAAA,CAAA;AAC1BS,IAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,MAAA,OAAO,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAG,IAAK,CAAA;KAAC;AACxEN,IAAAA,kBAAkB,EAAEO,6BAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,+BAAmB;AACzCN,IAAAA,UAAU,EAAEO,wBAAAA;AAAY,GAAA,EACrBtB,OAAO,CACV,CAAA,CAAA;AACJ;;;;;;;;;;;"}
|
package/build/lib/index.mjs
CHANGED
|
@@ -8,41 +8,43 @@
|
|
|
8
8
|
*
|
|
9
9
|
* @license MIT
|
|
10
10
|
*/
|
|
11
|
+
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.mjs';
|
|
11
12
|
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
12
13
|
export * from '@tanstack/virtual-core';
|
|
13
14
|
import { readable } from 'svelte/store';
|
|
14
15
|
|
|
15
16
|
function createVirtualizerBase(options) {
|
|
16
|
-
|
|
17
|
-
return readable(virtualizer, set
|
|
18
|
-
|
|
17
|
+
var virtualizer = new Virtualizer(options);
|
|
18
|
+
return readable(virtualizer, function (set) {
|
|
19
|
+
var cleanup = virtualizer._didMount();
|
|
19
20
|
virtualizer._willUpdate();
|
|
20
|
-
virtualizer.setOptions({
|
|
21
|
-
|
|
22
|
-
onChange: instance => {
|
|
21
|
+
virtualizer.setOptions(_extends({}, options, {
|
|
22
|
+
onChange: function onChange(instance) {
|
|
23
23
|
set(instance);
|
|
24
24
|
options.onChange == null ? void 0 : options.onChange(instance);
|
|
25
25
|
}
|
|
26
|
-
});
|
|
27
|
-
return ()
|
|
26
|
+
}));
|
|
27
|
+
return function () {
|
|
28
|
+
return cleanup();
|
|
29
|
+
};
|
|
28
30
|
});
|
|
29
31
|
}
|
|
30
32
|
function createVirtualizer(options) {
|
|
31
|
-
return createVirtualizerBase({
|
|
33
|
+
return createVirtualizerBase(_extends({
|
|
32
34
|
observeElementRect: observeElementRect,
|
|
33
35
|
observeElementOffset: observeElementOffset,
|
|
34
|
-
scrollToFn: elementScroll
|
|
35
|
-
|
|
36
|
-
});
|
|
36
|
+
scrollToFn: elementScroll
|
|
37
|
+
}, options));
|
|
37
38
|
}
|
|
38
39
|
function createWindowVirtualizer(options) {
|
|
39
|
-
return createVirtualizerBase({
|
|
40
|
-
getScrollElement: ()
|
|
40
|
+
return createVirtualizerBase(_extends({
|
|
41
|
+
getScrollElement: function getScrollElement() {
|
|
42
|
+
return typeof window !== 'undefined' ? window : null;
|
|
43
|
+
},
|
|
41
44
|
observeElementRect: observeWindowRect,
|
|
42
45
|
observeElementOffset: observeWindowOffset,
|
|
43
|
-
scrollToFn: windowScroll
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
+
scrollToFn: windowScroll
|
|
47
|
+
}, options));
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
export { createVirtualizer, createWindowVirtualizer };
|
package/build/lib/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import {\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\nimport { readable, Readable } from 'svelte/store'\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(options)\n\n return readable(virtualizer, (set) => {\n const cleanup = virtualizer._didMount()\n virtualizer._willUpdate()\n virtualizer.setOptions({\n ...options,\n onChange: (instance: Virtualizer<TScrollElement, TItemElement>) => {\n set(instance)\n options.onChange?.(instance)\n },\n })\n\n return () => cleanup()\n })\n}\n\nexport function createVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >,\n): Readable<Virtualizer<TScrollElement, TItemElement>> {\n return createVirtualizerBase<TScrollElement, TItemElement>({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...options,\n })\n}\n\nexport function createWindowVirtualizer<TItemElement extends Element>(\n options: PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'getScrollElement'\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n >,\n): Readable<Virtualizer<Window, TItemElement>> {\n return createVirtualizerBase<Window, TItemElement>({\n getScrollElement: () => (typeof window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...options,\n })\n}\n"],"names":["createVirtualizerBase","options","virtualizer","Virtualizer","readable","set","cleanup","_didMount","_willUpdate","setOptions","onChange","instance","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;AAeA,SAASA,qBAAqB,CAI5BC,OAAyD,EACJ;AACrD,EAAA,IAAMC,WAAW,GAAG,IAAIC,WAAW,CAACF,OAAO,CAAC,CAAA;AAE5C,EAAA,OAAOG,QAAQ,CAACF,WAAW,EAAE,UAACG,GAAG,EAAK;AACpC,IAAA,IAAMC,OAAO,GAAGJ,WAAW,CAACK,SAAS,EAAE,CAAA;IACvCL,WAAW,CAACM,WAAW,EAAE,CAAA;IACzBN,WAAW,CAACO,UAAU,CAAA,QAAA,CAAA,EAAA,EACjBR,OAAO,EAAA;MACVS,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAmD,EAAK;QACjEN,GAAG,CAACM,QAAQ,CAAC,CAAA;QACbV,OAAO,CAACS,QAAQ,IAAhBT,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACS,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEF,OAAO,YAAA;AAAA,MAAA,OAAML,OAAO,EAAE,CAAA;AAAA,KAAA,CAAA;AACxB,GAAC,CAAC,CAAA;AACJ,CAAA;AAEO,SAASM,iBAAiB,CAI/BX,OAGC,EACoD;AACrD,EAAA,OAAOD,qBAAqB,CAAA,QAAA,CAAA;AAC1Ba,IAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,IAAAA,UAAU,EAAEC,aAAAA;AAAa,GAAA,EACtBf,OAAO,CACV,CAAA,CAAA;AACJ,CAAA;AAEO,SAASgB,uBAAuB,CACrChB,OAMC,EAC4C;AAC7C,EAAA,OAAOD,qBAAqB,CAAA,QAAA,CAAA;AAC1BkB,IAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,MAAA,OAAO,OAAOC,MAAM,KAAK,WAAW,GAAGA,MAAM,GAAG,IAAK,CAAA;KAAC;AACxEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAAA;AAAY,GAAA,EACrBrB,OAAO,CACV,CAAA,CAAA;AACJ;;;;"}
|