@tanstack/vue-virtual 3.0.0-beta.29 → 3.0.0-beta.32

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.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * vue-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
+ * vue-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
+ * vue-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":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -8,28 +8,32 @@
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
  import { computed, unref, shallowRef, watch, triggerRef, onScopeDispose } from 'vue';
13
14
 
14
15
  function useVirtualizerBase(options) {
15
- const virtualizer = new Virtualizer(unref(options));
16
- const state = shallowRef(virtualizer);
17
- const cleanup = virtualizer._didMount();
18
- watch(() => unref(options).getScrollElement(), el => {
16
+ var virtualizer = new Virtualizer(unref(options));
17
+ var state = shallowRef(virtualizer);
18
+ var cleanup = virtualizer._didMount();
19
+ watch(function () {
20
+ return unref(options).getScrollElement();
21
+ }, function (el) {
19
22
  if (el) {
20
23
  virtualizer._willUpdate();
21
24
  }
22
25
  }, {
23
26
  immediate: true
24
27
  });
25
- watch(() => unref(options), options => {
26
- virtualizer.setOptions({
27
- ...options,
28
- onChange: instance => {
28
+ watch(function () {
29
+ return unref(options);
30
+ }, function (options) {
31
+ virtualizer.setOptions(_extends({}, options, {
32
+ onChange: function onChange(instance) {
29
33
  triggerRef(state);
30
34
  options.onChange == null ? void 0 : options.onChange(instance);
31
35
  }
32
- });
36
+ }));
33
37
  virtualizer._willUpdate();
34
38
  }, {
35
39
  immediate: true
@@ -38,22 +42,26 @@ function useVirtualizerBase(options) {
38
42
  return state;
39
43
  }
40
44
  function useVirtualizer(options) {
41
- return useVirtualizerBase(computed(() => ({
42
- observeElementRect: observeElementRect,
43
- observeElementOffset: observeElementOffset,
44
- scrollToFn: elementScroll,
45
- ...unref(options)
46
- })));
45
+ return useVirtualizerBase(computed(function () {
46
+ return _extends({
47
+ observeElementRect: observeElementRect,
48
+ observeElementOffset: observeElementOffset,
49
+ scrollToFn: elementScroll
50
+ }, unref(options));
51
+ }));
47
52
  }
48
53
  function useWindowVirtualizer(options) {
49
- return useVirtualizerBase(computed(() => ({
50
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
- getScrollElement: () => typeof Window !== 'undefined' ? window : null,
52
- observeElementRect: observeWindowRect,
53
- observeElementOffset: observeWindowOffset,
54
- scrollToFn: windowScroll,
55
- ...unref(options)
56
- })));
54
+ return useVirtualizerBase(computed(function () {
55
+ return _extends({
56
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
+ getScrollElement: function getScrollElement() {
58
+ return typeof Window !== 'undefined' ? window : null;
59
+ },
60
+ observeElementRect: observeWindowRect,
61
+ observeElementOffset: observeWindowOffset,
62
+ scrollToFn: windowScroll
63
+ }, unref(options));
64
+ }));
57
65
  }
58
66
 
59
67
  export { useVirtualizer, useWindowVirtualizer };
@@ -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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAACC,KAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,MAAMI,KAAK,GAAGC,UAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,MAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;EAEvCC,KAAK,CACH,MAAML,KAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,EACtCC,EAAE,IAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDJ,KAAK,CACH,MAAML,KAAK,CAACH,OAAO,CAAC,EACnBA,OAAO,IAAK;IACXC,WAAW,CAACY,UAAU,CAAC;AACrB,MAAA,GAAGb,OAAO;MACVc,QAAQ,EAAGC,QAAQ,IAAK;QACtBC,UAAU,CAACZ,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;AACF,KAAC,CAAC,CAAA;IAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDK,cAAc,CAACX,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;AAChD,EAAA,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,OAAO;AACdC,IAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,IAAAA,UAAU,EAAEC,aAAa;IACzB,GAAGpB,KAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;AACxC,EAAA,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,OAAO;AACd;IACAV,gBAAgB,EAAE,MAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAM;AACxEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAY;IACxB,GAAG1B,KAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH;;;;"}
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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,IAAMC,WAAW,GAAG,IAAIC,WAAW,CAACC,KAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,IAAMI,KAAK,GAAGC,UAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,IAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;AAEvCC,EAAAA,KAAK,CACH,YAAA;AAAA,IAAA,OAAML,KAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,CAAA;GACvC,EAAA,UAACC,EAAE,EAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;AAEDJ,EAAAA,KAAK,CACH,YAAA;IAAA,OAAML,KAAK,CAACH,OAAO,CAAC,CAAA;GACpB,EAAA,UAACA,OAAO,EAAK;IACXC,WAAW,CAACY,UAAU,CAAA,QAAA,CAAA,EAAA,EACjBb,OAAO,EAAA;MACVc,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;QACtBC,UAAU,CAACZ,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDK,cAAc,CAACX,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;EAChD,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,YAAA;AAAA,IAAA,OAAA,QAAA,CAAA;AACPC,MAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,MAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,MAAAA,UAAU,EAAEC,aAAAA;KACTpB,EAAAA,KAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;EACxC,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,YAAA;AAAA,IAAA,OAAA,QAAA,CAAA;AACP;AACAV,MAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,QAAA,OAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAK,CAAA;OAAC;AACxEN,MAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,MAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,MAAAA,UAAU,EAAEO,YAAAA;KACT1B,EAAAA,KAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH;;;;"}
@@ -12,28 +12,32 @@
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 vue = require('vue');
17
18
 
18
19
  function useVirtualizerBase(options) {
19
- const virtualizer = new virtualCore.Virtualizer(vue.unref(options));
20
- const state = vue.shallowRef(virtualizer);
21
- const cleanup = virtualizer._didMount();
22
- vue.watch(() => vue.unref(options).getScrollElement(), el => {
20
+ var virtualizer = new virtualCore.Virtualizer(vue.unref(options));
21
+ var state = vue.shallowRef(virtualizer);
22
+ var cleanup = virtualizer._didMount();
23
+ vue.watch(function () {
24
+ return vue.unref(options).getScrollElement();
25
+ }, function (el) {
23
26
  if (el) {
24
27
  virtualizer._willUpdate();
25
28
  }
26
29
  }, {
27
30
  immediate: true
28
31
  });
29
- vue.watch(() => vue.unref(options), options => {
30
- virtualizer.setOptions({
31
- ...options,
32
- onChange: instance => {
32
+ vue.watch(function () {
33
+ return vue.unref(options);
34
+ }, function (options) {
35
+ virtualizer.setOptions(_rollupPluginBabelHelpers["extends"]({}, options, {
36
+ onChange: function onChange(instance) {
33
37
  vue.triggerRef(state);
34
38
  options.onChange == null ? void 0 : options.onChange(instance);
35
39
  }
36
- });
40
+ }));
37
41
  virtualizer._willUpdate();
38
42
  }, {
39
43
  immediate: true
@@ -42,22 +46,26 @@ function useVirtualizerBase(options) {
42
46
  return state;
43
47
  }
44
48
  function useVirtualizer(options) {
45
- return useVirtualizerBase(vue.computed(() => ({
46
- observeElementRect: virtualCore.observeElementRect,
47
- observeElementOffset: virtualCore.observeElementOffset,
48
- scrollToFn: virtualCore.elementScroll,
49
- ...vue.unref(options)
50
- })));
49
+ return useVirtualizerBase(vue.computed(function () {
50
+ return _rollupPluginBabelHelpers["extends"]({
51
+ observeElementRect: virtualCore.observeElementRect,
52
+ observeElementOffset: virtualCore.observeElementOffset,
53
+ scrollToFn: virtualCore.elementScroll
54
+ }, vue.unref(options));
55
+ }));
51
56
  }
52
57
  function useWindowVirtualizer(options) {
53
- return useVirtualizerBase(vue.computed(() => ({
54
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
55
- getScrollElement: () => typeof Window !== 'undefined' ? window : null,
56
- observeElementRect: virtualCore.observeWindowRect,
57
- observeElementOffset: virtualCore.observeWindowOffset,
58
- scrollToFn: virtualCore.windowScroll,
59
- ...vue.unref(options)
60
- })));
58
+ return useVirtualizerBase(vue.computed(function () {
59
+ return _rollupPluginBabelHelpers["extends"]({
60
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61
+ getScrollElement: function getScrollElement() {
62
+ return typeof Window !== 'undefined' ? window : null;
63
+ },
64
+ observeElementRect: virtualCore.observeWindowRect,
65
+ observeElementOffset: virtualCore.observeWindowOffset,
66
+ scrollToFn: virtualCore.windowScroll
67
+ }, vue.unref(options));
68
+ }));
61
69
  }
62
70
 
63
71
  exports.useVirtualizer = useVirtualizer;
@@ -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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,MAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACC,SAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,MAAMI,KAAK,GAAGC,cAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,MAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;EAEvCC,SAAK,CACH,MAAML,SAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,EACtCC,EAAE,IAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDJ,SAAK,CACH,MAAML,SAAK,CAACH,OAAO,CAAC,EACnBA,OAAO,IAAK;IACXC,WAAW,CAACY,UAAU,CAAC;AACrB,MAAA,GAAGb,OAAO;MACVc,QAAQ,EAAGC,QAAQ,IAAK;QACtBC,cAAU,CAACZ,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;AACF,KAAC,CAAC,CAAA;IAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDK,kBAAc,CAACX,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;AAChD,EAAA,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,OAAO;AACdC,IAAAA,kBAAkB,EAAEA,8BAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,gCAAoB;AAC1CC,IAAAA,UAAU,EAAEC,yBAAa;IACzB,GAAGpB,SAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;AACxC,EAAA,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,OAAO;AACd;IACAV,gBAAgB,EAAE,MAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAM;AACxEN,IAAAA,kBAAkB,EAAEO,6BAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,+BAAmB;AACzCN,IAAAA,UAAU,EAAEO,wBAAY;IACxB,GAAG1B,SAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH;;;;;"}
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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","_extends","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,IAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACC,SAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,IAAMI,KAAK,GAAGC,cAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,IAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;AAEvCC,EAAAA,SAAK,CACH,YAAA;AAAA,IAAA,OAAML,SAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,CAAA;GACvC,EAAA,UAACC,EAAE,EAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;AAEDJ,EAAAA,SAAK,CACH,YAAA;IAAA,OAAML,SAAK,CAACH,OAAO,CAAC,CAAA;GACpB,EAAA,UAACA,OAAO,EAAK;IACXC,WAAW,CAACY,UAAU,CAAAC,oCAAA,CAAA,EAAA,EACjBd,OAAO,EAAA;MACVe,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;QACtBC,cAAU,CAACb,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACe,QAAQ,IAAhBf,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACe,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEFf,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDM,kBAAc,CAACZ,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASe,cAAc,CAI5BnB,OAKC,EAC+C;EAChD,OAAOD,kBAAkB,CACvBqB,YAAQ,CAAC,YAAA;AAAA,IAAA,OAAAN,oCAAA,CAAA;AACPO,MAAAA,kBAAkB,EAAEA,8BAAkB;AACtCC,MAAAA,oBAAoB,EAAEA,gCAAoB;AAC1CC,MAAAA,UAAU,EAAEC,yBAAAA;KACTrB,EAAAA,SAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASyB,oBAAoB,CAClCzB,OAQC,EACuC;EACxC,OAAOD,kBAAkB,CACvBqB,YAAQ,CAAC,YAAA;AAAA,IAAA,OAAAN,oCAAA,CAAA;AACP;AACAL,MAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,QAAA,OAAO,OAAOiB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAK,CAAA;OAAC;AACxEN,MAAAA,kBAAkB,EAAEO,6BAAiB;AACrCN,MAAAA,oBAAoB,EAAEO,+BAAmB;AACzCN,MAAAA,UAAU,EAAEO,wBAAAA;KACT3B,EAAAA,SAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH;;;;;"}
@@ -8,28 +8,32 @@
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
  import { computed, unref, shallowRef, watch, triggerRef, onScopeDispose } from 'vue';
13
14
 
14
15
  function useVirtualizerBase(options) {
15
- const virtualizer = new Virtualizer(unref(options));
16
- const state = shallowRef(virtualizer);
17
- const cleanup = virtualizer._didMount();
18
- watch(() => unref(options).getScrollElement(), el => {
16
+ var virtualizer = new Virtualizer(unref(options));
17
+ var state = shallowRef(virtualizer);
18
+ var cleanup = virtualizer._didMount();
19
+ watch(function () {
20
+ return unref(options).getScrollElement();
21
+ }, function (el) {
19
22
  if (el) {
20
23
  virtualizer._willUpdate();
21
24
  }
22
25
  }, {
23
26
  immediate: true
24
27
  });
25
- watch(() => unref(options), options => {
26
- virtualizer.setOptions({
27
- ...options,
28
- onChange: instance => {
28
+ watch(function () {
29
+ return unref(options);
30
+ }, function (options) {
31
+ virtualizer.setOptions(_extends({}, options, {
32
+ onChange: function onChange(instance) {
29
33
  triggerRef(state);
30
34
  options.onChange == null ? void 0 : options.onChange(instance);
31
35
  }
32
- });
36
+ }));
33
37
  virtualizer._willUpdate();
34
38
  }, {
35
39
  immediate: true
@@ -38,22 +42,26 @@ function useVirtualizerBase(options) {
38
42
  return state;
39
43
  }
40
44
  function useVirtualizer(options) {
41
- return useVirtualizerBase(computed(() => ({
42
- observeElementRect: observeElementRect,
43
- observeElementOffset: observeElementOffset,
44
- scrollToFn: elementScroll,
45
- ...unref(options)
46
- })));
45
+ return useVirtualizerBase(computed(function () {
46
+ return _extends({
47
+ observeElementRect: observeElementRect,
48
+ observeElementOffset: observeElementOffset,
49
+ scrollToFn: elementScroll
50
+ }, unref(options));
51
+ }));
47
52
  }
48
53
  function useWindowVirtualizer(options) {
49
- return useVirtualizerBase(computed(() => ({
50
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
- getScrollElement: () => typeof Window !== 'undefined' ? window : null,
52
- observeElementRect: observeWindowRect,
53
- observeElementOffset: observeWindowOffset,
54
- scrollToFn: windowScroll,
55
- ...unref(options)
56
- })));
54
+ return useVirtualizerBase(computed(function () {
55
+ return _extends({
56
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
57
+ getScrollElement: function getScrollElement() {
58
+ return typeof Window !== 'undefined' ? window : null;
59
+ },
60
+ observeElementRect: observeWindowRect,
61
+ observeElementOffset: observeWindowOffset,
62
+ scrollToFn: windowScroll
63
+ }, unref(options));
64
+ }));
57
65
  }
58
66
 
59
67
  export { useVirtualizer, useWindowVirtualizer };
@@ -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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,MAAMC,WAAW,GAAG,IAAIC,WAAW,CAACC,KAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,MAAMI,KAAK,GAAGC,UAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,MAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;EAEvCC,KAAK,CACH,MAAML,KAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,EACtCC,EAAE,IAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDJ,KAAK,CACH,MAAML,KAAK,CAACH,OAAO,CAAC,EACnBA,OAAO,IAAK;IACXC,WAAW,CAACY,UAAU,CAAC;AACrB,MAAA,GAAGb,OAAO;MACVc,QAAQ,EAAGC,QAAQ,IAAK;QACtBC,UAAU,CAACZ,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;AACF,KAAC,CAAC,CAAA;IAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDK,cAAc,CAACX,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;AAChD,EAAA,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,OAAO;AACdC,IAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,IAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,IAAAA,UAAU,EAAEC,aAAa;IACzB,GAAGpB,KAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;AACxC,EAAA,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,OAAO;AACd;IACAV,gBAAgB,EAAE,MAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAM;AACxEN,IAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,IAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,IAAAA,UAAU,EAAEO,YAAY;IACxB,GAAG1B,KAAK,CAACH,OAAO,CAAA;GACjB,CAAC,CAAC,CACJ,CAAA;AACH;;;;"}
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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;AAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;EAChD,IAAMC,WAAW,GAAG,IAAIC,WAAW,CAACC,KAAK,CAACH,OAAO,CAAC,CAAC,CAAA;AACnD,EAAA,IAAMI,KAAK,GAAGC,UAAU,CAACJ,WAAW,CAAC,CAAA;AAErC,EAAA,IAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;AAEvCC,EAAAA,KAAK,CACH,YAAA;AAAA,IAAA,OAAML,KAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,CAAA;GACvC,EAAA,UAACC,EAAE,EAAK;AACN,IAAA,IAAIA,EAAE,EAAE;MACNT,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,KAAA;AACF,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;AAEDJ,EAAAA,KAAK,CACH,YAAA;IAAA,OAAML,KAAK,CAACH,OAAO,CAAC,CAAA;GACpB,EAAA,UAACA,OAAO,EAAK;IACXC,WAAW,CAACY,UAAU,CAAA,QAAA,CAAA,EAAA,EACjBb,OAAO,EAAA;MACVc,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;QACtBC,UAAU,CAACZ,KAAK,CAAC,CAAA;QACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;AAC9B,OAAA;KACA,CAAA,CAAA,CAAA;IAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;AAC3B,GAAC,EACD;AACEC,IAAAA,SAAS,EAAE,IAAA;AACb,GAAC,CACF,CAAA;EAEDK,cAAc,CAACX,OAAO,CAAC,CAAA;AAEvB,EAAA,OAAOF,KAAK,CAAA;AACd,CAAA;AAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;EAChD,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,YAAA;AAAA,IAAA,OAAA,QAAA,CAAA;AACPC,MAAAA,kBAAkB,EAAEA,kBAAkB;AACtCC,MAAAA,oBAAoB,EAAEA,oBAAoB;AAC1CC,MAAAA,UAAU,EAAEC,aAAAA;KACTpB,EAAAA,KAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH,CAAA;AAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;EACxC,OAAOD,kBAAkB,CACvBoB,QAAQ,CAAC,YAAA;AAAA,IAAA,OAAA,QAAA,CAAA;AACP;AACAV,MAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;AAAA,QAAA,OAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAK,CAAA;OAAC;AACxEN,MAAAA,kBAAkB,EAAEO,iBAAiB;AACrCN,MAAAA,oBAAoB,EAAEO,mBAAmB;AACzCN,MAAAA,UAAU,EAAEO,YAAAA;KACT1B,EAAAA,KAAK,CAACH,OAAO,CAAC,CAAA,CAAA;AAAA,GACjB,CAAC,CACJ,CAAA;AACH;;;;"}
@@ -14,25 +14,43 @@
14
14
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.VueVirtual = {}, global.VirtualCore, global.Vue));
15
15
  })(this, (function (exports, virtualCore, vue) { 'use strict';
16
16
 
17
+ function _extends() {
18
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
19
+ for (var i = 1; i < arguments.length; i++) {
20
+ var source = arguments[i];
21
+ for (var key in source) {
22
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
23
+ target[key] = source[key];
24
+ }
25
+ }
26
+ }
27
+ return target;
28
+ };
29
+ return _extends.apply(this, arguments);
30
+ }
31
+
17
32
  function useVirtualizerBase(options) {
18
- const virtualizer = new virtualCore.Virtualizer(vue.unref(options));
19
- const state = vue.shallowRef(virtualizer);
20
- const cleanup = virtualizer._didMount();
21
- vue.watch(() => vue.unref(options).getScrollElement(), el => {
33
+ var virtualizer = new virtualCore.Virtualizer(vue.unref(options));
34
+ var state = vue.shallowRef(virtualizer);
35
+ var cleanup = virtualizer._didMount();
36
+ vue.watch(function () {
37
+ return vue.unref(options).getScrollElement();
38
+ }, function (el) {
22
39
  if (el) {
23
40
  virtualizer._willUpdate();
24
41
  }
25
42
  }, {
26
43
  immediate: true
27
44
  });
28
- vue.watch(() => vue.unref(options), options => {
29
- virtualizer.setOptions({
30
- ...options,
31
- onChange: instance => {
45
+ vue.watch(function () {
46
+ return vue.unref(options);
47
+ }, function (options) {
48
+ virtualizer.setOptions(_extends({}, options, {
49
+ onChange: function onChange(instance) {
32
50
  vue.triggerRef(state);
33
51
  options.onChange == null ? void 0 : options.onChange(instance);
34
52
  }
35
- });
53
+ }));
36
54
  virtualizer._willUpdate();
37
55
  }, {
38
56
  immediate: true
@@ -41,22 +59,26 @@
41
59
  return state;
42
60
  }
43
61
  function useVirtualizer(options) {
44
- return useVirtualizerBase(vue.computed(() => ({
45
- observeElementRect: virtualCore.observeElementRect,
46
- observeElementOffset: virtualCore.observeElementOffset,
47
- scrollToFn: virtualCore.elementScroll,
48
- ...vue.unref(options)
49
- })));
62
+ return useVirtualizerBase(vue.computed(function () {
63
+ return _extends({
64
+ observeElementRect: virtualCore.observeElementRect,
65
+ observeElementOffset: virtualCore.observeElementOffset,
66
+ scrollToFn: virtualCore.elementScroll
67
+ }, vue.unref(options));
68
+ }));
50
69
  }
51
70
  function useWindowVirtualizer(options) {
52
- return useVirtualizerBase(vue.computed(() => ({
53
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
54
- getScrollElement: () => typeof Window !== 'undefined' ? window : null,
55
- observeElementRect: virtualCore.observeWindowRect,
56
- observeElementOffset: virtualCore.observeWindowOffset,
57
- scrollToFn: virtualCore.windowScroll,
58
- ...vue.unref(options)
59
- })));
71
+ return useVirtualizerBase(vue.computed(function () {
72
+ return _extends({
73
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
74
+ getScrollElement: function getScrollElement() {
75
+ return typeof Window !== 'undefined' ? window : null;
76
+ },
77
+ observeElementRect: virtualCore.observeWindowRect,
78
+ observeElementOffset: virtualCore.observeWindowOffset,
79
+ scrollToFn: virtualCore.windowScroll
80
+ }, vue.unref(options));
81
+ }));
60
82
  }
61
83
 
62
84
  exports.useVirtualizer = useVirtualizer;
@@ -1 +1 @@
1
- {"version":3,"file":"index.development.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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;EAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;IAChD,MAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACC,SAAK,CAACH,OAAO,CAAC,CAAC,CAAA;EACnD,EAAA,MAAMI,KAAK,GAAGC,cAAU,CAACJ,WAAW,CAAC,CAAA;EAErC,EAAA,MAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;IAEvCC,SAAK,CACH,MAAML,SAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,EACtCC,EAAE,IAAK;EACN,IAAA,IAAIA,EAAE,EAAE;QACNT,WAAW,CAACU,WAAW,EAAE,CAAA;EAC3B,KAAA;EACF,GAAC,EACD;EACEC,IAAAA,SAAS,EAAE,IAAA;EACb,GAAC,CACF,CAAA;IAEDJ,SAAK,CACH,MAAML,SAAK,CAACH,OAAO,CAAC,EACnBA,OAAO,IAAK;MACXC,WAAW,CAACY,UAAU,CAAC;EACrB,MAAA,GAAGb,OAAO;QACVc,QAAQ,EAAGC,QAAQ,IAAK;UACtBC,cAAU,CAACZ,KAAK,CAAC,CAAA;UACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;EAC9B,OAAA;EACF,KAAC,CAAC,CAAA;MAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;EAC3B,GAAC,EACD;EACEC,IAAAA,SAAS,EAAE,IAAA;EACb,GAAC,CACF,CAAA;IAEDK,kBAAc,CAACX,OAAO,CAAC,CAAA;EAEvB,EAAA,OAAOF,KAAK,CAAA;EACd,CAAA;EAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;EAChD,EAAA,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,OAAO;EACdC,IAAAA,kBAAkB,EAAEA,8BAAkB;EACtCC,IAAAA,oBAAoB,EAAEA,gCAAoB;EAC1CC,IAAAA,UAAU,EAAEC,yBAAa;MACzB,GAAGpB,SAAK,CAACH,OAAO,CAAA;KACjB,CAAC,CAAC,CACJ,CAAA;EACH,CAAA;EAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;EACxC,EAAA,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,OAAO;EACd;MACAV,gBAAgB,EAAE,MAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAM;EACxEN,IAAAA,kBAAkB,EAAEO,6BAAiB;EACrCN,IAAAA,oBAAoB,EAAEO,+BAAmB;EACzCN,IAAAA,UAAU,EAAEO,wBAAY;MACxB,GAAG1B,SAAK,CAACH,OAAO,CAAA;KACjB,CAAC,CAAC,CACJ,CAAA;EACH;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.development.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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","useVirtualizer","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","useWindowVirtualizer","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuBA,SAASA,kBAAkB,CAIzBC,OAAmE,EACnB;IAChD,IAAMC,WAAW,GAAG,IAAIC,uBAAW,CAACC,SAAK,CAACH,OAAO,CAAC,CAAC,CAAA;EACnD,EAAA,IAAMI,KAAK,GAAGC,cAAU,CAACJ,WAAW,CAAC,CAAA;EAErC,EAAA,IAAMK,OAAO,GAAGL,WAAW,CAACM,SAAS,EAAE,CAAA;EAEvCC,EAAAA,SAAK,CACH,YAAA;EAAA,IAAA,OAAML,SAAK,CAACH,OAAO,CAAC,CAACS,gBAAgB,EAAE,CAAA;KACvC,EAAA,UAACC,EAAE,EAAK;EACN,IAAA,IAAIA,EAAE,EAAE;QACNT,WAAW,CAACU,WAAW,EAAE,CAAA;EAC3B,KAAA;EACF,GAAC,EACD;EACEC,IAAAA,SAAS,EAAE,IAAA;EACb,GAAC,CACF,CAAA;EAEDJ,EAAAA,SAAK,CACH,YAAA;MAAA,OAAML,SAAK,CAACH,OAAO,CAAC,CAAA;KACpB,EAAA,UAACA,OAAO,EAAK;MACXC,WAAW,CAACY,UAAU,CAAA,QAAA,CAAA,EAAA,EACjBb,OAAO,EAAA;QACVc,QAAQ,EAAE,SAACC,QAAAA,CAAAA,QAAQ,EAAK;UACtBC,cAAU,CAACZ,KAAK,CAAC,CAAA;UACjBJ,OAAO,CAACc,QAAQ,IAAhBd,IAAAA,GAAAA,KAAAA,CAAAA,GAAAA,OAAO,CAACc,QAAQ,CAAGC,QAAQ,CAAC,CAAA;EAC9B,OAAA;OACA,CAAA,CAAA,CAAA;MAEFd,WAAW,CAACU,WAAW,EAAE,CAAA;EAC3B,GAAC,EACD;EACEC,IAAAA,SAAS,EAAE,IAAA;EACb,GAAC,CACF,CAAA;IAEDK,kBAAc,CAACX,OAAO,CAAC,CAAA;EAEvB,EAAA,OAAOF,KAAK,CAAA;EACd,CAAA;EAEO,SAASc,cAAc,CAI5BlB,OAKC,EAC+C;IAChD,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,YAAA;EAAA,IAAA,OAAA,QAAA,CAAA;EACPC,MAAAA,kBAAkB,EAAEA,8BAAkB;EACtCC,MAAAA,oBAAoB,EAAEA,gCAAoB;EAC1CC,MAAAA,UAAU,EAAEC,yBAAAA;OACTpB,EAAAA,SAAK,CAACH,OAAO,CAAC,CAAA,CAAA;EAAA,GACjB,CAAC,CACJ,CAAA;EACH,CAAA;EAEO,SAASwB,oBAAoB,CAClCxB,OAQC,EACuC;IACxC,OAAOD,kBAAkB,CACvBoB,YAAQ,CAAC,YAAA;EAAA,IAAA,OAAA,QAAA,CAAA;EACP;EACAV,MAAAA,gBAAgB,EAAE,SAAA,gBAAA,GAAA;EAAA,QAAA,OAAO,OAAOgB,MAAM,KAAK,WAAW,GAAGC,MAAM,GAAG,IAAK,CAAA;SAAC;EACxEN,MAAAA,kBAAkB,EAAEO,6BAAiB;EACrCN,MAAAA,oBAAoB,EAAEO,+BAAmB;EACzCN,MAAAA,UAAU,EAAEO,wBAAAA;OACT1B,EAAAA,SAAK,CAACH,OAAO,CAAC,CAAA,CAAA;EAAA,GACjB,CAAC,CACJ,CAAA;EACH;;;;;;;;;;;"}
@@ -8,5 +8,5 @@
8
8
  *
9
9
  * @license MIT
10
10
  */
11
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/virtual-core"),require("vue")):"function"==typeof define&&define.amd?define(["exports","@tanstack/virtual-core","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).VueVirtual={},e.VirtualCore,e.Vue)}(this,(function(e,t,n){"use strict";function o(e){const o=new t.Virtualizer(n.unref(e)),r=n.shallowRef(o),l=o._didMount();return n.watch((()=>n.unref(e).getScrollElement()),(e=>{e&&o._willUpdate()}),{immediate:!0}),n.watch((()=>n.unref(e)),(e=>{o.setOptions({...e,onChange:t=>{n.triggerRef(r),null==e.onChange||e.onChange(t)}}),o._willUpdate()}),{immediate:!0}),n.onScopeDispose(l),r}e.useVirtualizer=function(e){return o(n.computed((()=>({observeElementRect:t.observeElementRect,observeElementOffset:t.observeElementOffset,scrollToFn:t.elementScroll,...n.unref(e)}))))},e.useWindowVirtualizer=function(e){return o(n.computed((()=>({getScrollElement:()=>"undefined"!=typeof Window?window:null,observeElementRect:t.observeWindowRect,observeElementOffset:t.observeWindowOffset,scrollToFn:t.windowScroll,...n.unref(e)}))))},Object.defineProperty(e,"__esModule",{value:!0})}));
11
+ !function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("@tanstack/virtual-core"),require("vue")):"function"==typeof define&&define.amd?define(["exports","@tanstack/virtual-core","vue"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).VueVirtual={},e.VirtualCore,e.Vue)}(this,(function(e,n,t){"use strict";function r(){return r=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e},r.apply(this,arguments)}function o(e){var o=new n.Virtualizer(t.unref(e)),i=t.shallowRef(o),u=o._didMount();return t.watch((function(){return t.unref(e).getScrollElement()}),(function(e){e&&o._willUpdate()}),{immediate:!0}),t.watch((function(){return t.unref(e)}),(function(e){o.setOptions(r({},e,{onChange:function(n){t.triggerRef(i),null==e.onChange||e.onChange(n)}})),o._willUpdate()}),{immediate:!0}),t.onScopeDispose(u),i}e.useVirtualizer=function(e){return o(t.computed((function(){return r({observeElementRect:n.observeElementRect,observeElementOffset:n.observeElementOffset,scrollToFn:n.elementScroll},t.unref(e))})))},e.useWindowVirtualizer=function(e){return o(t.computed((function(){return r({getScrollElement:function(){return"undefined"!=typeof Window?window:null},observeElementRect:n.observeWindowRect,observeElementOffset:n.observeWindowOffset,scrollToFn:n.windowScroll},t.unref(e))})))},Object.defineProperty(e,"__esModule",{value:!0})}));
12
12
  //# sourceMappingURL=index.production.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.production.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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","onChange","instance","triggerRef","onScopeDispose","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;0VAuBA,SAASA,EAIPC,GAEA,MAAMC,EAAc,IAAIC,EAAAA,YAAYC,EAAAA,MAAMH,IACpCI,EAAQC,aAAWJ,GAEnBK,EAAUL,EAAYM,YAkC5B,OAhCAC,EAAKA,OACH,IAAML,EAAAA,MAAMH,GAASS,qBACpBC,IACKA,GACFT,EAAYU,aACd,GAEF,CACEC,WAAW,IAIfJ,EAAAA,OACE,IAAML,EAAAA,MAAMH,KACXA,IACCC,EAAYY,WAAW,IAClBb,EACHc,SAAWC,IACTC,EAAUA,WAACZ,GACXJ,MAAAA,EAAQc,UAARd,EAAQc,SAAWC,EAAS,IAIhCd,EAAYU,aAAa,GAE3B,CACEC,WAAW,IAIfK,EAAcA,eAACX,GAERF,CACT,kBAEO,SAILJ,GAOA,OAAOD,EACLmB,EAAAA,UAAS,KAAO,CACdC,mBAAoBA,EAAkBA,mBACtCC,qBAAsBA,EAAoBA,qBAC1CC,WAAYC,EAAaA,iBACtBnB,EAAAA,MAAMH,OAGf,yBAEO,SACLA,GAUA,OAAOD,EACLmB,EAAAA,UAAS,KAAO,CAEdT,iBAAkB,IAAyB,oBAAXc,OAAyBC,OAAS,KAClEL,mBAAoBM,EAAiBA,kBACrCL,qBAAsBM,EAAmBA,oBACzCL,WAAYM,EAAYA,gBACrBxB,EAAAA,MAAMH,OAGf"}
1
+ {"version":3,"file":"index.production.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'\nimport {\n computed,\n onScopeDispose,\n Ref,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\n\ntype MaybeRef<T> = T | Ref<T>\n\nfunction useVirtualizerBase<\n TScrollElement extends Element | Window,\n TItemElement extends Element,\n>(\n options: MaybeRef<VirtualizerOptions<TScrollElement, TItemElement>>,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n const virtualizer = new Virtualizer(unref(options))\n const state = shallowRef(virtualizer)\n\n const cleanup = virtualizer._didMount()\n\n watch(\n () => unref(options).getScrollElement(),\n (el) => {\n if (el) {\n virtualizer._willUpdate()\n }\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance) => {\n triggerRef(state)\n options.onChange?.(instance)\n },\n })\n\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n onScopeDispose(cleanup)\n\n return state\n}\n\nexport function useVirtualizer<\n TScrollElement extends Element,\n TItemElement extends Element,\n>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<TScrollElement, TItemElement>,\n 'observeElementRect' | 'observeElementOffset' | 'scrollToFn'\n >\n >,\n): Ref<Virtualizer<TScrollElement, TItemElement>> {\n return useVirtualizerBase<TScrollElement, TItemElement>(\n computed(() => ({\n observeElementRect: observeElementRect,\n observeElementOffset: observeElementOffset,\n scrollToFn: elementScroll,\n ...unref(options),\n })),\n )\n}\n\nexport function useWindowVirtualizer<TItemElement extends Element>(\n options: MaybeRef<\n PartialKeys<\n VirtualizerOptions<Window, TItemElement>,\n | 'observeElementRect'\n | 'observeElementOffset'\n | 'scrollToFn'\n | 'getScrollElement'\n >\n >,\n): Ref<Virtualizer<Window, TItemElement>> {\n return useVirtualizerBase<Window, TItemElement>(\n computed(() => ({\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n getScrollElement: () => (typeof Window !== 'undefined' ? window : null!),\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n ...unref(options),\n })),\n )\n}\n"],"names":["useVirtualizerBase","options","virtualizer","Virtualizer","unref","state","shallowRef","cleanup","_didMount","watch","getScrollElement","el","_willUpdate","immediate","setOptions","_extends","onChange","instance","triggerRef","onScopeDispose","computed","observeElementRect","observeElementOffset","scrollToFn","elementScroll","Window","window","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;;;;;;;8jBAuBA,SAASA,EAIPC,GAEA,IAAMC,EAAc,IAAIC,EAAAA,YAAYC,EAAAA,MAAMH,IACpCI,EAAQC,aAAWJ,GAEnBK,EAAUL,EAAYM,YAkC5B,OAhCAC,EAAAA,OACE,WAAA,OAAML,QAAMH,GAASS,kBACrB,IAAA,SAACC,GACKA,GACFT,EAAYU,aAEhB,GACA,CACEC,WAAW,IAIfJ,EAAAA,OACE,WAAA,OAAML,EAAAA,MAAMH,EACZ,IAAA,SAACA,GACCC,EAAYY,WAAUC,EAAA,CAAA,EACjBd,EAAO,CACVe,SAAU,SAACC,GACTC,EAAUA,WAACb,GACXJ,MAAAA,EAAQe,UAARf,EAAQe,SAAWC,EACrB,KAGFf,EAAYU,aACd,GACA,CACEC,WAAW,IAIfM,EAAcA,eAACZ,GAERF,CACT,kBAEO,SAILJ,GAOA,OAAOD,EACLoB,EAAAA,UAAS,WAAA,OAAAL,EAAA,CACPM,mBAAoBA,EAAkBA,mBACtCC,qBAAsBA,EAAoBA,qBAC1CC,WAAYC,EAAAA,eACTpB,EAAKA,MAACH,GACT,IAEN,yBAEO,SACLA,GAUA,OAAOD,EACLoB,EAAAA,UAAS,WAAA,OAAAL,EAAA,CAEPL,iBAAkB,WAAA,MAAyB,oBAAXe,OAAyBC,OAAS,IAAM,EACxEL,mBAAoBM,EAAiBA,kBACrCL,qBAAsBM,EAAmBA,oBACzCL,WAAYM,EAAAA,cACTzB,EAAKA,MAACH,GACT,IAEN"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tanstack/vue-virtual",
3
3
  "author": "Tanner Linsley",
4
- "version": "3.0.0-beta.29",
4
+ "version": "3.0.0-beta.32",
5
5
  "description": "Headless UI for virtualizing scrollable elements in Solid",
6
6
  "license": "MIT",
7
7
  "homepage": "https://github.com/tanstack/virtual#readme",
@@ -46,7 +46,7 @@
46
46
  "vue": "^3.2.45"
47
47
  },
48
48
  "dependencies": {
49
- "@tanstack/virtual-core": "3.0.0-beta.29"
49
+ "@tanstack/virtual-core": "3.0.0-beta.32"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "vue": "^3.0.0"