@tanstack/svelte-virtual 3.0.4 → 3.1.3
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/index.js +46 -0
- package/package.json +33 -27
- 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 -62
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js +0 -72
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -62
- package/build/lib/index.mjs.map +0 -1
- package/build/umd/index.development.js +0 -825
- 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 → dist}/index.d.ts +0 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { elementScroll, observeElementOffset, observeElementRect, observeWindowOffset, observeWindowRect, Virtualizer, windowScroll, } from '@tanstack/virtual-core';
|
|
2
|
+
export * from '@tanstack/virtual-core';
|
|
3
|
+
import { derived, writable } from 'svelte/store';
|
|
4
|
+
function createVirtualizerBase(initialOptions) {
|
|
5
|
+
const virtualizer = new Virtualizer(initialOptions);
|
|
6
|
+
const originalSetOptions = virtualizer.setOptions;
|
|
7
|
+
let virtualizerWritable;
|
|
8
|
+
const setOptions = (options) => {
|
|
9
|
+
const resolvedOptions = {
|
|
10
|
+
...virtualizer.options,
|
|
11
|
+
...options,
|
|
12
|
+
onChange: options.onChange,
|
|
13
|
+
};
|
|
14
|
+
originalSetOptions({
|
|
15
|
+
...resolvedOptions,
|
|
16
|
+
onChange: (instance, sync) => {
|
|
17
|
+
virtualizerWritable.set(instance);
|
|
18
|
+
resolvedOptions.onChange?.(instance, sync);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
virtualizer._willUpdate();
|
|
22
|
+
};
|
|
23
|
+
virtualizerWritable = writable(virtualizer, () => {
|
|
24
|
+
setOptions(initialOptions);
|
|
25
|
+
return virtualizer._didMount();
|
|
26
|
+
});
|
|
27
|
+
return derived(virtualizerWritable, (instance) => Object.assign(instance, { setOptions }));
|
|
28
|
+
}
|
|
29
|
+
export function createVirtualizer(options) {
|
|
30
|
+
return createVirtualizerBase({
|
|
31
|
+
observeElementRect: observeElementRect,
|
|
32
|
+
observeElementOffset: observeElementOffset,
|
|
33
|
+
scrollToFn: elementScroll,
|
|
34
|
+
...options,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function createWindowVirtualizer(options) {
|
|
38
|
+
return createVirtualizerBase({
|
|
39
|
+
getScrollElement: () => (typeof document !== 'undefined' ? window : null),
|
|
40
|
+
observeElementRect: observeWindowRect,
|
|
41
|
+
observeElementOffset: observeWindowOffset,
|
|
42
|
+
scrollToFn: windowScroll,
|
|
43
|
+
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined,
|
|
44
|
+
...options,
|
|
45
|
+
});
|
|
46
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,60 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/svelte-virtual",
|
|
3
|
-
"
|
|
4
|
-
"version": "3.0.4",
|
|
3
|
+
"version": "3.1.3",
|
|
5
4
|
"description": "Headless UI for virtualizing scrollable elements in Svelte",
|
|
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
|
-
"svelte",
|
|
20
|
-
"virtual",
|
|
21
|
-
"virtual-core",
|
|
22
|
-
"datagrid"
|
|
23
|
-
],
|
|
11
|
+
"homepage": "https://github.com/tanstack/virtual#readme",
|
|
24
12
|
"funding": {
|
|
25
13
|
"type": "github",
|
|
26
14
|
"url": "https://github.com/sponsors/tannerlinsley"
|
|
27
15
|
},
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"module": "
|
|
16
|
+
"type": "module",
|
|
17
|
+
"types": "dist/index.d.ts",
|
|
18
|
+
"module": "dist/index.js",
|
|
19
|
+
"svelte": "./dist/index.js",
|
|
31
20
|
"exports": {
|
|
32
21
|
".": {
|
|
33
|
-
"types": "./
|
|
34
|
-
"
|
|
35
|
-
"
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"svelte": "./dist/index.js",
|
|
24
|
+
"import": "./dist/index.js"
|
|
36
25
|
},
|
|
37
26
|
"./package.json": "./package.json"
|
|
38
27
|
},
|
|
39
28
|
"sideEffects": false,
|
|
29
|
+
"keywords": [
|
|
30
|
+
"react",
|
|
31
|
+
"vue",
|
|
32
|
+
"solid",
|
|
33
|
+
"svelte",
|
|
34
|
+
"virtual",
|
|
35
|
+
"virtual-core",
|
|
36
|
+
"datagrid"
|
|
37
|
+
],
|
|
40
38
|
"files": [
|
|
41
|
-
"
|
|
42
|
-
"build/umd/*",
|
|
39
|
+
"dist",
|
|
43
40
|
"src"
|
|
44
41
|
],
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"svelte": "^4.2.2"
|
|
47
|
-
},
|
|
48
42
|
"dependencies": {
|
|
49
|
-
"@tanstack/virtual-core": "3.
|
|
43
|
+
"@tanstack/virtual-core": "3.1.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@sveltejs/package": "^2.2.6",
|
|
47
|
+
"@sveltejs/vite-plugin-svelte": "^3.0.2",
|
|
48
|
+
"svelte": "^4.2.2",
|
|
49
|
+
"svelte-check": "^3.4.6"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"svelte": "^3.48.0 || ^4.0.0"
|
|
53
|
+
},
|
|
54
|
+
"scripts": {
|
|
55
|
+
"clean": "rimraf ./dist && rimraf ./coverage",
|
|
56
|
+
"test:types": "svelte-check --tsconfig ./tsconfig.json",
|
|
57
|
+
"test:build": "publint --strict",
|
|
58
|
+
"build": "svelte-package --input ./src --output ./dist"
|
|
53
59
|
}
|
|
54
60
|
}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/build/lib/index.esm.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
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
|
-
import { extends as _extends } from './_virtual/_rollupPluginBabelHelpers.esm.js';
|
|
12
|
-
import { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
13
|
-
export * from '@tanstack/virtual-core';
|
|
14
|
-
import { writable, derived } from 'svelte/store';
|
|
15
|
-
|
|
16
|
-
function createVirtualizerBase(initialOptions) {
|
|
17
|
-
var virtualizer = new Virtualizer(initialOptions);
|
|
18
|
-
var originalSetOptions = virtualizer.setOptions;
|
|
19
|
-
var virtualizerWritable;
|
|
20
|
-
var setOptions = function setOptions(options) {
|
|
21
|
-
var resolvedOptions = _extends({}, virtualizer.options, options, {
|
|
22
|
-
onChange: options.onChange
|
|
23
|
-
});
|
|
24
|
-
originalSetOptions(_extends({}, resolvedOptions, {
|
|
25
|
-
onChange: function onChange(instance, sync) {
|
|
26
|
-
virtualizerWritable.set(instance);
|
|
27
|
-
resolvedOptions.onChange == null || resolvedOptions.onChange(instance, sync);
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
virtualizer._willUpdate();
|
|
31
|
-
};
|
|
32
|
-
virtualizerWritable = writable(virtualizer, function () {
|
|
33
|
-
setOptions(initialOptions);
|
|
34
|
-
return virtualizer._didMount();
|
|
35
|
-
});
|
|
36
|
-
return derived(virtualizerWritable, function (instance) {
|
|
37
|
-
return Object.assign(instance, {
|
|
38
|
-
setOptions: setOptions
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function createVirtualizer(options) {
|
|
43
|
-
return createVirtualizerBase(_extends({
|
|
44
|
-
observeElementRect: observeElementRect,
|
|
45
|
-
observeElementOffset: observeElementOffset,
|
|
46
|
-
scrollToFn: elementScroll
|
|
47
|
-
}, options));
|
|
48
|
-
}
|
|
49
|
-
function createWindowVirtualizer(options) {
|
|
50
|
-
return createVirtualizerBase(_extends({
|
|
51
|
-
getScrollElement: function getScrollElement() {
|
|
52
|
-
return typeof document !== 'undefined' ? window : null;
|
|
53
|
-
},
|
|
54
|
-
observeElementRect: observeWindowRect,
|
|
55
|
-
observeElementOffset: observeWindowOffset,
|
|
56
|
-
scrollToFn: windowScroll,
|
|
57
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
58
|
-
}, options));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { createVirtualizer, createWindowVirtualizer };
|
|
62
|
-
//# sourceMappingURL=index.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { derived, Readable, writable, Writable } from 'svelte/store'\n\nexport type SvelteVirtualizer<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n> = Omit<Virtualizer<TScrollElement, TItemElement>, 'setOptions'> & {\n setOptions: (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => void\n}\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n initialOptions: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<SvelteVirtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(initialOptions)\n const originalSetOptions = virtualizer.setOptions\n\n let virtualizerWritable: Writable<Virtualizer<TScrollElement, TItemElement>>\n\n const setOptions = (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => {\n const resolvedOptions = {\n ...virtualizer.options,\n ...options,\n onChange: options.onChange,\n }\n originalSetOptions({\n ...resolvedOptions,\n onChange: (\n instance: Virtualizer<TScrollElement, TItemElement>,\n sync: boolean,\n ) => {\n virtualizerWritable.set(instance)\n resolvedOptions.onChange?.(instance, sync)\n },\n })\n virtualizer._willUpdate()\n }\n\n virtualizerWritable = writable(virtualizer, () => {\n setOptions(initialOptions)\n return virtualizer._didMount()\n })\n\n return derived(virtualizerWritable, (instance) =>\n Object.assign(instance, { setOptions }),\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<SvelteVirtualizer<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<SvelteVirtualizer<Window, TItemElement>> {\n return createVirtualizerBase<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":["createVirtualizerBase","initialOptions","virtualizer","Virtualizer","originalSetOptions","setOptions","virtualizerWritable","options","resolvedOptions","_extends","onChange","instance","sync","set","_willUpdate","writable","_didMount","derived","Object","assign","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","document","window","observeWindowRect","observeWindowOffset","windowScroll","initialOffset","scrollY","undefined"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAASA,qBAAqBA,CAI5BC,cAAgE,EACL;AAC3D,EAAA,IAAMC,WAAW,GAAG,IAAIC,WAAW,CAACF,cAAc,CAAC,CAAA;AACnD,EAAA,IAAMG,kBAAkB,GAAGF,WAAW,CAACG,UAAU,CAAA;AAEjD,EAAA,IAAIC,mBAAwE,CAAA;AAE5E,EAAA,IAAMD,UAAU,GAAG,SAAbA,UAAUA,CACdE,OAAkE,EAC/D;IACH,IAAMC,eAAe,GAAAC,QAAA,CAAA,EAAA,EAChBP,WAAW,CAACK,OAAO,EACnBA,OAAO,EAAA;MACVG,QAAQ,EAAEH,OAAO,CAACG,QAAAA;KACnB,CAAA,CAAA;IACDN,kBAAkB,CAAAK,QAAA,CAAA,EAAA,EACbD,eAAe,EAAA;AAClBE,MAAAA,QAAQ,EAAE,SAAAA,QAAAA,CACRC,QAAmD,EACnDC,IAAa,EACV;AACHN,QAAAA,mBAAmB,CAACO,GAAG,CAACF,QAAQ,CAAC,CAAA;QACjCH,eAAe,CAACE,QAAQ,IAAA,IAAA,IAAxBF,eAAe,CAACE,QAAQ,CAAGC,QAAQ,EAAEC,IAAI,CA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-1,72 +0,0 @@
|
|
|
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
|
-
var _rollupPluginBabelHelpers = require('./_virtual/_rollupPluginBabelHelpers.js');
|
|
16
|
-
var virtualCore = require('@tanstack/virtual-core');
|
|
17
|
-
var store = require('svelte/store');
|
|
18
|
-
|
|
19
|
-
function createVirtualizerBase(initialOptions) {
|
|
20
|
-
var virtualizer = new virtualCore.Virtualizer(initialOptions);
|
|
21
|
-
var originalSetOptions = virtualizer.setOptions;
|
|
22
|
-
var virtualizerWritable;
|
|
23
|
-
var setOptions = function setOptions(options) {
|
|
24
|
-
var resolvedOptions = _rollupPluginBabelHelpers["extends"]({}, virtualizer.options, options, {
|
|
25
|
-
onChange: options.onChange
|
|
26
|
-
});
|
|
27
|
-
originalSetOptions(_rollupPluginBabelHelpers["extends"]({}, resolvedOptions, {
|
|
28
|
-
onChange: function onChange(instance, sync) {
|
|
29
|
-
virtualizerWritable.set(instance);
|
|
30
|
-
resolvedOptions.onChange == null || resolvedOptions.onChange(instance, sync);
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
virtualizer._willUpdate();
|
|
34
|
-
};
|
|
35
|
-
virtualizerWritable = store.writable(virtualizer, function () {
|
|
36
|
-
setOptions(initialOptions);
|
|
37
|
-
return virtualizer._didMount();
|
|
38
|
-
});
|
|
39
|
-
return store.derived(virtualizerWritable, function (instance) {
|
|
40
|
-
return Object.assign(instance, {
|
|
41
|
-
setOptions: setOptions
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
function createVirtualizer(options) {
|
|
46
|
-
return createVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
47
|
-
observeElementRect: virtualCore.observeElementRect,
|
|
48
|
-
observeElementOffset: virtualCore.observeElementOffset,
|
|
49
|
-
scrollToFn: virtualCore.elementScroll
|
|
50
|
-
}, options));
|
|
51
|
-
}
|
|
52
|
-
function createWindowVirtualizer(options) {
|
|
53
|
-
return createVirtualizerBase(_rollupPluginBabelHelpers["extends"]({
|
|
54
|
-
getScrollElement: function getScrollElement() {
|
|
55
|
-
return typeof document !== 'undefined' ? window : null;
|
|
56
|
-
},
|
|
57
|
-
observeElementRect: virtualCore.observeWindowRect,
|
|
58
|
-
observeElementOffset: virtualCore.observeWindowOffset,
|
|
59
|
-
scrollToFn: virtualCore.windowScroll,
|
|
60
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
61
|
-
}, options));
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
exports.createVirtualizer = createVirtualizer;
|
|
65
|
-
exports.createWindowVirtualizer = createWindowVirtualizer;
|
|
66
|
-
Object.keys(virtualCore).forEach(function (k) {
|
|
67
|
-
if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
|
|
68
|
-
enumerable: true,
|
|
69
|
-
get: function () { return virtualCore[k]; }
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
//# sourceMappingURL=index.js.map
|
package/build/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 { derived, Readable, writable, Writable } from 'svelte/store'\n\nexport type SvelteVirtualizer<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n> = Omit<Virtualizer<TScrollElement, TItemElement>, 'setOptions'> & {\n setOptions: (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => void\n}\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n initialOptions: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<SvelteVirtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(initialOptions)\n const originalSetOptions = virtualizer.setOptions\n\n let virtualizerWritable: Writable<Virtualizer<TScrollElement, TItemElement>>\n\n const setOptions = (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => {\n const resolvedOptions = {\n ...virtualizer.options,\n ...options,\n onChange: options.onChange,\n }\n originalSetOptions({\n ...resolvedOptions,\n onChange: (\n instance: Virtualizer<TScrollElement, TItemElement>,\n sync: boolean,\n ) => {\n virtualizerWritable.set(instance)\n resolvedOptions.onChange?.(instance, sync)\n },\n })\n virtualizer._willUpdate()\n }\n\n virtualizerWritable = writable(virtualizer, () => {\n setOptions(initialOptions)\n return virtualizer._didMount()\n })\n\n return derived(virtualizerWritable, (instance) =>\n Object.assign(instance, { setOptions }),\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<SvelteVirtualizer<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<SvelteVirtualizer<Window, TItemElement>> {\n return createVirtualizerBase<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":["createVirtualizerBase","initialOptions","virtualizer","Virtualizer","originalSetOptions","setOptions","virtualizerWritable","options","resolvedOptions","_extends","onChange","instance","sync","set","_willUpdate","writable","_didMount","derived","Object","assign","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","document","window","observeWindowRect","observeWindowOffset","windowScroll","initialOffset","scrollY","undefined"],"mappings":";;;;;;;;;;;;;;;;;;AAwBA,SAASA,qBAAqBA,CAI5BC,cAAgE,EACL;AAC3D,EAAA,IAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACF,cAAc,CAAC,CAAA;AACnD,EAAA,IAAMG,kBAAkB,GAAGF,WAAW,CAACG,UAAU,CAAA;AAEjD,EAAA,IAAIC,mBAAwE,CAAA;AAE5E,EAAA,IAAMD,UAAU,GAAG,SAAbA,UAAUA,CACdE,OAAkE,EAC/D;IACH,IAAMC,eAAe,GAAAC,oCAAA,CAAA,EAAA,EAChBP,WAAW,CAACK,OAAO,EACnBA,OAAO,EAAA;MACVG,QAAQ,EAAEH,OAAO,CAACG,QAAAA;KACnB,CAAA,CAAA;IACDN,kBAAkB,CAAAK,oCAAA,CAAA,EAAA,EACbD,eAAe,EAAA;AAClBE,MAAAA,QAAQ,EAAE,SAAAA,QAAAA,CACRC,QAAmD,EACnDC,IAAa,EACV;AACHN,QAAAA,mBAAmB,CAACO,GAAG,CAACF,QAAQ,CAAC,CAAA;QACjCH,eAAe,CAACE,QAAQ,IAAA,IAAA,IAAxBF,eAAe,CAACE,QAAQ,CAAGC,QAAQ,EAAEC,IAAI,CAAC,CAAA;AAC5C,OAAA;AAAC,KAAA,CACF,CAAC,CAAA;IACFV,WAAW,CAACY,WAAW,EAAE,CAAA;GAC1B,CAAA;AAEDR,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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 { observeElementRect, observeElementOffset, elementScroll, observeWindowRect, observeWindowOffset, windowScroll, Virtualizer } from '@tanstack/virtual-core';
|
|
13
|
-
export * from '@tanstack/virtual-core';
|
|
14
|
-
import { writable, derived } from 'svelte/store';
|
|
15
|
-
|
|
16
|
-
function createVirtualizerBase(initialOptions) {
|
|
17
|
-
var virtualizer = new Virtualizer(initialOptions);
|
|
18
|
-
var originalSetOptions = virtualizer.setOptions;
|
|
19
|
-
var virtualizerWritable;
|
|
20
|
-
var setOptions = function setOptions(options) {
|
|
21
|
-
var resolvedOptions = _extends({}, virtualizer.options, options, {
|
|
22
|
-
onChange: options.onChange
|
|
23
|
-
});
|
|
24
|
-
originalSetOptions(_extends({}, resolvedOptions, {
|
|
25
|
-
onChange: function onChange(instance, sync) {
|
|
26
|
-
virtualizerWritable.set(instance);
|
|
27
|
-
resolvedOptions.onChange == null || resolvedOptions.onChange(instance, sync);
|
|
28
|
-
}
|
|
29
|
-
}));
|
|
30
|
-
virtualizer._willUpdate();
|
|
31
|
-
};
|
|
32
|
-
virtualizerWritable = writable(virtualizer, function () {
|
|
33
|
-
setOptions(initialOptions);
|
|
34
|
-
return virtualizer._didMount();
|
|
35
|
-
});
|
|
36
|
-
return derived(virtualizerWritable, function (instance) {
|
|
37
|
-
return Object.assign(instance, {
|
|
38
|
-
setOptions: setOptions
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function createVirtualizer(options) {
|
|
43
|
-
return createVirtualizerBase(_extends({
|
|
44
|
-
observeElementRect: observeElementRect,
|
|
45
|
-
observeElementOffset: observeElementOffset,
|
|
46
|
-
scrollToFn: elementScroll
|
|
47
|
-
}, options));
|
|
48
|
-
}
|
|
49
|
-
function createWindowVirtualizer(options) {
|
|
50
|
-
return createVirtualizerBase(_extends({
|
|
51
|
-
getScrollElement: function getScrollElement() {
|
|
52
|
-
return typeof document !== 'undefined' ? window : null;
|
|
53
|
-
},
|
|
54
|
-
observeElementRect: observeWindowRect,
|
|
55
|
-
observeElementOffset: observeWindowOffset,
|
|
56
|
-
scrollToFn: windowScroll,
|
|
57
|
-
initialOffset: typeof document !== 'undefined' ? window.scrollY : undefined
|
|
58
|
-
}, options));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { createVirtualizer, createWindowVirtualizer };
|
|
62
|
-
//# sourceMappingURL=index.mjs.map
|
package/build/lib/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 { derived, Readable, writable, Writable } from 'svelte/store'\n\nexport type SvelteVirtualizer<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n> = Omit<Virtualizer<TScrollElement, TItemElement>, 'setOptions'> & {\n setOptions: (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => void\n}\n\nfunction createVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n initialOptions: VirtualizerOptions<TScrollElement, TItemElement>,\n): Readable<SvelteVirtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(initialOptions)\n const originalSetOptions = virtualizer.setOptions\n\n let virtualizerWritable: Writable<Virtualizer<TScrollElement, TItemElement>>\n\n const setOptions = (\n options: Partial<VirtualizerOptions<TScrollElement, TItemElement>>,\n ) => {\n const resolvedOptions = {\n ...virtualizer.options,\n ...options,\n onChange: options.onChange,\n }\n originalSetOptions({\n ...resolvedOptions,\n onChange: (\n instance: Virtualizer<TScrollElement, TItemElement>,\n sync: boolean,\n ) => {\n virtualizerWritable.set(instance)\n resolvedOptions.onChange?.(instance, sync)\n },\n })\n virtualizer._willUpdate()\n }\n\n virtualizerWritable = writable(virtualizer, () => {\n setOptions(initialOptions)\n return virtualizer._didMount()\n })\n\n return derived(virtualizerWritable, (instance) =>\n Object.assign(instance, { setOptions }),\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<SvelteVirtualizer<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<SvelteVirtualizer<Window, TItemElement>> {\n return createVirtualizerBase<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":["createVirtualizerBase","initialOptions","virtualizer","Virtualizer","originalSetOptions","setOptions","virtualizerWritable","options","resolvedOptions","_extends","onChange","instance","sync","set","_willUpdate","writable","_didMount","derived","Object","assign","createVirtualizer","observeElementRect","observeElementOffset","scrollToFn","elementScroll","createWindowVirtualizer","getScrollElement","document","window","observeWindowRect","observeWindowOffset","windowScroll","initialOffset","scrollY","undefined"],"mappings":";;;;;;;;;;;;;;;AAwBA,SAASA,qBAAqBA,CAI5B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