@react-stately/virtualizer 4.4.5 → 4.5.0
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/import.mjs +2 -14
- package/dist/main.js +8 -20
- package/dist/main.js.map +1 -1
- package/dist/module.js +2 -14
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +2 -0
- package/package.json +15 -12
- package/src/index.ts +2 -11
- package/dist/Layout.main.js +0 -54
- package/dist/Layout.main.js.map +0 -1
- package/dist/Layout.mjs +0 -49
- package/dist/Layout.module.js +0 -49
- package/dist/Layout.module.js.map +0 -1
- package/dist/LayoutInfo.main.js +0 -52
- package/dist/LayoutInfo.main.js.map +0 -1
- package/dist/LayoutInfo.mjs +0 -47
- package/dist/LayoutInfo.module.js +0 -47
- package/dist/LayoutInfo.module.js.map +0 -1
- package/dist/OverscanManager.main.js +0 -52
- package/dist/OverscanManager.main.js.map +0 -1
- package/dist/OverscanManager.mjs +0 -47
- package/dist/OverscanManager.module.js +0 -47
- package/dist/OverscanManager.module.js.map +0 -1
- package/dist/Point.main.js +0 -40
- package/dist/Point.main.js.map +0 -1
- package/dist/Point.mjs +0 -35
- package/dist/Point.module.js +0 -35
- package/dist/Point.module.js.map +0 -1
- package/dist/Rect.main.js +0 -131
- package/dist/Rect.main.js.map +0 -1
- package/dist/Rect.mjs +0 -126
- package/dist/Rect.module.js +0 -126
- package/dist/Rect.module.js.map +0 -1
- package/dist/ReusableView.main.js +0 -69
- package/dist/ReusableView.main.js.map +0 -1
- package/dist/ReusableView.mjs +0 -63
- package/dist/ReusableView.module.js +0 -63
- package/dist/ReusableView.module.js.map +0 -1
- package/dist/Size.main.js +0 -40
- package/dist/Size.main.js.map +0 -1
- package/dist/Size.mjs +0 -35
- package/dist/Size.module.js +0 -35
- package/dist/Size.module.js.map +0 -1
- package/dist/Virtualizer.main.js +0 -239
- package/dist/Virtualizer.main.js.map +0 -1
- package/dist/Virtualizer.mjs +0 -234
- package/dist/Virtualizer.module.js +0 -234
- package/dist/Virtualizer.module.js.map +0 -1
- package/dist/types.d.ts +0 -368
- package/dist/types.d.ts.map +0 -1
- package/dist/useVirtualizerState.main.js +0 -101
- package/dist/useVirtualizerState.main.js.map +0 -1
- package/dist/useVirtualizerState.mjs +0 -92
- package/dist/useVirtualizerState.module.js +0 -92
- package/dist/useVirtualizerState.module.js.map +0 -1
- package/dist/utils.main.js +0 -27
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -22
- package/dist/utils.module.js +0 -22
- package/dist/utils.module.js.map +0 -1
- package/src/Layout.ts +0 -101
- package/src/LayoutInfo.ts +0 -118
- package/src/OverscanManager.ts +0 -56
- package/src/Point.ts +0 -45
- package/src/Rect.ts +0 -193
- package/src/ReusableView.ts +0 -98
- package/src/Size.ts +0 -43
- package/src/Virtualizer.ts +0 -363
- package/src/types.ts +0 -44
- package/src/useVirtualizerState.ts +0 -120
- package/src/utils.ts +0 -30
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import {Rect as $60423f92c7f9ad87$export$c79fc6492f3af13d} from "./Rect.module.js";
|
|
2
|
-
import {Virtualizer as $38b9490c1cca8fc4$export$89be5a243e59c4b2} from "./Virtualizer.module.js";
|
|
3
|
-
import $3Fik3$react, {useState as $3Fik3$useState, useRef as $3Fik3$useRef, useMemo as $3Fik3$useMemo, useCallback as $3Fik3$useCallback} from "react";
|
|
4
|
-
|
|
5
|
-
/*
|
|
6
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
7
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
9
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
-
*
|
|
11
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
12
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
13
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
14
|
-
* governing permissions and limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const $fc0b13b484ac1194$export$e5c5a5f917a5871c = typeof document !== 'undefined' ? (0, $3Fik3$react).useLayoutEffect : ()=>{};
|
|
19
|
-
function $fc0b13b484ac1194$export$1505db82fe357e65(opts) {
|
|
20
|
-
let [visibleRect, setVisibleRect] = (0, $3Fik3$useState)(new (0, $60423f92c7f9ad87$export$c79fc6492f3af13d)(0, 0, 0, 0));
|
|
21
|
-
let [isScrolling, setScrolling] = (0, $3Fik3$useState)(false);
|
|
22
|
-
let [invalidationContext, setInvalidationContext] = (0, $3Fik3$useState)({});
|
|
23
|
-
let visibleRectChanged = (0, $3Fik3$useRef)(false);
|
|
24
|
-
let [virtualizer] = (0, $3Fik3$useState)(()=>new (0, $38b9490c1cca8fc4$export$89be5a243e59c4b2)({
|
|
25
|
-
collection: opts.collection,
|
|
26
|
-
layout: opts.layout,
|
|
27
|
-
delegate: {
|
|
28
|
-
setVisibleRect (rect) {
|
|
29
|
-
setVisibleRect(rect);
|
|
30
|
-
visibleRectChanged.current = true;
|
|
31
|
-
},
|
|
32
|
-
// TODO: should changing these invalidate the entire cache?
|
|
33
|
-
renderView: opts.renderView,
|
|
34
|
-
invalidate: setInvalidationContext
|
|
35
|
-
}
|
|
36
|
-
}));
|
|
37
|
-
// onVisibleRectChange must be called from an effect, not during render.
|
|
38
|
-
$fc0b13b484ac1194$export$e5c5a5f917a5871c(()=>{
|
|
39
|
-
if (visibleRectChanged.current) {
|
|
40
|
-
visibleRectChanged.current = false;
|
|
41
|
-
opts.onVisibleRectChange(visibleRect);
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
let mergedInvalidationContext = (0, $3Fik3$useMemo)(()=>{
|
|
45
|
-
if (opts.layoutOptions != null) return {
|
|
46
|
-
...invalidationContext,
|
|
47
|
-
layoutOptions: opts.layoutOptions
|
|
48
|
-
};
|
|
49
|
-
return invalidationContext;
|
|
50
|
-
}, [
|
|
51
|
-
invalidationContext,
|
|
52
|
-
opts.layoutOptions
|
|
53
|
-
]);
|
|
54
|
-
let visibleViews = virtualizer.render({
|
|
55
|
-
layout: opts.layout,
|
|
56
|
-
collection: opts.collection,
|
|
57
|
-
persistedKeys: opts.persistedKeys,
|
|
58
|
-
layoutOptions: opts.layoutOptions,
|
|
59
|
-
visibleRect: visibleRect,
|
|
60
|
-
invalidationContext: mergedInvalidationContext,
|
|
61
|
-
isScrolling: isScrolling
|
|
62
|
-
});
|
|
63
|
-
let contentSize = virtualizer.contentSize;
|
|
64
|
-
let startScrolling = (0, $3Fik3$useCallback)(()=>{
|
|
65
|
-
setScrolling(true);
|
|
66
|
-
}, []);
|
|
67
|
-
let endScrolling = (0, $3Fik3$useCallback)(()=>{
|
|
68
|
-
setScrolling(false);
|
|
69
|
-
}, []);
|
|
70
|
-
let state = (0, $3Fik3$useMemo)(()=>({
|
|
71
|
-
virtualizer: virtualizer,
|
|
72
|
-
visibleViews: visibleViews,
|
|
73
|
-
setVisibleRect: setVisibleRect,
|
|
74
|
-
contentSize: contentSize,
|
|
75
|
-
isScrolling: isScrolling,
|
|
76
|
-
startScrolling: startScrolling,
|
|
77
|
-
endScrolling: endScrolling
|
|
78
|
-
}), [
|
|
79
|
-
virtualizer,
|
|
80
|
-
visibleViews,
|
|
81
|
-
setVisibleRect,
|
|
82
|
-
contentSize,
|
|
83
|
-
isScrolling,
|
|
84
|
-
startScrolling,
|
|
85
|
-
endScrolling
|
|
86
|
-
]);
|
|
87
|
-
return state;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
export {$fc0b13b484ac1194$export$e5c5a5f917a5871c as useLayoutEffect, $fc0b13b484ac1194$export$1505db82fe357e65 as useVirtualizerState};
|
|
92
|
-
//# sourceMappingURL=useVirtualizerState.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAcM,MAAM,4CAAgD,OAAO,aAAa,cAC7E,CAAA,GAAA,YAAI,EAAE,eAAe,GACrB,KAAO;AAqBJ,SAAS,0CAAkD,IAA+B;IAC/F,IAAI,CAAC,aAAa,eAAe,GAAG,CAAA,GAAA,eAAO,EAAE,IAAI,CAAA,GAAA,yCAAG,EAAE,GAAG,GAAG,GAAG;IAC/D,IAAI,CAAC,aAAa,aAAa,GAAG,CAAA,GAAA,eAAO,EAAE;IAC3C,IAAI,CAAC,qBAAqB,uBAAuB,GAAG,CAAA,GAAA,eAAO,EAAuB,CAAC;IACnF,IAAI,qBAAqB,CAAA,GAAA,aAAK,EAAE;IAChC,IAAI,CAAC,YAAY,GAAG,CAAA,GAAA,eAAO,EAAE,IAAM,IAAI,CAAA,GAAA,yCAAU,EAAQ;YACvD,YAAY,KAAK,UAAU;YAC3B,QAAQ,KAAK,MAAM;YACnB,UAAU;gBACR,gBAAe,IAAI;oBACjB,eAAe;oBACf,mBAAmB,OAAO,GAAG;gBAC/B;gBACA,2DAA2D;gBAC3D,YAAY,KAAK,UAAU;gBAC3B,YAAY;YACd;QACF;IAEA,wEAAwE;IACxE,0CAAgB;QACd,IAAI,mBAAmB,OAAO,EAAE;YAC9B,mBAAmB,OAAO,GAAG;YAC7B,KAAK,mBAAmB,CAAC;QAC3B;IACF;IAEA,IAAI,4BAA4B,CAAA,GAAA,cAAM,EAAE;QACtC,IAAI,KAAK,aAAa,IAAI,MACxB,OAAO;YAAC,GAAG,mBAAmB;YAAE,eAAe,KAAK,aAAa;QAAA;QAEnE,OAAO;IACT,GAAG;QAAC;QAAqB,KAAK,aAAa;KAAC;IAE5C,IAAI,eAAe,YAAY,MAAM,CAAC;QACpC,QAAQ,KAAK,MAAM;QACnB,YAAY,KAAK,UAAU;QAC3B,eAAe,KAAK,aAAa;QACjC,eAAe,KAAK,aAAa;qBACjC;QACA,qBAAqB;qBACrB;IACF;IAEA,IAAI,cAAc,YAAY,WAAW;IAEzC,IAAI,iBAAiB,CAAA,GAAA,kBAAU,EAAE;QAC/B,aAAa;IACf,GAAG,EAAE;IACL,IAAI,eAAe,CAAA,GAAA,kBAAU,EAAE;QAC7B,aAAa;IACf,GAAG,EAAE;IAEL,IAAI,QAAQ,CAAA,GAAA,cAAM,EAAE,IAAO,CAAA;yBACzB;0BACA;4BACA;yBACA;yBACA;4BACA;0BACA;QACF,CAAA,GAAI;QACF;QACA;QACA;QACA;QACA;QACA;QACA;KACD;IAED,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/useVirtualizerState.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, Key} from '@react-types/shared';\nimport {InvalidationContext} from './types';\nimport {Layout} from './Layout';\nimport React, {useCallback, useMemo, useRef, useState} from 'react';\nimport {Rect} from './Rect';\nimport {ReusableView} from './ReusableView';\nimport {Size} from './Size';\nimport {Virtualizer} from './Virtualizer';\n\n// During SSR, React emits a warning when calling useLayoutEffect.\n// Since neither useLayoutEffect nor useEffect run on the server,\n// we can suppress this by replace it with a noop on the server.\nexport const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined'\n ? React.useLayoutEffect\n : () => {};\n\ninterface VirtualizerProps<T extends object, V, O> {\n renderView(type: string, content: T | null): V,\n layout: Layout<T>,\n collection: Collection<T>,\n onVisibleRectChange(rect: Rect): void,\n persistedKeys?: Set<Key> | null,\n layoutOptions?: O\n}\n\nexport interface VirtualizerState<T extends object, V> {\n visibleViews: ReusableView<T, V>[],\n setVisibleRect: (rect: Rect) => void,\n contentSize: Size,\n virtualizer: Virtualizer<T, V>,\n isScrolling: boolean,\n startScrolling: () => void,\n endScrolling: () => void\n}\n\nexport function useVirtualizerState<T extends object, V, O = any>(opts: VirtualizerProps<T, V, O>): VirtualizerState<T, V> {\n let [visibleRect, setVisibleRect] = useState(new Rect(0, 0, 0, 0));\n let [isScrolling, setScrolling] = useState(false);\n let [invalidationContext, setInvalidationContext] = useState<InvalidationContext>({});\n let visibleRectChanged = useRef(false);\n let [virtualizer] = useState(() => new Virtualizer<T, V>({\n collection: opts.collection,\n layout: opts.layout,\n delegate: {\n setVisibleRect(rect) {\n setVisibleRect(rect);\n visibleRectChanged.current = true;\n },\n // TODO: should changing these invalidate the entire cache?\n renderView: opts.renderView,\n invalidate: setInvalidationContext\n }\n }));\n\n // onVisibleRectChange must be called from an effect, not during render.\n useLayoutEffect(() => {\n if (visibleRectChanged.current) {\n visibleRectChanged.current = false;\n opts.onVisibleRectChange(visibleRect);\n }\n });\n\n let mergedInvalidationContext = useMemo(() => {\n if (opts.layoutOptions != null) {\n return {...invalidationContext, layoutOptions: opts.layoutOptions};\n }\n return invalidationContext;\n }, [invalidationContext, opts.layoutOptions]);\n\n let visibleViews = virtualizer.render({\n layout: opts.layout,\n collection: opts.collection,\n persistedKeys: opts.persistedKeys,\n layoutOptions: opts.layoutOptions,\n visibleRect,\n invalidationContext: mergedInvalidationContext,\n isScrolling\n });\n\n let contentSize = virtualizer.contentSize;\n\n let startScrolling = useCallback(() => {\n setScrolling(true);\n }, []);\n let endScrolling = useCallback(() => {\n setScrolling(false);\n }, []);\n\n let state = useMemo(() => ({\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n }), [\n virtualizer,\n visibleViews,\n setVisibleRect,\n contentSize,\n isScrolling,\n startScrolling,\n endScrolling\n ]);\n\n return state;\n}\n"],"names":[],"version":3,"file":"useVirtualizerState.module.js.map"}
|
package/dist/utils.main.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
function $parcel$export(e, n, v, s) {
|
|
3
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
$parcel$export(module.exports, "isSetEqual", () => $abed55ea619a7a17$export$a8d0d0c8d1c5df64);
|
|
7
|
-
/*
|
|
8
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
9
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
11
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
14
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
15
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
16
|
-
* governing permissions and limitations under the License.
|
|
17
|
-
*/ /** Returns whether two sets are equal. */ function $abed55ea619a7a17$export$a8d0d0c8d1c5df64(a, b) {
|
|
18
|
-
if (a === b) return true;
|
|
19
|
-
if (a.size !== b.size) return false;
|
|
20
|
-
for (let key of a){
|
|
21
|
-
if (!b.has(key)) return false;
|
|
22
|
-
}
|
|
23
|
-
return true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//# sourceMappingURL=utils.main.js.map
|
package/dist/utils.main.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC,GAED,wCAAwC,GACjC,SAAS,0CAAc,CAAS,EAAE,CAAS;IAChD,IAAI,MAAM,GACR,OAAO;IAGT,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EACnB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAG;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/** Returns whether two sets are equal. */\nexport function isSetEqual<T>(a: Set<T>, b: Set<T>): boolean {\n if (a === b) {\n return true;\n }\n\n if (a.size !== b.size) {\n return false;\n }\n\n for (let key of a) {\n if (!b.has(key)) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"utils.main.js.map"}
|
package/dist/utils.mjs
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/ /** Returns whether two sets are equal. */ function $fc36f9a046a9ce79$export$a8d0d0c8d1c5df64(a, b) {
|
|
12
|
-
if (a === b) return true;
|
|
13
|
-
if (a.size !== b.size) return false;
|
|
14
|
-
for (let key of a){
|
|
15
|
-
if (!b.has(key)) return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export {$fc36f9a046a9ce79$export$a8d0d0c8d1c5df64 as isSetEqual};
|
|
22
|
-
//# sourceMappingURL=utils.module.js.map
|
package/dist/utils.module.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/ /** Returns whether two sets are equal. */ function $fc36f9a046a9ce79$export$a8d0d0c8d1c5df64(a, b) {
|
|
12
|
-
if (a === b) return true;
|
|
13
|
-
if (a.size !== b.size) return false;
|
|
14
|
-
for (let key of a){
|
|
15
|
-
if (!b.has(key)) return false;
|
|
16
|
-
}
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export {$fc36f9a046a9ce79$export$a8d0d0c8d1c5df64 as isSetEqual};
|
|
22
|
-
//# sourceMappingURL=utils.module.js.map
|
package/dist/utils.module.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":"AAAA;;;;;;;;;;CAUC,GAED,wCAAwC,GACjC,SAAS,0CAAc,CAAS,EAAE,CAAS;IAChD,IAAI,MAAM,GACR,OAAO;IAGT,IAAI,EAAE,IAAI,KAAK,EAAE,IAAI,EACnB,OAAO;IAGT,KAAK,IAAI,OAAO,EAAG;QACjB,IAAI,CAAC,EAAE,GAAG,CAAC,MACT,OAAO;IAEX;IAEA,OAAO;AACT","sources":["packages/@react-stately/virtualizer/src/utils.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/** Returns whether two sets are equal. */\nexport function isSetEqual<T>(a: Set<T>, b: Set<T>): boolean {\n if (a === b) {\n return true;\n }\n\n if (a.size !== b.size) {\n return false;\n }\n\n for (let key of a) {\n if (!b.has(key)) {\n return false;\n }\n }\n\n return true;\n}\n"],"names":[],"version":3,"file":"utils.module.js.map"}
|
package/src/Layout.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {InvalidationContext} from './types';
|
|
14
|
-
import {ItemDropTarget, Key, LayoutDelegate, Node} from '@react-types/shared';
|
|
15
|
-
import {LayoutInfo} from './LayoutInfo';
|
|
16
|
-
import {Rect} from './Rect';
|
|
17
|
-
import {Size} from './Size';
|
|
18
|
-
import {Virtualizer} from './Virtualizer';
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Virtualizer supports arbitrary layout objects, which compute what items are visible, and how
|
|
22
|
-
* to position and style them. However, layouts do not render items directly. Instead,
|
|
23
|
-
* layouts produce lightweight LayoutInfo objects which describe various properties of an item,
|
|
24
|
-
* such as its position and size. The Virtualizer is then responsible for creating the actual
|
|
25
|
-
* views as needed, based on this layout information.
|
|
26
|
-
*
|
|
27
|
-
* Every layout extends from the Layout abstract base class. Layouts must implement the `getVisibleLayoutInfos`,
|
|
28
|
-
* `getLayoutInfo`, and `getContentSize` methods. All other methods can be optionally overridden to implement custom behavior.
|
|
29
|
-
*/
|
|
30
|
-
export abstract class Layout<T extends object = Node<any>, O = any> implements LayoutDelegate {
|
|
31
|
-
/** The Virtualizer the layout is currently attached to. */
|
|
32
|
-
virtualizer: Virtualizer<T, any> | null = null;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Returns an array of `LayoutInfo` objects which are inside the given rectangle.
|
|
36
|
-
* Should be implemented by subclasses.
|
|
37
|
-
* @param rect The rectangle that should contain the returned LayoutInfo objects.
|
|
38
|
-
*/
|
|
39
|
-
abstract getVisibleLayoutInfos(rect: Rect): LayoutInfo[];
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Returns a `LayoutInfo` for the given key.
|
|
43
|
-
* Should be implemented by subclasses.
|
|
44
|
-
* @param key The key of the LayoutInfo to retrieve.
|
|
45
|
-
*/
|
|
46
|
-
abstract getLayoutInfo(key: Key): LayoutInfo | null;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Returns size of the content. By default, it returns virtualizer's size.
|
|
50
|
-
*/
|
|
51
|
-
abstract getContentSize(): Size;
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Returns whether the layout should invalidate in response to
|
|
55
|
-
* visible rectangle changes. By default, it only invalidates
|
|
56
|
-
* when the virtualizer's size changes. Return true always
|
|
57
|
-
* to make the layout invalidate while scrolling (e.g. sticky headers).
|
|
58
|
-
*/
|
|
59
|
-
shouldInvalidate(newRect: Rect, oldRect: Rect): boolean {
|
|
60
|
-
// By default, invalidate when the size changes
|
|
61
|
-
return newRect.width !== oldRect.width
|
|
62
|
-
|| newRect.height !== oldRect.height;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Returns whether the layout should invalidate when the layout options change.
|
|
67
|
-
* By default it invalidates when the object identity changes. Override this
|
|
68
|
-
* method to optimize layout updates based on specific option changes.
|
|
69
|
-
*/
|
|
70
|
-
shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {
|
|
71
|
-
return newOptions !== oldOptions;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* This method allows the layout to perform any pre-computation
|
|
76
|
-
* it needs to in order to prepare LayoutInfos for retrieval.
|
|
77
|
-
* Called by the virtualizer before `getVisibleLayoutInfos`
|
|
78
|
-
* or `getLayoutInfo` are called.
|
|
79
|
-
*/
|
|
80
|
-
update(invalidationContext: InvalidationContext<O>): void {} // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Updates the size of the given item.
|
|
84
|
-
*/
|
|
85
|
-
updateItemSize?(key: Key, size: Size): boolean;
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Returns a `LayoutInfo` for the given drop target.
|
|
89
|
-
*/
|
|
90
|
-
getDropTargetLayoutInfo?(target: ItemDropTarget): LayoutInfo;
|
|
91
|
-
|
|
92
|
-
/** @private */
|
|
93
|
-
getItemRect(key: Key): Rect | null {
|
|
94
|
-
return this.getLayoutInfo(key)?.rect ?? null;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** @private */
|
|
98
|
-
getVisibleRect(): Rect {
|
|
99
|
-
return this.virtualizer!.visibleRect;
|
|
100
|
-
}
|
|
101
|
-
}
|
package/src/LayoutInfo.ts
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {Key} from '@react-types/shared';
|
|
14
|
-
import {Rect} from './Rect';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Instances of this lightweight class are created by `Layout` subclasses
|
|
18
|
-
* to represent each item in the `Virtualizer`. LayoutInfo objects describe
|
|
19
|
-
* various properties of an item, such as its position and size, and style information.
|
|
20
|
-
* The virtualizer uses this information when creating actual DOM elements to display.
|
|
21
|
-
*/
|
|
22
|
-
export class LayoutInfo {
|
|
23
|
-
/**
|
|
24
|
-
* The type of element represented by this LayoutInfo. Should match the `type` of the corresponding collection node.
|
|
25
|
-
*/
|
|
26
|
-
type: string;
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* A unique key for this LayoutInfo. Should match the `key` of the corresponding collection node.
|
|
30
|
-
*/
|
|
31
|
-
key: Key;
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* The key for a parent LayoutInfo, if any.
|
|
35
|
-
*/
|
|
36
|
-
parentKey: Key | null;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Content for this item if it was generated by the layout rather than coming from the Collection.
|
|
40
|
-
*/
|
|
41
|
-
content: any | null;
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* The rectangle describing the size and position of this element.
|
|
45
|
-
*/
|
|
46
|
-
rect: Rect;
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Whether the size is estimated. `false` by default.
|
|
50
|
-
* Items with estimated sizes will be measured the first time they are added to the DOM.
|
|
51
|
-
* The estimated size is used to calculate the size and position of the scrollbar.
|
|
52
|
-
* @default false
|
|
53
|
-
*/
|
|
54
|
-
estimatedSize: boolean;
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Whether the layout info sticks to the viewport when scrolling.
|
|
58
|
-
* @default false
|
|
59
|
-
*/
|
|
60
|
-
isSticky: boolean;
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* The element's opacity.
|
|
64
|
-
* @default 1
|
|
65
|
-
*/
|
|
66
|
-
opacity: number;
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A CSS transform string to apply to the element. `null` by default.
|
|
70
|
-
*/
|
|
71
|
-
transform: string | null;
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* The z-index of the element. 0 by default.
|
|
75
|
-
*/
|
|
76
|
-
zIndex: number;
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Whether the element allows its contents to overflow its container.
|
|
80
|
-
* @default false
|
|
81
|
-
*/
|
|
82
|
-
allowOverflow: boolean;
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* @param type The type of element represented by this LayoutInfo. Should match the `type` of the corresponding collection node.
|
|
86
|
-
* @param key A unique key for this LayoutInfo. Should match the `key` of the corresponding collection node.
|
|
87
|
-
* @param rect The rectangle describing the size and position of this element.
|
|
88
|
-
*/
|
|
89
|
-
constructor(type: string, key: Key, rect: Rect) {
|
|
90
|
-
this.type = type;
|
|
91
|
-
this.key = key;
|
|
92
|
-
this.parentKey = null;
|
|
93
|
-
this.content = null;
|
|
94
|
-
this.rect = rect;
|
|
95
|
-
this.estimatedSize = false;
|
|
96
|
-
this.isSticky = false;
|
|
97
|
-
this.opacity = 1;
|
|
98
|
-
this.transform = null;
|
|
99
|
-
this.zIndex = 0;
|
|
100
|
-
this.allowOverflow = false;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Returns a copy of the LayoutInfo.
|
|
105
|
-
*/
|
|
106
|
-
copy(): LayoutInfo {
|
|
107
|
-
let res = new LayoutInfo(this.type, this.key, this.rect.copy());
|
|
108
|
-
res.estimatedSize = this.estimatedSize;
|
|
109
|
-
res.opacity = this.opacity;
|
|
110
|
-
res.transform = this.transform;
|
|
111
|
-
res.parentKey = this.parentKey;
|
|
112
|
-
res.content = this.content;
|
|
113
|
-
res.isSticky = this.isSticky;
|
|
114
|
-
res.zIndex = this.zIndex;
|
|
115
|
-
res.allowOverflow = this.allowOverflow;
|
|
116
|
-
return res;
|
|
117
|
-
}
|
|
118
|
-
}
|
package/src/OverscanManager.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
import {Point} from './Point';
|
|
14
|
-
import {Rect} from './Rect';
|
|
15
|
-
|
|
16
|
-
export class OverscanManager {
|
|
17
|
-
private startTime = 0;
|
|
18
|
-
private velocity = new Point(0, 0);
|
|
19
|
-
private visibleRect = new Rect();
|
|
20
|
-
|
|
21
|
-
setVisibleRect(rect: Rect): void {
|
|
22
|
-
let time = performance.now() - this.startTime;
|
|
23
|
-
if (time < 500) {
|
|
24
|
-
if (rect.x !== this.visibleRect.x && time > 0) {
|
|
25
|
-
this.velocity.x = (rect.x - this.visibleRect.x) / time;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (rect.y !== this.visibleRect.y && time > 0) {
|
|
29
|
-
this.velocity.y = (rect.y - this.visibleRect.y) / time;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
this.startTime = performance.now();
|
|
34
|
-
this.visibleRect = rect;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
getOverscannedRect(): Rect {
|
|
38
|
-
let overscanned = this.visibleRect.copy();
|
|
39
|
-
|
|
40
|
-
let overscanY = this.visibleRect.height / 3;
|
|
41
|
-
overscanned.height += overscanY;
|
|
42
|
-
if (this.velocity.y < 0) {
|
|
43
|
-
overscanned.y -= overscanY;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
if (this.velocity.x !== 0) {
|
|
47
|
-
let overscanX = this.visibleRect.width / 3;
|
|
48
|
-
overscanned.width += overscanX;
|
|
49
|
-
if (this.velocity.x < 0) {
|
|
50
|
-
overscanned.x -= overscanX;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return overscanned;
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/Point.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
3
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
-
*
|
|
7
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
-
* governing permissions and limitations under the License.
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
export class Point {
|
|
14
|
-
/** The x-coordinate of the point. */
|
|
15
|
-
x: number;
|
|
16
|
-
|
|
17
|
-
/** The y-coordinate of the point. */
|
|
18
|
-
y: number;
|
|
19
|
-
|
|
20
|
-
constructor(x = 0, y = 0) {
|
|
21
|
-
this.x = x;
|
|
22
|
-
this.y = y;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Returns a copy of this point.
|
|
27
|
-
*/
|
|
28
|
-
copy(): Point {
|
|
29
|
-
return new Point(this.x, this.y);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Checks if two points are equal.
|
|
34
|
-
*/
|
|
35
|
-
equals(point: Point): boolean {
|
|
36
|
-
return this.x === point.x && this.y === point.y;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Returns true if this point is the origin.
|
|
41
|
-
*/
|
|
42
|
-
isOrigin(): boolean {
|
|
43
|
-
return this.x === 0 && this.y === 0;
|
|
44
|
-
}
|
|
45
|
-
}
|