@tanstack/vue-virtual 3.13.52 → 3.13.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.cjs +11 -8
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.js +11 -8
- package/dist/esm/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +17 -9
package/dist/cjs/index.cjs
CHANGED
|
@@ -48,14 +48,17 @@ function useVirtualizer(options) {
|
|
|
48
48
|
}
|
|
49
49
|
function useWindowVirtualizer(options) {
|
|
50
50
|
return useVirtualizerBase(
|
|
51
|
-
vue.computed(() =>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
51
|
+
vue.computed(() => {
|
|
52
|
+
const resolvedOptions = vue.unref(options);
|
|
53
|
+
return {
|
|
54
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
55
|
+
observeElementRect: virtualCore.observeWindowRect,
|
|
56
|
+
observeElementOffset: virtualCore.observeWindowOffset,
|
|
57
|
+
scrollToFn: virtualCore.windowScroll,
|
|
58
|
+
initialOffset: () => typeof document !== "undefined" ? resolvedOptions.horizontal ? window.scrollX : window.scrollY : 0,
|
|
59
|
+
...resolvedOptions
|
|
60
|
+
};
|
|
61
|
+
})
|
|
59
62
|
);
|
|
60
63
|
}
|
|
61
64
|
exports.useVirtualizer = useVirtualizer;
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n Virtualizer,\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n windowScroll,\n} from '@tanstack/virtual-core'\nimport {\n computed,\n onScopeDispose,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\nimport type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'\nimport type { Ref } from 'vue'\n\nexport * from '@tanstack/virtual-core'\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 () => {\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance, sync) => {\n triggerRef(state)\n options.onChange?.(instance, sync)\n },\n })\n\n virtualizer._willUpdate()\n triggerRef(state)\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
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import {\n Virtualizer,\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n windowScroll,\n} from '@tanstack/virtual-core'\nimport {\n computed,\n onScopeDispose,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\nimport type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'\nimport type { Ref } from 'vue'\n\nexport * from '@tanstack/virtual-core'\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 () => {\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance, sync) => {\n triggerRef(state)\n options.onChange?.(instance, sync)\n },\n })\n\n virtualizer._willUpdate()\n triggerRef(state)\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 const resolvedOptions = unref(options)\n return {\n getScrollElement: () =>\n typeof document !== 'undefined' ? window : null,\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n initialOffset: () =>\n typeof document !== 'undefined'\n ? resolvedOptions.horizontal\n ? window.scrollX\n : window.scrollY\n : 0,\n ...resolvedOptions,\n }\n }),\n )\n}\n"],"names":["Virtualizer","unref","shallowRef","watch","options","triggerRef","onScopeDispose","computed","observeElementRect","observeElementOffset","elementScroll","observeWindowRect","observeWindowOffset","windowScroll"],"mappings":";;;;AAwBA,SAAS,mBAIP,SACgD;AAChD,QAAM,cAAc,IAAIA,YAAAA,YAAYC,IAAAA,MAAM,OAAO,CAAC;AAClD,QAAM,QAAQC,IAAAA,WAAW,WAAW;AAEpC,QAAM,UAAU,YAAY,UAAA;AAE5BC,MAAAA;AAAAA,IACE,MAAMF,IAAAA,MAAM,OAAO,EAAE,iBAAA;AAAA,IACrB,MAAM;AACJ,kBAAY,YAAA;AAAA,IACd;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IAAA;AAAA,EACb;AAGFE,MAAAA;AAAAA,IACE,MAAMF,IAAAA,MAAM,OAAO;AAAA,IACnB,CAACG,aAAY;AACX,kBAAY,WAAW;AAAA,QACrB,GAAGA;AAAAA,QACH,UAAU,CAAC,UAAU,SAAS;;AAC5BC,cAAAA,WAAW,KAAK;AAChBD,yBAAQ,aAARA,kCAAmB,UAAU;AAAA,QAC/B;AAAA,MAAA,CACD;AAED,kBAAY,YAAA;AACZC,UAAAA,WAAW,KAAK;AAAA,IAClB;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IAAA;AAAA,EACb;AAGFC,MAAAA,eAAe,OAAO;AAEtB,SAAO;AACT;AAEO,SAAS,eAId,SAMgD;AAChD,SAAO;AAAA,IACLC,IAAAA,SAAS,OAAO;AAAA,MAAA,oBACdC,YAAAA;AAAAA,MAAA,sBACAC,YAAAA;AAAAA,MACA,YAAYC,YAAAA;AAAAA,MACZ,GAAGT,IAAAA,MAAM,OAAO;AAAA,IAAA,EAChB;AAAA,EAAA;AAEN;AAEO,SAAS,qBACd,SASwC;AACxC,SAAO;AAAA,IACLM,IAAAA,SAAS,MAAM;AACb,YAAM,kBAAkBN,IAAAA,MAAM,OAAO;AACrC,aAAO;AAAA,QACL,kBAAkB,MAChB,OAAO,aAAa,cAAc,SAAS;AAAA,QAC7C,oBAAoBU,YAAAA;AAAAA,QACpB,sBAAsBC,YAAAA;AAAAA,QACtB,YAAYC,YAAAA;AAAAA,QACZ,eAAe,MACb,OAAO,aAAa,cAChB,gBAAgB,aACd,OAAO,UACP,OAAO,UACT;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEP,CAAC;AAAA,EAAA;AAEL;;;;;;;;;"}
|
package/dist/esm/index.js
CHANGED
|
@@ -47,14 +47,17 @@ function useVirtualizer(options) {
|
|
|
47
47
|
}
|
|
48
48
|
function useWindowVirtualizer(options) {
|
|
49
49
|
return useVirtualizerBase(
|
|
50
|
-
computed(() =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
50
|
+
computed(() => {
|
|
51
|
+
const resolvedOptions = unref(options);
|
|
52
|
+
return {
|
|
53
|
+
getScrollElement: () => typeof document !== "undefined" ? window : null,
|
|
54
|
+
observeElementRect: observeWindowRect,
|
|
55
|
+
observeElementOffset: observeWindowOffset,
|
|
56
|
+
scrollToFn: windowScroll,
|
|
57
|
+
initialOffset: () => typeof document !== "undefined" ? resolvedOptions.horizontal ? window.scrollX : window.scrollY : 0,
|
|
58
|
+
...resolvedOptions
|
|
59
|
+
};
|
|
60
|
+
})
|
|
58
61
|
);
|
|
59
62
|
}
|
|
60
63
|
export {
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n Virtualizer,\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n windowScroll,\n} from '@tanstack/virtual-core'\nimport {\n computed,\n onScopeDispose,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\nimport type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'\nimport type { Ref } from 'vue'\n\nexport * from '@tanstack/virtual-core'\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 () => {\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance, sync) => {\n triggerRef(state)\n options.onChange?.(instance, sync)\n },\n })\n\n virtualizer._willUpdate()\n triggerRef(state)\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
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/index.ts"],"sourcesContent":["import {\n Virtualizer,\n elementScroll,\n observeElementOffset,\n observeElementRect,\n observeWindowOffset,\n observeWindowRect,\n windowScroll,\n} from '@tanstack/virtual-core'\nimport {\n computed,\n onScopeDispose,\n shallowRef,\n triggerRef,\n unref,\n watch,\n} from 'vue'\nimport type { PartialKeys, VirtualizerOptions } from '@tanstack/virtual-core'\nimport type { Ref } from 'vue'\n\nexport * from '@tanstack/virtual-core'\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 () => {\n virtualizer._willUpdate()\n },\n {\n immediate: true,\n },\n )\n\n watch(\n () => unref(options),\n (options) => {\n virtualizer.setOptions({\n ...options,\n onChange: (instance, sync) => {\n triggerRef(state)\n options.onChange?.(instance, sync)\n },\n })\n\n virtualizer._willUpdate()\n triggerRef(state)\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 const resolvedOptions = unref(options)\n return {\n getScrollElement: () =>\n typeof document !== 'undefined' ? window : null,\n observeElementRect: observeWindowRect,\n observeElementOffset: observeWindowOffset,\n scrollToFn: windowScroll,\n initialOffset: () =>\n typeof document !== 'undefined'\n ? resolvedOptions.horizontal\n ? window.scrollX\n : window.scrollY\n : 0,\n ...resolvedOptions,\n }\n }),\n )\n}\n"],"names":["options"],"mappings":";;;AAwBA,SAAS,mBAIP,SACgD;AAChD,QAAM,cAAc,IAAI,YAAY,MAAM,OAAO,CAAC;AAClD,QAAM,QAAQ,WAAW,WAAW;AAEpC,QAAM,UAAU,YAAY,UAAA;AAE5B;AAAA,IACE,MAAM,MAAM,OAAO,EAAE,iBAAA;AAAA,IACrB,MAAM;AACJ,kBAAY,YAAA;AAAA,IACd;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IAAA;AAAA,EACb;AAGF;AAAA,IACE,MAAM,MAAM,OAAO;AAAA,IACnB,CAACA,aAAY;AACX,kBAAY,WAAW;AAAA,QACrB,GAAGA;AAAAA,QACH,UAAU,CAAC,UAAU,SAAS;;AAC5B,qBAAW,KAAK;AAChBA,yBAAQ,aAARA,kCAAmB,UAAU;AAAA,QAC/B;AAAA,MAAA,CACD;AAED,kBAAY,YAAA;AACZ,iBAAW,KAAK;AAAA,IAClB;AAAA,IACA;AAAA,MACE,WAAW;AAAA,IAAA;AAAA,EACb;AAGF,iBAAe,OAAO;AAEtB,SAAO;AACT;AAEO,SAAS,eAId,SAMgD;AAChD,SAAO;AAAA,IACL,SAAS,OAAO;AAAA,MACd;AAAA,MACA;AAAA,MACA,YAAY;AAAA,MACZ,GAAG,MAAM,OAAO;AAAA,IAAA,EAChB;AAAA,EAAA;AAEN;AAEO,SAAS,qBACd,SASwC;AACxC,SAAO;AAAA,IACL,SAAS,MAAM;AACb,YAAM,kBAAkB,MAAM,OAAO;AACrC,aAAO;AAAA,QACL,kBAAkB,MAChB,OAAO,aAAa,cAAc,SAAS;AAAA,QAC7C,oBAAoB;AAAA,QACpB,sBAAsB;AAAA,QACtB,YAAY;AAAA,QACZ,eAAe,MACb,OAAO,aAAa,cAChB,gBAAgB,aACd,OAAO,UACP,OAAO,UACT;AAAA,QACN,GAAG;AAAA,MAAA;AAAA,IAEP,CAAC;AAAA,EAAA;AAEL;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tanstack/vue-virtual",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.54",
|
|
4
4
|
"description": "Headless UI for virtualizing scrollable elements in Vue",
|
|
5
5
|
"author": "Tanner Linsley",
|
|
6
6
|
"license": "MIT",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"src"
|
|
50
50
|
],
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@tanstack/virtual-core": "3.19.
|
|
52
|
+
"@tanstack/virtual-core": "3.19.13"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@vitejs/plugin-vue": "^5.2.4",
|
package/src/index.ts
CHANGED
|
@@ -100,14 +100,22 @@ export function useWindowVirtualizer<TItemElement extends Element>(
|
|
|
100
100
|
>,
|
|
101
101
|
): Ref<Virtualizer<Window, TItemElement>> {
|
|
102
102
|
return useVirtualizerBase<Window, TItemElement>(
|
|
103
|
-
computed(() =>
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
103
|
+
computed(() => {
|
|
104
|
+
const resolvedOptions = unref(options)
|
|
105
|
+
return {
|
|
106
|
+
getScrollElement: () =>
|
|
107
|
+
typeof document !== 'undefined' ? window : null,
|
|
108
|
+
observeElementRect: observeWindowRect,
|
|
109
|
+
observeElementOffset: observeWindowOffset,
|
|
110
|
+
scrollToFn: windowScroll,
|
|
111
|
+
initialOffset: () =>
|
|
112
|
+
typeof document !== 'undefined'
|
|
113
|
+
? resolvedOptions.horizontal
|
|
114
|
+
? window.scrollX
|
|
115
|
+
: window.scrollY
|
|
116
|
+
: 0,
|
|
117
|
+
...resolvedOptions,
|
|
118
|
+
}
|
|
119
|
+
}),
|
|
112
120
|
)
|
|
113
121
|
}
|