@tanstack/virtual-core 3.0.0-beta.9 → 3.0.1

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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js +27 -0
  3. package/build/lib/_virtual/_rollupPluginBabelHelpers.esm.js.map +1 -0
  4. package/build/lib/_virtual/_rollupPluginBabelHelpers.js +31 -0
  5. package/build/lib/_virtual/_rollupPluginBabelHelpers.js.map +1 -0
  6. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs +27 -0
  7. package/build/lib/_virtual/_rollupPluginBabelHelpers.mjs.map +1 -0
  8. package/build/lib/index.d.ts +126 -0
  9. package/build/lib/index.esm.js +639 -0
  10. package/build/lib/index.esm.js.map +1 -0
  11. package/build/lib/index.js +654 -0
  12. package/build/lib/index.js.map +1 -0
  13. package/build/lib/index.mjs +639 -0
  14. package/build/lib/index.mjs.map +1 -0
  15. package/build/lib/utils.d.ts +10 -0
  16. package/build/lib/utils.esm.js +58 -0
  17. package/build/lib/utils.esm.js.map +1 -0
  18. package/build/{cjs/packages/virtual-core/src → lib}/utils.js +28 -21
  19. package/build/lib/utils.js.map +1 -0
  20. package/build/lib/utils.mjs +58 -0
  21. package/build/lib/utils.mjs.map +1 -0
  22. package/build/umd/index.development.js +600 -493
  23. package/build/umd/index.development.js.map +1 -1
  24. package/build/umd/index.production.js +1 -1
  25. package/build/umd/index.production.js.map +1 -1
  26. package/package.json +16 -14
  27. package/src/index.ts +566 -278
  28. package/src/utils.ts +17 -5
  29. package/build/cjs/packages/virtual-core/src/index.js +0 -497
  30. package/build/cjs/packages/virtual-core/src/index.js.map +0 -1
  31. package/build/cjs/packages/virtual-core/src/utils.js.map +0 -1
  32. package/build/esm/index.js +0 -591
  33. package/build/esm/index.js.map +0 -1
  34. package/build/stats-html.html +0 -2689
  35. package/build/stats.json +0 -101
  36. package/build/types/index.d.ts +0 -88
  37. package/build/types/utils.d.ts +0 -7
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Tanner Linsley
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,27 @@
1
+ /**
2
+ * virtual-core
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
+ * virtual-core
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
+ * virtual-core
3
+ *
4
+ * Copyright (c) TanStack
5
+ *
6
+ * This source code is licensed under the MIT license found in the
7
+ * LICENSE.md file in the root directory of this source tree.
8
+ *
9
+ * @license MIT
10
+ */
11
+ function _extends() {
12
+ _extends = Object.assign ? Object.assign.bind() : function (target) {
13
+ for (var i = 1; i < arguments.length; i++) {
14
+ var source = arguments[i];
15
+ for (var key in source) {
16
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
17
+ target[key] = source[key];
18
+ }
19
+ }
20
+ }
21
+ return target;
22
+ };
23
+ return _extends.apply(this, arguments);
24
+ }
25
+
26
+ export { _extends as extends };
27
+ //# sourceMappingURL=_rollupPluginBabelHelpers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_rollupPluginBabelHelpers.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,126 @@
1
+ export * from './utils';
2
+ type ScrollDirection = 'forward' | 'backward';
3
+ type ScrollAlignment = 'start' | 'center' | 'end' | 'auto';
4
+ type ScrollBehavior = 'auto' | 'smooth';
5
+ export interface ScrollToOptions {
6
+ align?: ScrollAlignment;
7
+ behavior?: ScrollBehavior;
8
+ }
9
+ type ScrollToOffsetOptions = ScrollToOptions;
10
+ type ScrollToIndexOptions = ScrollToOptions;
11
+ export interface Range {
12
+ startIndex: number;
13
+ endIndex: number;
14
+ overscan: number;
15
+ count: number;
16
+ }
17
+ type Key = number | string;
18
+ export interface VirtualItem {
19
+ key: Key;
20
+ index: number;
21
+ start: number;
22
+ end: number;
23
+ size: number;
24
+ lane: number;
25
+ }
26
+ interface Rect {
27
+ width: number;
28
+ height: number;
29
+ }
30
+ export declare const defaultKeyExtractor: (index: number) => number;
31
+ export declare const defaultRangeExtractor: (range: Range) => number[];
32
+ export declare const observeElementRect: <T extends Element>(instance: Virtualizer<T, any>, cb: (rect: Rect) => void) => (() => void) | undefined;
33
+ export declare const observeWindowRect: (instance: Virtualizer<Window, any>, cb: (rect: Rect) => void) => (() => void) | undefined;
34
+ export declare const observeElementOffset: <T extends Element>(instance: Virtualizer<T, any>, cb: (offset: number) => void) => (() => void) | undefined;
35
+ export declare const observeWindowOffset: (instance: Virtualizer<Window, any>, cb: (offset: number) => void) => (() => void) | undefined;
36
+ export declare const measureElement: <TItemElement extends Element>(element: TItemElement, entry: ResizeObserverEntry | undefined, instance: Virtualizer<any, TItemElement>) => number;
37
+ export declare const windowScroll: <T extends Window>(offset: number, { adjustments, behavior, }: {
38
+ adjustments?: number | undefined;
39
+ behavior?: ScrollBehavior | undefined;
40
+ }, instance: Virtualizer<T, any>) => void;
41
+ export declare const elementScroll: <T extends Element>(offset: number, { adjustments, behavior, }: {
42
+ adjustments?: number | undefined;
43
+ behavior?: ScrollBehavior | undefined;
44
+ }, instance: Virtualizer<T, any>) => void;
45
+ export interface VirtualizerOptions<TScrollElement extends Element | Window, TItemElement extends Element> {
46
+ count: number;
47
+ getScrollElement: () => TScrollElement | null;
48
+ estimateSize: (index: number) => number;
49
+ scrollToFn: (offset: number, options: {
50
+ adjustments?: number;
51
+ behavior?: ScrollBehavior;
52
+ }, instance: Virtualizer<TScrollElement, TItemElement>) => void;
53
+ observeElementRect: (instance: Virtualizer<TScrollElement, TItemElement>, cb: (rect: Rect) => void) => void | (() => void);
54
+ observeElementOffset: (instance: Virtualizer<TScrollElement, TItemElement>, cb: (offset: number) => void) => void | (() => void);
55
+ debug?: any;
56
+ initialRect?: Rect;
57
+ onChange?: (instance: Virtualizer<TScrollElement, TItemElement>, sync: boolean) => void;
58
+ measureElement?: (element: TItemElement, entry: ResizeObserverEntry | undefined, instance: Virtualizer<TScrollElement, TItemElement>) => number;
59
+ overscan?: number;
60
+ horizontal?: boolean;
61
+ paddingStart?: number;
62
+ paddingEnd?: number;
63
+ scrollPaddingStart?: number;
64
+ scrollPaddingEnd?: number;
65
+ initialOffset?: number;
66
+ getItemKey?: (index: number) => Key;
67
+ rangeExtractor?: (range: Range) => number[];
68
+ scrollMargin?: number;
69
+ scrollingDelay?: number;
70
+ indexAttribute?: string;
71
+ initialMeasurementsCache?: VirtualItem[];
72
+ lanes?: number;
73
+ }
74
+ export declare class Virtualizer<TScrollElement extends Element | Window, TItemElement extends Element> {
75
+ private unsubs;
76
+ options: Required<VirtualizerOptions<TScrollElement, TItemElement>>;
77
+ scrollElement: TScrollElement | null;
78
+ isScrolling: boolean;
79
+ private isScrollingTimeoutId;
80
+ private scrollToIndexTimeoutId;
81
+ measurementsCache: VirtualItem[];
82
+ private itemSizeCache;
83
+ private pendingMeasuredCacheIndexes;
84
+ scrollRect: Rect;
85
+ scrollOffset: number;
86
+ scrollDirection: ScrollDirection | null;
87
+ private scrollAdjustments;
88
+ measureElementCache: Map<Key, TItemElement>;
89
+ private observer;
90
+ range: {
91
+ startIndex: number;
92
+ endIndex: number;
93
+ } | null;
94
+ constructor(opts: VirtualizerOptions<TScrollElement, TItemElement>);
95
+ setOptions: (opts: VirtualizerOptions<TScrollElement, TItemElement>) => void;
96
+ private notify;
97
+ private maybeNotify;
98
+ private cleanup;
99
+ _didMount: () => () => void;
100
+ _willUpdate: () => void;
101
+ private getSize;
102
+ private memoOptions;
103
+ private getFurthestMeasurement;
104
+ private getMeasurements;
105
+ calculateRange: () => {
106
+ startIndex: number;
107
+ endIndex: number;
108
+ } | null;
109
+ private getIndexes;
110
+ indexFromElement: (node: TItemElement) => number;
111
+ private _measureElement;
112
+ resizeItem: (item: VirtualItem, size: number) => void;
113
+ measureElement: (node: TItemElement | null) => void;
114
+ getVirtualItems: () => VirtualItem[];
115
+ getVirtualItemForOffset: (offset: number) => VirtualItem;
116
+ getOffsetForAlignment: (toOffset: number, align: ScrollAlignment) => number;
117
+ getOffsetForIndex: (index: number, align?: ScrollAlignment) => readonly [number, "auto"] | readonly [number, "start" | "center" | "end"];
118
+ private isDynamicMode;
119
+ private cancelScrollToIndex;
120
+ scrollToOffset: (toOffset: number, { align, behavior }?: ScrollToOffsetOptions) => void;
121
+ scrollToIndex: (index: number, { align: initialAlign, behavior }?: ScrollToIndexOptions) => void;
122
+ scrollBy: (delta: number, { behavior }?: ScrollToOffsetOptions) => void;
123
+ getTotalSize: () => number;
124
+ private _scrollToOffset;
125
+ measure: () => void;
126
+ }