@react-aria/virtualizer 4.1.13 → 4.2.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 +6 -6
- package/dist/main.js +14 -14
- package/dist/main.js.map +1 -1
- package/dist/module.js +6 -6
- package/dist/module.js.map +1 -1
- package/dist/types/src/index.d.ts +7 -0
- package/package.json +15 -16
- package/src/index.ts +8 -7
- package/dist/ScrollView.main.js +0 -228
- package/dist/ScrollView.main.js.map +0 -1
- package/dist/ScrollView.mjs +0 -218
- package/dist/ScrollView.module.js +0 -218
- package/dist/ScrollView.module.js.map +0 -1
- package/dist/Virtualizer.main.js +0 -84
- package/dist/Virtualizer.main.js.map +0 -1
- package/dist/Virtualizer.mjs +0 -75
- package/dist/Virtualizer.module.js +0 -75
- package/dist/Virtualizer.module.js.map +0 -1
- package/dist/VirtualizerItem.main.js +0 -90
- package/dist/VirtualizerItem.main.js.map +0 -1
- package/dist/VirtualizerItem.mjs +0 -80
- package/dist/VirtualizerItem.module.js +0 -80
- package/dist/VirtualizerItem.module.js.map +0 -1
- package/dist/types.d.ts +0 -60
- package/dist/types.d.ts.map +0 -1
- package/dist/useVirtualizerItem.main.js +0 -54
- package/dist/useVirtualizerItem.main.js.map +0 -1
- package/dist/useVirtualizerItem.mjs +0 -49
- package/dist/useVirtualizerItem.module.js +0 -49
- package/dist/useVirtualizerItem.module.js.map +0 -1
- package/dist/utils.main.js +0 -80
- package/dist/utils.main.js.map +0 -1
- package/dist/utils.mjs +0 -73
- package/dist/utils.module.js +0 -73
- package/dist/utils.module.js.map +0 -1
- package/src/ScrollView.tsx +0 -282
- package/src/Virtualizer.tsx +0 -113
- package/src/VirtualizerItem.tsx +0 -93
- package/src/useVirtualizerItem.ts +0 -55
- package/src/utils.ts +0 -107
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import {ScrollView as $44a6ee657928b002$export$5665e3d6be6adea} from "./ScrollView.module.js";
|
|
2
|
-
import {VirtualizerItem as $ccf8a0a04e4175ae$export$6796df8ba7398521} from "./VirtualizerItem.module.js";
|
|
3
|
-
import {useVirtualizerState as $9WwqA$useVirtualizerState} from "@react-stately/virtualizer";
|
|
4
|
-
import {useObjectRef as $9WwqA$useObjectRef, useLoadMore as $9WwqA$useLoadMore, mergeProps as $9WwqA$mergeProps} from "@react-aria/utils";
|
|
5
|
-
import $9WwqA$react, {useCallback as $9WwqA$useCallback} from "react";
|
|
6
|
-
|
|
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
|
-
*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const $6d0a5c394373ae64$export$89be5a243e59c4b2 = /*#__PURE__*/ (0, $9WwqA$react).forwardRef(function Virtualizer(props, forwardedRef) {
|
|
23
|
-
let { children: renderView, renderWrapper: renderWrapper, layout: layout, collection: collection, scrollDirection: scrollDirection, isLoading: isLoading, onLoadMore: onLoadMore, persistedKeys: persistedKeys, layoutOptions: layoutOptions, ...otherProps } = props;
|
|
24
|
-
let ref = (0, $9WwqA$useObjectRef)(forwardedRef);
|
|
25
|
-
let state = (0, $9WwqA$useVirtualizerState)({
|
|
26
|
-
layout: layout,
|
|
27
|
-
collection: collection,
|
|
28
|
-
renderView: renderView,
|
|
29
|
-
onVisibleRectChange (rect) {
|
|
30
|
-
if (ref.current) {
|
|
31
|
-
ref.current.scrollLeft = rect.x;
|
|
32
|
-
ref.current.scrollTop = rect.y;
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
persistedKeys: persistedKeys,
|
|
36
|
-
layoutOptions: layoutOptions
|
|
37
|
-
});
|
|
38
|
-
(0, $9WwqA$useLoadMore)({
|
|
39
|
-
isLoading: isLoading,
|
|
40
|
-
onLoadMore: onLoadMore,
|
|
41
|
-
scrollOffset: 1
|
|
42
|
-
}, ref);
|
|
43
|
-
let onVisibleRectChange = (0, $9WwqA$useCallback)((rect)=>{
|
|
44
|
-
state.setVisibleRect(rect);
|
|
45
|
-
}, [
|
|
46
|
-
state
|
|
47
|
-
]);
|
|
48
|
-
return /*#__PURE__*/ (0, $9WwqA$react).createElement((0, $44a6ee657928b002$export$5665e3d6be6adea), {
|
|
49
|
-
...(0, $9WwqA$mergeProps)(otherProps, {
|
|
50
|
-
onVisibleRectChange: onVisibleRectChange
|
|
51
|
-
}),
|
|
52
|
-
ref: ref,
|
|
53
|
-
contentSize: state.contentSize,
|
|
54
|
-
onScrollStart: state.startScrolling,
|
|
55
|
-
onScrollEnd: state.endScrolling,
|
|
56
|
-
scrollDirection: scrollDirection
|
|
57
|
-
}, $6d0a5c394373ae64$var$renderChildren(null, state.visibleViews, renderWrapper || $6d0a5c394373ae64$var$defaultRenderWrapper));
|
|
58
|
-
});
|
|
59
|
-
function $6d0a5c394373ae64$var$renderChildren(parent, views, renderWrapper) {
|
|
60
|
-
return views.map((view)=>{
|
|
61
|
-
return renderWrapper(parent, view, view.children ? Array.from(view.children) : [], (childViews)=>$6d0a5c394373ae64$var$renderChildren(view, childViews, renderWrapper));
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function $6d0a5c394373ae64$var$defaultRenderWrapper(parent, reusableView) {
|
|
65
|
-
return /*#__PURE__*/ (0, $9WwqA$react).createElement((0, $ccf8a0a04e4175ae$export$6796df8ba7398521), {
|
|
66
|
-
key: reusableView.key,
|
|
67
|
-
layoutInfo: reusableView.layoutInfo,
|
|
68
|
-
virtualizer: reusableView.virtualizer,
|
|
69
|
-
parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
|
|
70
|
-
}, reusableView.rendered);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
export {$6d0a5c394373ae64$export$89be5a243e59c4b2 as Virtualizer};
|
|
75
|
-
//# sourceMappingURL=Virtualizer.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAAA;;;;;;;;;;CAUC;;;;;AA8BM,MAAM,0DAAc,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,YAAsD,KAAgC,EAAE,YAAiD;IAC5L,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,mBACV,eAAe,aACf,SAAS,cACT,UAAU,iBACV,aAAa,iBACb,aAAa,EACb,GAAG,YACJ,GAAG;IAEJ,IAAI,MAAM,CAAA,GAAA,mBAAW,EAAE;IAEvB,IAAI,QAAQ,CAAA,GAAA,0BAAkB,EAAE;gBAC9B;oBACA;oBACA;QACA,qBAAoB,IAAI;YACtB,IAAI,IAAI,OAAO,EAAE;gBACf,IAAI,OAAO,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC/B,IAAI,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC;YAChC;QACF;uBACA;uBACA;IACF;IAEA,CAAA,GAAA,kBAAU,EAAE;mBAAC;oBAAW;QAAY,cAAc;IAAC,GAAG;IACtD,IAAI,sBAAsB,CAAA,GAAA,kBAAU,EAAE,CAAC;QACrC,MAAM,cAAc,CAAC;IACvB,GAAG;QAAC;KAAM;IAEV,qBACE,gCAAC,CAAA,GAAA,wCAAS;QACP,GAAG,CAAA,GAAA,iBAAS,EAAE,YAAY;iCAAC;QAAmB,EAAE;QACjD,KAAK;QACL,aAAa,MAAM,WAAW;QAC9B,eAAe,MAAM,cAAc;QACnC,aAAa,MAAM,YAAY;QAC/B,iBAAiB;OAChB,qCAAe,MAAM,MAAM,YAAY,EAAE,iBAAiB;AAGjE;AAEA,SAAS,qCAAoC,MAAiC,EAAE,KAA2B,EAAE,aAAkC;IAC7I,OAAO,MAAM,GAAG,CAAC,CAAA;QACf,OAAO,cACL,QACA,MACA,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,QAAQ,IAAI,EAAE,EAC9C,CAAA,aAAc,qCAAe,MAAM,YAAY;IAEnD;AACF;AAEA,SAAS,2CACP,MAAiC,EACjC,YAAgC;IAEhC,qBACE,gCAAC,CAAA,GAAA,yCAAc;QACb,KAAK,aAAa,GAAG;QACrB,YAAY,aAAa,UAAU;QACnC,aAAa,aAAa,WAAW;QACrC,MAAM,EAAE,mBAAA,6BAAA,OAAQ,UAAU;OACzB,aAAa,QAAQ;AAG5B","sources":["packages/@react-aria/virtualizer/src/Virtualizer.tsx"],"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, RefObject} from '@react-types/shared';\nimport {Layout, Rect, ReusableView, useVirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLoadMore, useObjectRef} from '@react-aria/utils';\nimport React, {ForwardedRef, HTMLAttributes, ReactElement, ReactNode, useCallback} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ntype RenderWrapper<T extends object, V> = (\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>,\n children: ReusableView<T, V>[],\n renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]\n) => ReactElement | null;\n\ninterface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: RenderWrapper<T, V>,\n layout: Layout<T, O>,\n collection: Collection<T>,\n persistedKeys?: Set<Key> | null,\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n isLoading?: boolean,\n onLoadMore?: () => void,\n layoutOptions?: O\n}\n\n// forwardRef doesn't support generic parameters, so cast the result to the correct type\n// https://stackoverflow.com/questions/58469229/react-with-typescript-generics-while-using-react-forwardref\nexport const Virtualizer = React.forwardRef(function Virtualizer<T extends object, V extends ReactNode, O>(props: VirtualizerProps<T, V, O>, forwardedRef: ForwardedRef<HTMLDivElement | null>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n scrollDirection,\n isLoading,\n onLoadMore,\n persistedKeys,\n layoutOptions,\n ...otherProps\n } = props;\n\n let ref = useObjectRef(forwardedRef);\n\n let state = useVirtualizerState({\n layout,\n collection,\n renderView,\n onVisibleRectChange(rect) {\n if (ref.current) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n },\n persistedKeys,\n layoutOptions\n });\n\n useLoadMore({isLoading, onLoadMore, scrollOffset: 1}, ref);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n }, [state]);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, {onVisibleRectChange})}\n ref={ref}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n scrollDirection={scrollDirection}>\n {renderChildren(null, state.visibleViews, renderWrapper || defaultRenderWrapper)}\n </ScrollView>\n );\n}) as <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {ref?: RefObject<HTMLDivElement | null>}) => ReactElement;\n\nfunction renderChildren<T extends object, V>(parent: ReusableView<T, V> | null, views: ReusableView<T, V>[], renderWrapper: RenderWrapper<T, V>) {\n return views.map(view => {\n return renderWrapper(\n parent,\n view,\n view.children ? Array.from(view.children) : [],\n childViews => renderChildren(view, childViews, renderWrapper)\n );\n });\n}\n\nfunction defaultRenderWrapper<T extends object, V extends ReactNode>(\n parent: ReusableView<T, V> | null,\n reusableView: ReusableView<T, V>\n) {\n return (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo!}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n );\n}\n"],"names":[],"version":3,"file":"Virtualizer.module.js.map"}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
var $7d70e069fceb2deb$exports = require("./useVirtualizerItem.main.js");
|
|
2
|
-
var $eXWCF$react = require("react");
|
|
3
|
-
var $eXWCF$reactariai18n = require("@react-aria/i18n");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function $parcel$interopDefault(a) {
|
|
7
|
-
return a && a.__esModule ? a.default : a;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function $parcel$export(e, n, v, s) {
|
|
11
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
$parcel$export(module.exports, "VirtualizerItem", () => $d6a26279cc31826b$export$6796df8ba7398521);
|
|
15
|
-
$parcel$export(module.exports, "layoutInfoToStyle", () => $d6a26279cc31826b$export$1481e64fbe01b8b3);
|
|
16
|
-
/*
|
|
17
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
18
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
19
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
20
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
21
|
-
*
|
|
22
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
23
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
24
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
25
|
-
* governing permissions and limitations under the License.
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
function $d6a26279cc31826b$export$6796df8ba7398521(props) {
|
|
30
|
-
let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
|
|
31
|
-
let { direction: direction } = (0, $eXWCF$reactariai18n.useLocale)();
|
|
32
|
-
let ref = (0, $eXWCF$react.useRef)(null);
|
|
33
|
-
(0, $7d70e069fceb2deb$exports.useVirtualizerItem)({
|
|
34
|
-
layoutInfo: layoutInfo,
|
|
35
|
-
virtualizer: virtualizer,
|
|
36
|
-
ref: ref
|
|
37
|
-
});
|
|
38
|
-
return /*#__PURE__*/ (0, ($parcel$interopDefault($eXWCF$react))).createElement("div", {
|
|
39
|
-
role: "presentation",
|
|
40
|
-
ref: ref,
|
|
41
|
-
className: className,
|
|
42
|
-
style: {
|
|
43
|
-
...$d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, direction, parent),
|
|
44
|
-
...style
|
|
45
|
-
}
|
|
46
|
-
}, children);
|
|
47
|
-
}
|
|
48
|
-
let $d6a26279cc31826b$var$cache = new WeakMap();
|
|
49
|
-
function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
50
|
-
let xProperty = dir === 'rtl' ? 'right' : 'left';
|
|
51
|
-
let cached = $d6a26279cc31826b$var$cache.get(layoutInfo);
|
|
52
|
-
if (cached && cached[xProperty] != null) {
|
|
53
|
-
if (!parent) return cached;
|
|
54
|
-
// Invalidate if the parent position changed.
|
|
55
|
-
let top = layoutInfo.rect.y - parent.rect.y;
|
|
56
|
-
let x = layoutInfo.rect.x - parent.rect.x;
|
|
57
|
-
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
58
|
-
}
|
|
59
|
-
let rectStyles = {
|
|
60
|
-
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container
|
|
61
|
-
// which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position
|
|
62
|
-
// Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the
|
|
63
|
-
// calculated layoutInfo.y here
|
|
64
|
-
top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),
|
|
65
|
-
[xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),
|
|
66
|
-
width: layoutInfo.rect.width,
|
|
67
|
-
height: layoutInfo.rect.height
|
|
68
|
-
};
|
|
69
|
-
// Get rid of any non finite values since they aren't valid css values
|
|
70
|
-
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
71
|
-
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
72
|
-
});
|
|
73
|
-
var _layoutInfo_transform;
|
|
74
|
-
let style = {
|
|
75
|
-
position: layoutInfo.isSticky ? 'sticky' : 'absolute',
|
|
76
|
-
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
77
|
-
display: layoutInfo.isSticky ? 'inline-block' : undefined,
|
|
78
|
-
overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
|
|
79
|
-
opacity: layoutInfo.opacity,
|
|
80
|
-
zIndex: layoutInfo.zIndex,
|
|
81
|
-
transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
|
|
82
|
-
contain: 'size layout style',
|
|
83
|
-
...rectStyles
|
|
84
|
-
};
|
|
85
|
-
$d6a26279cc31826b$var$cache.set(layoutInfo, style);
|
|
86
|
-
return style;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//# sourceMappingURL=VirtualizerItem.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAgBM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,mBAAK,EAAyB;IACxC,CAAA,GAAA,4CAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,0DAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY,WAAW,OAAO;YAAE,GAAG,KAAK;QAAA;OAC3H;AAGP;AAEA,IAAI,8BAAQ,IAAI;AACT,SAAS,0CAAkB,UAAsB,EAAE,GAAc,EAAE,MAA0B;IAClG,IAAI,YAAY,QAAQ,QAAQ,UAAU;IAC1C,IAAI,SAAS,4BAAM,GAAG,CAAC;IACvB,IAAI,UAAU,MAAM,CAAC,UAAU,IAAI,MAAM;QACvC,IAAI,CAAC,QACH,OAAO;QAGT,6CAA6C;QAC7C,IAAI,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO,GAAG,KAAK,OAAO,MAAM,CAAC,UAAU,KAAK,GAC9C,OAAO;IAEX;IAEA,IAAI,aAAiD;QACnD,wJAAwJ;QACxJ,sIAAsI;QACtI,mJAAmJ;QACnJ,+BAA+B;QAC/B,KAAK,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QACrG,CAAC,UAAU,EAAE,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QAC7G,OAAO,WAAW,IAAI,CAAC,KAAK;QAC5B,QAAQ,WAAW,IAAI,CAAC,MAAM;IAChC;IAEA,sEAAsE;IACtE,OAAO,OAAO,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;QAC9C,IAAI,CAAC,OAAO,QAAQ,CAAC,QACnB,UAAU,CAAC,IAAI,GAAG;IAEtB;QASa;IAPb,IAAI,QAAuB;QACzB,UAAU,WAAW,QAAQ,GAAG,WAAW;QAC3C,qJAAqJ;QACrJ,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,CAAA,wBAAA,WAAW,SAAS,cAApB,mCAAA,wBAAwB;QACnC,SAAS;QACT,GAAG,UAAU;IACf;IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"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 {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, JSX, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n layoutInfo: LayoutInfo,\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps): JSX.Element {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef<HTMLDivElement | null>(null);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles: Record<string, number | undefined> = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform ?? undefined,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.main.js.map"}
|
package/dist/VirtualizerItem.mjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {useVirtualizerItem as $47736c1e63ba1c6d$export$1da781778207e0a2} from "./useVirtualizerItem.mjs";
|
|
2
|
-
import $ivH3G$react, {useRef as $ivH3G$useRef} from "react";
|
|
3
|
-
import {useLocale as $ivH3G$useLocale} from "@react-aria/i18n";
|
|
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
|
-
function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) {
|
|
19
|
-
let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
|
|
20
|
-
let { direction: direction } = (0, $ivH3G$useLocale)();
|
|
21
|
-
let ref = (0, $ivH3G$useRef)(null);
|
|
22
|
-
(0, $47736c1e63ba1c6d$export$1da781778207e0a2)({
|
|
23
|
-
layoutInfo: layoutInfo,
|
|
24
|
-
virtualizer: virtualizer,
|
|
25
|
-
ref: ref
|
|
26
|
-
});
|
|
27
|
-
return /*#__PURE__*/ (0, $ivH3G$react).createElement("div", {
|
|
28
|
-
role: "presentation",
|
|
29
|
-
ref: ref,
|
|
30
|
-
className: className,
|
|
31
|
-
style: {
|
|
32
|
-
...$ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent),
|
|
33
|
-
...style
|
|
34
|
-
}
|
|
35
|
-
}, children);
|
|
36
|
-
}
|
|
37
|
-
let $ccf8a0a04e4175ae$var$cache = new WeakMap();
|
|
38
|
-
function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
39
|
-
let xProperty = dir === 'rtl' ? 'right' : 'left';
|
|
40
|
-
let cached = $ccf8a0a04e4175ae$var$cache.get(layoutInfo);
|
|
41
|
-
if (cached && cached[xProperty] != null) {
|
|
42
|
-
if (!parent) return cached;
|
|
43
|
-
// Invalidate if the parent position changed.
|
|
44
|
-
let top = layoutInfo.rect.y - parent.rect.y;
|
|
45
|
-
let x = layoutInfo.rect.x - parent.rect.x;
|
|
46
|
-
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
47
|
-
}
|
|
48
|
-
let rectStyles = {
|
|
49
|
-
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container
|
|
50
|
-
// which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position
|
|
51
|
-
// Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the
|
|
52
|
-
// calculated layoutInfo.y here
|
|
53
|
-
top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),
|
|
54
|
-
[xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),
|
|
55
|
-
width: layoutInfo.rect.width,
|
|
56
|
-
height: layoutInfo.rect.height
|
|
57
|
-
};
|
|
58
|
-
// Get rid of any non finite values since they aren't valid css values
|
|
59
|
-
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
60
|
-
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
61
|
-
});
|
|
62
|
-
var _layoutInfo_transform;
|
|
63
|
-
let style = {
|
|
64
|
-
position: layoutInfo.isSticky ? 'sticky' : 'absolute',
|
|
65
|
-
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
66
|
-
display: layoutInfo.isSticky ? 'inline-block' : undefined,
|
|
67
|
-
overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
|
|
68
|
-
opacity: layoutInfo.opacity,
|
|
69
|
-
zIndex: layoutInfo.zIndex,
|
|
70
|
-
transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
|
|
71
|
-
contain: 'size layout style',
|
|
72
|
-
...rectStyles
|
|
73
|
-
};
|
|
74
|
-
$ccf8a0a04e4175ae$var$cache.set(layoutInfo, style);
|
|
75
|
-
return style;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export {$ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle};
|
|
80
|
-
//# sourceMappingURL=VirtualizerItem.module.js.map
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import {useVirtualizerItem as $47736c1e63ba1c6d$export$1da781778207e0a2} from "./useVirtualizerItem.module.js";
|
|
2
|
-
import $ivH3G$react, {useRef as $ivH3G$useRef} from "react";
|
|
3
|
-
import {useLocale as $ivH3G$useLocale} from "@react-aria/i18n";
|
|
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
|
-
function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) {
|
|
19
|
-
let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
|
|
20
|
-
let { direction: direction } = (0, $ivH3G$useLocale)();
|
|
21
|
-
let ref = (0, $ivH3G$useRef)(null);
|
|
22
|
-
(0, $47736c1e63ba1c6d$export$1da781778207e0a2)({
|
|
23
|
-
layoutInfo: layoutInfo,
|
|
24
|
-
virtualizer: virtualizer,
|
|
25
|
-
ref: ref
|
|
26
|
-
});
|
|
27
|
-
return /*#__PURE__*/ (0, $ivH3G$react).createElement("div", {
|
|
28
|
-
role: "presentation",
|
|
29
|
-
ref: ref,
|
|
30
|
-
className: className,
|
|
31
|
-
style: {
|
|
32
|
-
...$ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent),
|
|
33
|
-
...style
|
|
34
|
-
}
|
|
35
|
-
}, children);
|
|
36
|
-
}
|
|
37
|
-
let $ccf8a0a04e4175ae$var$cache = new WeakMap();
|
|
38
|
-
function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
39
|
-
let xProperty = dir === 'rtl' ? 'right' : 'left';
|
|
40
|
-
let cached = $ccf8a0a04e4175ae$var$cache.get(layoutInfo);
|
|
41
|
-
if (cached && cached[xProperty] != null) {
|
|
42
|
-
if (!parent) return cached;
|
|
43
|
-
// Invalidate if the parent position changed.
|
|
44
|
-
let top = layoutInfo.rect.y - parent.rect.y;
|
|
45
|
-
let x = layoutInfo.rect.x - parent.rect.x;
|
|
46
|
-
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
47
|
-
}
|
|
48
|
-
let rectStyles = {
|
|
49
|
-
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container
|
|
50
|
-
// which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position
|
|
51
|
-
// Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the
|
|
52
|
-
// calculated layoutInfo.y here
|
|
53
|
-
top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),
|
|
54
|
-
[xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),
|
|
55
|
-
width: layoutInfo.rect.width,
|
|
56
|
-
height: layoutInfo.rect.height
|
|
57
|
-
};
|
|
58
|
-
// Get rid of any non finite values since they aren't valid css values
|
|
59
|
-
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
60
|
-
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
61
|
-
});
|
|
62
|
-
var _layoutInfo_transform;
|
|
63
|
-
let style = {
|
|
64
|
-
position: layoutInfo.isSticky ? 'sticky' : 'absolute',
|
|
65
|
-
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
66
|
-
display: layoutInfo.isSticky ? 'inline-block' : undefined,
|
|
67
|
-
overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',
|
|
68
|
-
opacity: layoutInfo.opacity,
|
|
69
|
-
zIndex: layoutInfo.zIndex,
|
|
70
|
-
transform: (_layoutInfo_transform = layoutInfo.transform) !== null && _layoutInfo_transform !== void 0 ? _layoutInfo_transform : undefined,
|
|
71
|
-
contain: 'size layout style',
|
|
72
|
-
...rectStyles
|
|
73
|
-
};
|
|
74
|
-
$ccf8a0a04e4175ae$var$cache.set(layoutInfo, style);
|
|
75
|
-
return style;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
export {$ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle};
|
|
80
|
-
//# sourceMappingURL=VirtualizerItem.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAgBM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,SAAC,KAAK,aAAE,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IACpE,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,aAAK,EAAyB;IACxC,CAAA,GAAA,yCAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO;YAAC,GAAG,0CAAkB,YAAY,WAAW,OAAO;YAAE,GAAG,KAAK;QAAA;OAC3H;AAGP;AAEA,IAAI,8BAAQ,IAAI;AACT,SAAS,0CAAkB,UAAsB,EAAE,GAAc,EAAE,MAA0B;IAClG,IAAI,YAAY,QAAQ,QAAQ,UAAU;IAC1C,IAAI,SAAS,4BAAM,GAAG,CAAC;IACvB,IAAI,UAAU,MAAM,CAAC,UAAU,IAAI,MAAM;QACvC,IAAI,CAAC,QACH,OAAO;QAGT,6CAA6C;QAC7C,IAAI,MAAM,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QAC3C,IAAI,IAAI,WAAW,IAAI,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC;QACzC,IAAI,OAAO,GAAG,KAAK,OAAO,MAAM,CAAC,UAAU,KAAK,GAC9C,OAAO;IAEX;IAEA,IAAI,aAAiD;QACnD,wJAAwJ;QACxJ,sIAAsI;QACtI,mJAAmJ;QACnJ,+BAA+B;QAC/B,KAAK,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QACrG,CAAC,UAAU,EAAE,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,UAAU,CAAE,CAAA,OAAO,aAAa,IAAI,WAAW,QAAQ,AAAD,IAAK,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QAC7G,OAAO,WAAW,IAAI,CAAC,KAAK;QAC5B,QAAQ,WAAW,IAAI,CAAC,MAAM;IAChC;IAEA,sEAAsE;IACtE,OAAO,OAAO,CAAC,YAAY,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;QAC9C,IAAI,CAAC,OAAO,QAAQ,CAAC,QACnB,UAAU,CAAC,IAAI,GAAG;IAEtB;QASa;IAPb,IAAI,QAAuB;QACzB,UAAU,WAAW,QAAQ,GAAG,WAAW;QAC3C,qJAAqJ;QACrJ,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,CAAA,wBAAA,WAAW,SAAS,cAApB,mCAAA,wBAAwB;QACnC,SAAS;QACT,GAAG,UAAU;IACf;IAEA,4BAAM,GAAG,CAAC,YAAY;IACtB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/VirtualizerItem.tsx"],"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 {Direction} from '@react-types/shared';\nimport {LayoutInfo} from '@react-stately/virtualizer';\nimport React, {CSSProperties, JSX, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n layoutInfo: LayoutInfo,\n parent?: LayoutInfo | null,\n style?: CSSProperties,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps): JSX.Element {\n let {style, className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef<HTMLDivElement | null>(null);\n useVirtualizerItem({\n layoutInfo,\n virtualizer,\n ref\n });\n\n return (\n <div role=\"presentation\" ref={ref} className={className} style={{...layoutInfoToStyle(layoutInfo, direction, parent), ...style}}>\n {children}\n </div>\n );\n}\n\nlet cache = new WeakMap();\nexport function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties {\n let xProperty = dir === 'rtl' ? 'right' : 'left';\n let cached = cache.get(layoutInfo);\n if (cached && cached[xProperty] != null) {\n if (!parent) {\n return cached;\n }\n\n // Invalidate if the parent position changed.\n let top = layoutInfo.rect.y - parent.rect.y;\n let x = layoutInfo.rect.x - parent.rect.x;\n if (cached.top === top && cached[xProperty] === x) {\n return cached;\n }\n }\n\n let rectStyles: Record<string, number | undefined> = {\n // TODO: For layoutInfos that are sticky that have parents with overflow visible, their \"top\" will be relative to the to the nearest scrolling container\n // which WON'T be the parent since the parent has overflow visible. This means we shouldn't offset the height by the parent's position\n // Not 100% about this change here since it is quite ambigious what the scrolling container maybe and how its top is positioned with respect to the\n // calculated layoutInfo.y here\n top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0),\n width: layoutInfo.rect.width,\n height: layoutInfo.rect.height\n };\n\n // Get rid of any non finite values since they aren't valid css values\n Object.entries(rectStyles).forEach(([key, value]) => {\n if (!Number.isFinite(value)) {\n rectStyles[key] = undefined;\n }\n });\n\n let style: CSSProperties = {\n position: layoutInfo.isSticky ? 'sticky' : 'absolute',\n // Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.\n display: layoutInfo.isSticky ? 'inline-block' : undefined,\n overflow: layoutInfo.allowOverflow ? 'visible' : 'hidden',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform ?? undefined,\n contain: 'size layout style',\n ...rectStyles\n };\n\n cache.set(layoutInfo, style);\n return style;\n}\n"],"names":[],"version":3,"file":"VirtualizerItem.module.js.map"}
|
package/dist/types.d.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { Direction, Key, RefObject, Collection } from "@react-types/shared";
|
|
2
|
-
import { LayoutInfo, Size, Rect, Layout, ReusableView } from "@react-stately/virtualizer";
|
|
3
|
-
import React, { CSSProperties, HTMLAttributes, ReactNode, RefObject as _RefObject1, JSX, ReactElement } from "react";
|
|
4
|
-
export type RTLOffsetType = 'negative' | 'positive-descending' | 'positive-ascending';
|
|
5
|
-
export function getRTLOffsetType(recalculate?: boolean): RTLOffsetType;
|
|
6
|
-
export function getScrollLeft(node: Element, direction: Direction): number;
|
|
7
|
-
export function setScrollLeft(node: Element, direction: Direction, scrollLeft: number): void;
|
|
8
|
-
interface IVirtualizer {
|
|
9
|
-
updateItemSize(key: Key, size: Size): void;
|
|
10
|
-
}
|
|
11
|
-
export interface VirtualizerItemOptions {
|
|
12
|
-
layoutInfo: LayoutInfo | null;
|
|
13
|
-
virtualizer: IVirtualizer;
|
|
14
|
-
ref: RefObject<HTMLElement | null>;
|
|
15
|
-
}
|
|
16
|
-
export function useVirtualizerItem(options: VirtualizerItemOptions): {
|
|
17
|
-
updateSize: () => void;
|
|
18
|
-
};
|
|
19
|
-
interface ScrollViewProps extends HTMLAttributes<HTMLElement> {
|
|
20
|
-
contentSize: Size;
|
|
21
|
-
onVisibleRectChange: (rect: Rect) => void;
|
|
22
|
-
children?: ReactNode;
|
|
23
|
-
innerStyle?: CSSProperties;
|
|
24
|
-
onScrollStart?: () => void;
|
|
25
|
-
onScrollEnd?: () => void;
|
|
26
|
-
scrollDirection?: 'horizontal' | 'vertical' | 'both';
|
|
27
|
-
}
|
|
28
|
-
export const ScrollView: React.ForwardRefExoticComponent<ScrollViewProps & React.RefAttributes<HTMLDivElement | null>>;
|
|
29
|
-
interface ScrollViewAria {
|
|
30
|
-
isScrolling: boolean;
|
|
31
|
-
scrollViewProps: HTMLAttributes<HTMLElement>;
|
|
32
|
-
contentProps: HTMLAttributes<HTMLElement>;
|
|
33
|
-
}
|
|
34
|
-
export function useScrollView(props: ScrollViewProps, ref: _RefObject1<HTMLElement | null>): ScrollViewAria;
|
|
35
|
-
interface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {
|
|
36
|
-
layoutInfo: LayoutInfo;
|
|
37
|
-
parent?: LayoutInfo | null;
|
|
38
|
-
style?: CSSProperties;
|
|
39
|
-
className?: string;
|
|
40
|
-
children: ReactNode;
|
|
41
|
-
}
|
|
42
|
-
export function VirtualizerItem(props: VirtualizerItemProps): JSX.Element;
|
|
43
|
-
export function layoutInfoToStyle(layoutInfo: LayoutInfo, dir: Direction, parent?: LayoutInfo | null): CSSProperties;
|
|
44
|
-
type RenderWrapper<T extends object, V> = (parent: ReusableView<T, V> | null, reusableView: ReusableView<T, V>, children: ReusableView<T, V>[], renderChildren: (views: ReusableView<T, V>[]) => ReactElement[]) => ReactElement | null;
|
|
45
|
-
interface VirtualizerProps<T extends object, V, O> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {
|
|
46
|
-
children: (type: string, content: T) => V;
|
|
47
|
-
renderWrapper?: RenderWrapper<T, V>;
|
|
48
|
-
layout: Layout<T, O>;
|
|
49
|
-
collection: Collection<T>;
|
|
50
|
-
persistedKeys?: Set<Key> | null;
|
|
51
|
-
scrollDirection?: 'horizontal' | 'vertical' | 'both';
|
|
52
|
-
isLoading?: boolean;
|
|
53
|
-
onLoadMore?: () => void;
|
|
54
|
-
layoutOptions?: O;
|
|
55
|
-
}
|
|
56
|
-
export const Virtualizer: <T extends object, V, O>(props: VirtualizerProps<T, V, O> & {
|
|
57
|
-
ref?: RefObject<HTMLDivElement | null>;
|
|
58
|
-
}) => ReactElement;
|
|
59
|
-
|
|
60
|
-
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;AAcA,4BACI,UAAU,GACV,qBAAqB,GACrB,oBAAoB,CAAC;AAezB,iCAAiC,WAAW,GAAE,OAAe,GAAG,aAAa,CAmC5E;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,GAAG,MAAM,CAkBzE;AAED,8BAA8B,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAiB3F;ACzFD;IACE,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAAA;CAC3C;AAED;IACE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,YAAY,CAAC;IAC1B,GAAG,EAAE,UAAU,WAAW,GAAG,IAAI,CAAC,CAAA;CACnC;AAED,mCAAmC,OAAO,EAAE,sBAAsB,GAAG;IAAC,UAAU,EAAE,MAAM,IAAI,CAAA;CAAC,CAkB5F;ACfD,yBAA0B,SAAQ,eAAe,WAAW,CAAC;IAC3D,WAAW,EAAE,IAAI,CAAC;IAClB,mBAAmB,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,CAAC;IAC1C,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,UAAU,CAAC,EAAE,aAAa,CAAC;IAC3B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;IACzB,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAA;CACrD;AAeD,OAAA,MAAM,YACJ,MAAM,yBAAyB,CAAC,eAAe,GAAG,MAAM,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC,CAClE,CAAC;AAG7B;IACE,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,eAAe,WAAW,CAAC,CAAC;IAC7C,YAAY,EAAE,eAAe,WAAW,CAAC,CAAA;CAC1C;AAED,8BAA8B,KAAK,EAAE,eAAe,EAAE,GAAG,EAAE,YAAU,WAAW,GAAG,IAAI,CAAC,GAAG,cAAc,CAyNxG;ACvQD,8BAA+B,SAAQ,IAAI,CAAC,sBAAsB,EAAE,KAAK,CAAC;IACxE,UAAU,EAAE,UAAU,CAAC;IACvB,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,CAAC;IAC3B,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAA;CACpB;AAED,gCAAgC,KAAK,EAAE,oBAAoB,GAAG,IAAI,OAAO,CAexE;AAGD,kCAAkC,UAAU,EAAE,UAAU,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,CAAC,EAAE,UAAU,GAAG,IAAI,GAAG,aAAa,CAgDnH;ACzED,mBAAmB,CAAC,SAAS,MAAM,EAAE,CAAC,IAAI,CACxC,MAAM,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,EACjC,YAAY,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,EAChC,QAAQ,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,EAC9B,cAAc,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,YAAY,EAAE,KAC5D,YAAY,GAAG,IAAI,CAAC;AAEzB,2BAA2B,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,CAAE,SAAQ,IAAI,CAAC,eAAe,WAAW,CAAC,EAAE,UAAU,CAAC;IACtG,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC;IAC1C,aAAa,CAAC,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAC;IACpC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACrB,UAAU,EAAE,WAAW,CAAC,CAAC,CAAC;IAC1B,aAAa,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAChC,eAAe,CAAC,EAAE,YAAY,GAAG,UAAU,GAAG,MAAM,CAAC;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,aAAa,CAAC,EAAE,CAAC,CAAA;CAClB;AAID,OAAO,MAAM,aA8CP,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,iBAAiB,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,UAAU,cAAc,GAAG,IAAI,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC","sources":["packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/utils.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/useVirtualizerItem.ts","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/ScrollView.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/VirtualizerItem.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/Virtualizer.tsx","packages/@react-aria/virtualizer/src/packages/@react-aria/virtualizer/src/index.ts","packages/@react-aria/virtualizer/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,"/*\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\nexport type {RTLOffsetType} from './utils';\nexport type {VirtualizerItemOptions} from './useVirtualizerItem';\nexport {Virtualizer} from './Virtualizer';\nexport {useVirtualizerItem} from './useVirtualizerItem';\nexport {VirtualizerItem, layoutInfoToStyle} from './VirtualizerItem';\nexport {ScrollView, useScrollView} from './ScrollView';\nexport {getRTLOffsetType, getScrollLeft, setScrollLeft} from './utils';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var $64doO$reactstatelyvirtualizer = require("@react-stately/virtualizer");
|
|
2
|
-
var $64doO$react = require("react");
|
|
3
|
-
var $64doO$reactariautils = require("@react-aria/utils");
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
function $parcel$export(e, n, v, s) {
|
|
7
|
-
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
$parcel$export(module.exports, "useVirtualizerItem", () => $7d70e069fceb2deb$export$1da781778207e0a2);
|
|
11
|
-
/*
|
|
12
|
-
* Copyright 2020 Adobe. All rights reserved.
|
|
13
|
-
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
14
|
-
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
15
|
-
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
-
*
|
|
17
|
-
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
18
|
-
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
19
|
-
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
20
|
-
* governing permissions and limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
function $7d70e069fceb2deb$export$1da781778207e0a2(options) {
|
|
25
|
-
let { layoutInfo: layoutInfo, virtualizer: virtualizer, ref: ref } = options;
|
|
26
|
-
let key = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.key;
|
|
27
|
-
let updateSize = (0, $64doO$react.useCallback)(()=>{
|
|
28
|
-
if (key != null && ref.current) {
|
|
29
|
-
let size = $7d70e069fceb2deb$var$getSize(ref.current);
|
|
30
|
-
virtualizer.updateItemSize(key, size);
|
|
31
|
-
}
|
|
32
|
-
}, [
|
|
33
|
-
virtualizer,
|
|
34
|
-
key,
|
|
35
|
-
ref
|
|
36
|
-
]);
|
|
37
|
-
(0, $64doO$reactariautils.useLayoutEffect)(()=>{
|
|
38
|
-
if (layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.estimatedSize) updateSize();
|
|
39
|
-
});
|
|
40
|
-
return {
|
|
41
|
-
updateSize: updateSize
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function $7d70e069fceb2deb$var$getSize(node) {
|
|
45
|
-
// Reset height before measuring so we get the intrinsic size
|
|
46
|
-
let height = node.style.height;
|
|
47
|
-
node.style.height = '';
|
|
48
|
-
let size = new (0, $64doO$reactstatelyvirtualizer.Size)(node.scrollWidth, node.scrollHeight);
|
|
49
|
-
node.style.height = height;
|
|
50
|
-
return size;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
//# sourceMappingURL=useVirtualizerItem.main.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IACrC,IAAI,MAAM,uBAAA,iCAAA,WAAY,GAAG;IAEzB,IAAI,aAAa,CAAA,GAAA,wBAAU,EAAE;QAC3B,IAAI,OAAO,QAAQ,IAAI,OAAO,EAAE;YAC9B,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,KAAK;QAClC;IACF,GAAG;QAAC;QAAa;QAAK;KAAI;IAE1B,CAAA,GAAA,qCAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/useVirtualizerItem.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 {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo | null,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions): {updateSize: () => void} {\n let {layoutInfo, virtualizer, ref} = options;\n let key = layoutInfo?.key;\n\n let updateSize = useCallback(() => {\n if (key != null && ref.current) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(key, size);\n }\n }, [virtualizer, key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo?.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement): Size {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"useVirtualizerItem.main.js.map"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {Size as $uBoVA$Size} from "@react-stately/virtualizer";
|
|
2
|
-
import {useCallback as $uBoVA$useCallback} from "react";
|
|
3
|
-
import {useLayoutEffect as $uBoVA$useLayoutEffect} from "@react-aria/utils";
|
|
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
|
-
function $47736c1e63ba1c6d$export$1da781778207e0a2(options) {
|
|
19
|
-
let { layoutInfo: layoutInfo, virtualizer: virtualizer, ref: ref } = options;
|
|
20
|
-
let key = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.key;
|
|
21
|
-
let updateSize = (0, $uBoVA$useCallback)(()=>{
|
|
22
|
-
if (key != null && ref.current) {
|
|
23
|
-
let size = $47736c1e63ba1c6d$var$getSize(ref.current);
|
|
24
|
-
virtualizer.updateItemSize(key, size);
|
|
25
|
-
}
|
|
26
|
-
}, [
|
|
27
|
-
virtualizer,
|
|
28
|
-
key,
|
|
29
|
-
ref
|
|
30
|
-
]);
|
|
31
|
-
(0, $uBoVA$useLayoutEffect)(()=>{
|
|
32
|
-
if (layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.estimatedSize) updateSize();
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
updateSize: updateSize
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function $47736c1e63ba1c6d$var$getSize(node) {
|
|
39
|
-
// Reset height before measuring so we get the intrinsic size
|
|
40
|
-
let height = node.style.height;
|
|
41
|
-
node.style.height = '';
|
|
42
|
-
let size = new (0, $uBoVA$Size)(node.scrollWidth, node.scrollHeight);
|
|
43
|
-
node.style.height = height;
|
|
44
|
-
return size;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export {$47736c1e63ba1c6d$export$1da781778207e0a2 as useVirtualizerItem};
|
|
49
|
-
//# sourceMappingURL=useVirtualizerItem.module.js.map
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import {Size as $uBoVA$Size} from "@react-stately/virtualizer";
|
|
2
|
-
import {useCallback as $uBoVA$useCallback} from "react";
|
|
3
|
-
import {useLayoutEffect as $uBoVA$useLayoutEffect} from "@react-aria/utils";
|
|
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
|
-
function $47736c1e63ba1c6d$export$1da781778207e0a2(options) {
|
|
19
|
-
let { layoutInfo: layoutInfo, virtualizer: virtualizer, ref: ref } = options;
|
|
20
|
-
let key = layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.key;
|
|
21
|
-
let updateSize = (0, $uBoVA$useCallback)(()=>{
|
|
22
|
-
if (key != null && ref.current) {
|
|
23
|
-
let size = $47736c1e63ba1c6d$var$getSize(ref.current);
|
|
24
|
-
virtualizer.updateItemSize(key, size);
|
|
25
|
-
}
|
|
26
|
-
}, [
|
|
27
|
-
virtualizer,
|
|
28
|
-
key,
|
|
29
|
-
ref
|
|
30
|
-
]);
|
|
31
|
-
(0, $uBoVA$useLayoutEffect)(()=>{
|
|
32
|
-
if (layoutInfo === null || layoutInfo === void 0 ? void 0 : layoutInfo.estimatedSize) updateSize();
|
|
33
|
-
});
|
|
34
|
-
return {
|
|
35
|
-
updateSize: updateSize
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function $47736c1e63ba1c6d$var$getSize(node) {
|
|
39
|
-
// Reset height before measuring so we get the intrinsic size
|
|
40
|
-
let height = node.style.height;
|
|
41
|
-
node.style.height = '';
|
|
42
|
-
let size = new (0, $uBoVA$Size)(node.scrollWidth, node.scrollHeight);
|
|
43
|
-
node.style.height = height;
|
|
44
|
-
return size;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
export {$47736c1e63ba1c6d$export$1da781778207e0a2 as useVirtualizerItem};
|
|
49
|
-
//# sourceMappingURL=useVirtualizerItem.module.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAiBM,SAAS,0CAAmB,OAA+B;IAChE,IAAI,cAAC,UAAU,eAAE,WAAW,OAAE,GAAG,EAAC,GAAG;IACrC,IAAI,MAAM,uBAAA,iCAAA,WAAY,GAAG;IAEzB,IAAI,aAAa,CAAA,GAAA,kBAAU,EAAE;QAC3B,IAAI,OAAO,QAAQ,IAAI,OAAO,EAAE;YAC9B,IAAI,OAAO,8BAAQ,IAAI,OAAO;YAC9B,YAAY,cAAc,CAAC,KAAK;QAClC;IACF,GAAG;QAAC;QAAa;QAAK;KAAI;IAE1B,CAAA,GAAA,sBAAc,EAAE;QACd,IAAI,uBAAA,iCAAA,WAAY,aAAa,EAC3B;IAEJ;IAEA,OAAO;oBAAC;IAAU;AACpB;AAEA,SAAS,8BAAQ,IAAiB;IAChC,6DAA6D;IAC7D,IAAI,SAAS,KAAK,KAAK,CAAC,MAAM;IAC9B,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,IAAI,OAAO,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY;IACvD,KAAK,KAAK,CAAC,MAAM,GAAG;IACpB,OAAO;AACT","sources":["packages/@react-aria/virtualizer/src/useVirtualizerItem.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 {Key, RefObject} from '@react-types/shared';\nimport {LayoutInfo, Size} from '@react-stately/virtualizer';\nimport {useCallback} from 'react';\nimport {useLayoutEffect} from '@react-aria/utils';\n\ninterface IVirtualizer {\n updateItemSize(key: Key, size: Size): void\n}\n\nexport interface VirtualizerItemOptions {\n layoutInfo: LayoutInfo | null,\n virtualizer: IVirtualizer,\n ref: RefObject<HTMLElement | null>\n}\n\nexport function useVirtualizerItem(options: VirtualizerItemOptions): {updateSize: () => void} {\n let {layoutInfo, virtualizer, ref} = options;\n let key = layoutInfo?.key;\n\n let updateSize = useCallback(() => {\n if (key != null && ref.current) {\n let size = getSize(ref.current);\n virtualizer.updateItemSize(key, size);\n }\n }, [virtualizer, key, ref]);\n\n useLayoutEffect(() => {\n if (layoutInfo?.estimatedSize) {\n updateSize();\n }\n });\n\n return {updateSize};\n}\n\nfunction getSize(node: HTMLElement): Size {\n // Reset height before measuring so we get the intrinsic size\n let height = node.style.height;\n node.style.height = '';\n let size = new Size(node.scrollWidth, node.scrollHeight);\n node.style.height = height;\n return size;\n}\n"],"names":[],"version":3,"file":"useVirtualizerItem.module.js.map"}
|