@react-aria/virtualizer 3.9.11-nightly.4555 → 3.9.11-nightly.4560
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/ScrollView.main.js +180 -0
- package/dist/ScrollView.main.js.map +1 -0
- package/dist/ScrollView.mjs +171 -0
- package/dist/ScrollView.module.js +171 -0
- package/dist/ScrollView.module.js.map +1 -0
- package/dist/Virtualizer.main.js +210 -0
- package/dist/Virtualizer.main.js.map +1 -0
- package/dist/Virtualizer.mjs +200 -0
- package/dist/Virtualizer.module.js +200 -0
- package/dist/Virtualizer.module.js.map +1 -0
- package/dist/VirtualizerItem.main.js +86 -0
- package/dist/VirtualizerItem.main.js.map +1 -0
- package/dist/VirtualizerItem.mjs +76 -0
- package/dist/VirtualizerItem.module.js +76 -0
- package/dist/VirtualizerItem.module.js.map +1 -0
- package/dist/import.mjs +5 -535
- package/dist/main.js +14 -548
- package/dist/main.js.map +1 -1
- package/dist/module.js +5 -535
- package/dist/module.js.map +1 -1
- package/dist/useVirtualizerItem.main.js +51 -0
- package/dist/useVirtualizerItem.main.js.map +1 -0
- package/dist/useVirtualizerItem.mjs +46 -0
- package/dist/useVirtualizerItem.module.js +46 -0
- package/dist/useVirtualizerItem.module.js.map +1 -0
- package/dist/utils.main.js +80 -0
- package/dist/utils.main.js.map +1 -0
- package/dist/utils.mjs +73 -0
- package/dist/utils.module.js +73 -0
- package/dist/utils.module.js.map +1 -0
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;AA+BD,SAAS,kCAAmD,KAA6B,EAAE,GAA8B;IACvH,IAAI,EACF,UAAU,UAAU,iBACpB,aAAa,UACb,MAAM,cACN,UAAU,aACV,SAAS,mBACT,eAAe,sBACf,kBAAkB,aAClB,6DAA6D;IAC7D,SAAS,cACT,6DAA6D;IAC7D,UAAU,cACV,6DAA6D;IAC7D,UAAU,y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W;QAAY;KAAM;IAE1F,OAAO;QACL,kBAAkB;sBAChB;qBACA;oBACA;QACF;QACA,iBAAiB;iCACf;QACF;IACF;AACF;AAEA,wFAAwF;AACxF,2GAA2G;AAC3G,MAAM,0DAAe,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC;AAGtC,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} from '@react-types/shared';\nimport {getInteractionModality} from '@react-aria/interactions';\nimport {Layout, Rect, ReusableView, useVirtualizerState, VirtualizerState} from '@react-stately/virtualizer';\nimport {mergeProps, useLayoutEffect} from '@react-aria/utils';\nimport React, {FocusEvent, HTMLAttributes, ReactElement, ReactNode, RefObject, useCallback, useEffect, useMemo, useRef} from 'react';\nimport {ScrollView} from './ScrollView';\nimport {VirtualizerItem} from './VirtualizerItem';\n\ninterface VirtualizerProps<T extends object, V> extends Omit<HTMLAttributes<HTMLElement>, 'children'> {\n children: (type: string, content: T) => V,\n renderWrapper?: (\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,\n layout: Layout<T>,\n collection: Collection<T>,\n focusedKey?: Key,\n sizeToFit?: 'width' | 'height',\n scrollDirection?: 'horizontal' | 'vertical' | 'both',\n transitionDuration?: number,\n isLoading?: boolean,\n onLoadMore?: () => void,\n shouldUseVirtualFocus?: boolean,\n scrollToItem?: (key: Key) => void,\n autoFocus?: boolean\n}\n\nfunction Virtualizer<T extends object, V extends ReactNode>(props: VirtualizerProps<T, V>, ref: RefObject<HTMLDivElement>) {\n let {\n children: renderView,\n renderWrapper,\n layout,\n collection,\n sizeToFit,\n scrollDirection,\n transitionDuration,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n isLoading,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n onLoadMore,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n focusedKey,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n shouldUseVirtualFocus,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n scrollToItem,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n autoFocus,\n ...otherProps\n } = props;\n\n let fallbackRef = useRef<HTMLDivElement>();\n ref = ref || fallbackRef;\n\n let state = useVirtualizerState({\n transitionDuration,\n layout,\n collection,\n renderView,\n renderWrapper: renderWrapper || defaultRenderWrapper,\n onVisibleRectChange(rect) {\n ref.current.scrollLeft = rect.x;\n ref.current.scrollTop = rect.y;\n }\n });\n\n let {virtualizerProps, scrollViewProps} = useVirtualizer(props, state, ref);\n\n return (\n <ScrollView\n {...mergeProps(otherProps, virtualizerProps, scrollViewProps)}\n ref={ref}\n innerStyle={state.isAnimating ? {transition: `none ${state.virtualizer.transitionDuration}ms`} : undefined}\n contentSize={state.contentSize}\n onScrollStart={state.startScrolling}\n onScrollEnd={state.endScrolling}\n sizeToFit={sizeToFit}\n scrollDirection={scrollDirection}>\n {state.visibleViews}\n </ScrollView>\n );\n}\n\ninterface VirtualizerOptions {\n tabIndex?: number,\n focusedKey?: Key,\n scrollToItem?: (key: Key) => void,\n shouldUseVirtualFocus?: boolean,\n autoFocus?: boolean,\n isLoading?: boolean,\n onLoadMore?: () => void\n}\n\nexport function useVirtualizer<T extends object, V extends ReactNode, W>(props: VirtualizerOptions, state: VirtualizerState<T, V, W>, ref: RefObject<HTMLElement>) {\n let {focusedKey, scrollToItem, shouldUseVirtualFocus, isLoading, onLoadMore} = props;\n let {virtualizer} = state;\n // Scroll to the focusedKey when it changes. Actually focusing the focusedKey\n // is up to the implementation using Virtualizer since we don't have refs\n // to all of the item DOM nodes.\n let lastFocusedKey = useRef(null);\n let isFocusWithin = useRef(false);\n let autoFocus = useRef(props.autoFocus);\n useEffect(() => {\n if (virtualizer.visibleRect.height === 0) {\n return;\n }\n\n // Only scroll the focusedKey into view if the modality is not pointer to avoid jumps in position when clicking/pressing tall items.\n let modality = getInteractionModality();\n if (focusedKey !== lastFocusedKey.current && (modality !== 'pointer' || autoFocus.current)) {\n autoFocus.current = false;\n if (scrollToItem) {\n // If user provides scrolltoitem, then it is their responsibility to call scrollIntoViewport if desired\n // since we don't know if their scrollToItem may take some time to actually bring the active element into the virtualizer's visible rect.\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n\n }\n }\n\n lastFocusedKey.current = focusedKey;\n }, [focusedKey, virtualizer.visibleRect.height, virtualizer, lastFocusedKey, scrollToItem, ref]);\n\n // Persist the focusedKey and prevent it from being removed from the DOM when scrolled out of view.\n virtualizer.persistedKeys = useMemo(() => focusedKey ? new Set([focusedKey]) : new Set(), [focusedKey]);\n\n let onFocus = useCallback((e: FocusEvent) => {\n // If the focused item is scrolled out of view and is not in the DOM, the collection\n // will have tabIndex={0}. When tabbing in from outside, scroll the focused item into view.\n // Ignore focus events that bubble through portals (e.g. focus that happens on a menu popover child of the virtualizer)\n // Don't scroll focused key into view if modality is pointer to prevent sudden jump in position (e.g. CardView).\n let modality = getInteractionModality();\n if (!isFocusWithin.current && ref.current.contains(e.target) && modality !== 'pointer') {\n if (scrollToItem) {\n scrollToItem(focusedKey);\n } else {\n virtualizer.scrollToItem(focusedKey, {duration: 0});\n }\n }\n\n isFocusWithin.current = e.target !== ref.current;\n }, [ref, virtualizer, focusedKey, scrollToItem]);\n\n let onBlur = useCallback((e: FocusEvent) => {\n isFocusWithin.current = ref.current.contains(e.relatedTarget as Element);\n }, [ref]);\n\n // Set tabIndex to -1 if there is a focused key, otherwise 0 so that the collection\n // itself is tabbable. When the collection receives focus, we scroll the focused item back into\n // view, which will allow it to be properly focused. If using virtual focus, don't set a\n // tabIndex at all so that VoiceOver on iOS 14 doesn't try to move real DOM focus to the element anyway.\n let tabIndex: number;\n if (!shouldUseVirtualFocus) {\n // When there is no focusedKey the default tabIndex is 0. We include logic for empty collections too.\n // For collections that are empty, but have a link in the empty children we want to skip focusing this\n // and let focus move to the link similar to link moving to children.\n tabIndex = focusedKey != null ? -1 : 0;\n\n // If the collection is empty, we want the tabIndex provided from props (if any)\n // so that we handle when tabbable items are added to the empty state.\n if (virtualizer.collection.size === 0 && props.tabIndex != null) {\n tabIndex = props.tabIndex;\n }\n }\n\n // Handle scrolling, and call onLoadMore when nearing the bottom.\n let isLoadingRef = useRef(isLoading);\n let prevProps = useRef(props);\n let onVisibleRectChange = useCallback((rect: Rect) => {\n state.setVisibleRect(rect);\n\n if (!isLoadingRef.current && onLoadMore) {\n let scrollOffset = state.virtualizer.contentSize.height - rect.height * 2;\n if (rect.y > scrollOffset) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n }\n }, [onLoadMore, state]);\n\n let lastContentSize = useRef(0);\n useLayoutEffect(() => {\n // If animating, wait until we're done.\n if (state.isAnimating) {\n return;\n }\n\n // Only update isLoadingRef if props object actually changed,\n // not if a local state change occurred.\n let wasLoading = isLoadingRef.current;\n if (props !== prevProps.current) {\n isLoadingRef.current = isLoading;\n prevProps.current = props;\n }\n\n let shouldLoadMore = !isLoadingRef.current\n && onLoadMore\n && state.contentSize.height > 0\n && state.contentSize.height <= state.virtualizer.visibleRect.height\n // Only try loading more if the content size changed, or if we just finished\n // loading and still have room for more items.\n && (wasLoading || state.contentSize.height !== lastContentSize.current);\n\n if (shouldLoadMore) {\n isLoadingRef.current = true;\n onLoadMore();\n }\n lastContentSize.current = state.contentSize.height;\n }, [state.contentSize, state.isAnimating, state.virtualizer, isLoading, onLoadMore, props]);\n\n return {\n virtualizerProps: {\n tabIndex,\n onFocus,\n onBlur\n },\n scrollViewProps: {\n onVisibleRectChange\n }\n };\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\nconst _Virtualizer = React.forwardRef(Virtualizer) as <T extends object, V>(props: VirtualizerProps<T, V> & {ref?: RefObject<HTMLDivElement>}) => ReactElement;\nexport {_Virtualizer as Virtualizer};\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"}
|
|
@@ -0,0 +1,86 @@
|
|
|
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 { 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)();
|
|
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: $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, direction, parent)
|
|
43
|
+
}, children);
|
|
44
|
+
}
|
|
45
|
+
let $d6a26279cc31826b$var$cache = new WeakMap();
|
|
46
|
+
function $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
47
|
+
let xProperty = dir === "rtl" ? "right" : "left";
|
|
48
|
+
let cached = $d6a26279cc31826b$var$cache.get(layoutInfo);
|
|
49
|
+
if (cached && cached[xProperty] != null) {
|
|
50
|
+
if (!parent) return cached;
|
|
51
|
+
// Invalidate if the parent position changed.
|
|
52
|
+
let top = layoutInfo.rect.y - parent.rect.y;
|
|
53
|
+
let x = layoutInfo.rect.x - parent.rect.x;
|
|
54
|
+
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
55
|
+
}
|
|
56
|
+
let rectStyles = {
|
|
57
|
+
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
|
|
58
|
+
[xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
|
|
59
|
+
width: layoutInfo.rect.width,
|
|
60
|
+
height: layoutInfo.rect.height
|
|
61
|
+
};
|
|
62
|
+
// Get rid of any non finite values since they aren't valid css values
|
|
63
|
+
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
64
|
+
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
65
|
+
});
|
|
66
|
+
let style = {
|
|
67
|
+
position: layoutInfo.isSticky ? "sticky" : "absolute",
|
|
68
|
+
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
69
|
+
display: layoutInfo.isSticky ? "inline-block" : undefined,
|
|
70
|
+
overflow: layoutInfo.allowOverflow ? "visible" : "hidden",
|
|
71
|
+
transition: "all",
|
|
72
|
+
WebkitTransition: "all",
|
|
73
|
+
WebkitTransitionDuration: "inherit",
|
|
74
|
+
transitionDuration: "inherit",
|
|
75
|
+
opacity: layoutInfo.opacity,
|
|
76
|
+
zIndex: layoutInfo.zIndex,
|
|
77
|
+
transform: layoutInfo.transform,
|
|
78
|
+
contain: "size layout style",
|
|
79
|
+
...rectStyles
|
|
80
|
+
};
|
|
81
|
+
$d6a26279cc31826b$var$cache.set(layoutInfo, style);
|
|
82
|
+
return style;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=VirtualizerItem.main.js.map
|
|
@@ -0,0 +1 @@
|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AY,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;QAC9C,IAAI,CAAC,OAAO,QAAQ,CAAC,QACnB,UAAU,CAAC,IAAI,GAAG;IAEtB;IAEA,IAAI,QAAuB;QACzB,UAAU,WAAW,QAAQ,GAAG,WAAW;QAC3C,qJAAqJ;QACrJ,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,YAAY;QACZ,kBAAkB;QAClB,0BAA0B;QAC1B,oBAAoB;QACpB,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,WAAW,SAAS;QAC/B,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, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n parent?: LayoutInfo,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef();\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)}>\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 = {\n top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent ? 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 transition: 'all',\n WebkitTransition: 'all',\n WebkitTransitionDuration: 'inherit',\n transitionDuration: 'inherit',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\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"}
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
|
|
20
|
+
let { direction: direction } = (0, $ivH3G$useLocale)();
|
|
21
|
+
let ref = (0, $ivH3G$useRef)();
|
|
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: $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent)
|
|
32
|
+
}, children);
|
|
33
|
+
}
|
|
34
|
+
let $ccf8a0a04e4175ae$var$cache = new WeakMap();
|
|
35
|
+
function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
36
|
+
let xProperty = dir === "rtl" ? "right" : "left";
|
|
37
|
+
let cached = $ccf8a0a04e4175ae$var$cache.get(layoutInfo);
|
|
38
|
+
if (cached && cached[xProperty] != null) {
|
|
39
|
+
if (!parent) return cached;
|
|
40
|
+
// Invalidate if the parent position changed.
|
|
41
|
+
let top = layoutInfo.rect.y - parent.rect.y;
|
|
42
|
+
let x = layoutInfo.rect.x - parent.rect.x;
|
|
43
|
+
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
44
|
+
}
|
|
45
|
+
let rectStyles = {
|
|
46
|
+
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
|
|
47
|
+
[xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
|
|
48
|
+
width: layoutInfo.rect.width,
|
|
49
|
+
height: layoutInfo.rect.height
|
|
50
|
+
};
|
|
51
|
+
// Get rid of any non finite values since they aren't valid css values
|
|
52
|
+
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
53
|
+
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
54
|
+
});
|
|
55
|
+
let style = {
|
|
56
|
+
position: layoutInfo.isSticky ? "sticky" : "absolute",
|
|
57
|
+
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
58
|
+
display: layoutInfo.isSticky ? "inline-block" : undefined,
|
|
59
|
+
overflow: layoutInfo.allowOverflow ? "visible" : "hidden",
|
|
60
|
+
transition: "all",
|
|
61
|
+
WebkitTransition: "all",
|
|
62
|
+
WebkitTransitionDuration: "inherit",
|
|
63
|
+
transitionDuration: "inherit",
|
|
64
|
+
opacity: layoutInfo.opacity,
|
|
65
|
+
zIndex: layoutInfo.zIndex,
|
|
66
|
+
transform: layoutInfo.transform,
|
|
67
|
+
contain: "size layout style",
|
|
68
|
+
...rectStyles
|
|
69
|
+
};
|
|
70
|
+
$ccf8a0a04e4175ae$var$cache.set(layoutInfo, style);
|
|
71
|
+
return style;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export {$ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle};
|
|
76
|
+
//# sourceMappingURL=VirtualizerItem.mjs.map
|
|
@@ -0,0 +1,76 @@
|
|
|
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 { className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props;
|
|
20
|
+
let { direction: direction } = (0, $ivH3G$useLocale)();
|
|
21
|
+
let ref = (0, $ivH3G$useRef)();
|
|
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: $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent)
|
|
32
|
+
}, children);
|
|
33
|
+
}
|
|
34
|
+
let $ccf8a0a04e4175ae$var$cache = new WeakMap();
|
|
35
|
+
function $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, dir, parent) {
|
|
36
|
+
let xProperty = dir === "rtl" ? "right" : "left";
|
|
37
|
+
let cached = $ccf8a0a04e4175ae$var$cache.get(layoutInfo);
|
|
38
|
+
if (cached && cached[xProperty] != null) {
|
|
39
|
+
if (!parent) return cached;
|
|
40
|
+
// Invalidate if the parent position changed.
|
|
41
|
+
let top = layoutInfo.rect.y - parent.rect.y;
|
|
42
|
+
let x = layoutInfo.rect.x - parent.rect.x;
|
|
43
|
+
if (cached.top === top && cached[xProperty] === x) return cached;
|
|
44
|
+
}
|
|
45
|
+
let rectStyles = {
|
|
46
|
+
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),
|
|
47
|
+
[xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0),
|
|
48
|
+
width: layoutInfo.rect.width,
|
|
49
|
+
height: layoutInfo.rect.height
|
|
50
|
+
};
|
|
51
|
+
// Get rid of any non finite values since they aren't valid css values
|
|
52
|
+
Object.entries(rectStyles).forEach(([key, value])=>{
|
|
53
|
+
if (!Number.isFinite(value)) rectStyles[key] = undefined;
|
|
54
|
+
});
|
|
55
|
+
let style = {
|
|
56
|
+
position: layoutInfo.isSticky ? "sticky" : "absolute",
|
|
57
|
+
// Sticky elements are positioned in normal document flow. Display inline-block so that they don't push other sticky columns onto the following rows.
|
|
58
|
+
display: layoutInfo.isSticky ? "inline-block" : undefined,
|
|
59
|
+
overflow: layoutInfo.allowOverflow ? "visible" : "hidden",
|
|
60
|
+
transition: "all",
|
|
61
|
+
WebkitTransition: "all",
|
|
62
|
+
WebkitTransitionDuration: "inherit",
|
|
63
|
+
transitionDuration: "inherit",
|
|
64
|
+
opacity: layoutInfo.opacity,
|
|
65
|
+
zIndex: layoutInfo.zIndex,
|
|
66
|
+
transform: layoutInfo.transform,
|
|
67
|
+
contain: "size layout style",
|
|
68
|
+
...rectStyles
|
|
69
|
+
};
|
|
70
|
+
$ccf8a0a04e4175ae$var$cache.set(layoutInfo, style);
|
|
71
|
+
return style;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
export {$ccf8a0a04e4175ae$export$6796df8ba7398521 as VirtualizerItem, $ccf8a0a04e4175ae$export$1481e64fbe01b8b3 as layoutInfoToStyle};
|
|
76
|
+
//# sourceMappingURL=VirtualizerItem.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"mappings":";;;;AAAA;;;;;;;;;;CAUC;;;AAcM,SAAS,0CAAgB,KAA2B;IACzD,IAAI,aAAC,SAAS,cAAE,UAAU,eAAE,WAAW,UAAE,MAAM,YAAE,QAAQ,EAAC,GAAG;IAC7D,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,MAAM,CAAA,GAAA,aAAK;IACf,CAAA,GAAA,yCAAiB,EAAE;oBACjB;qBACA;aACA;IACF;IAEA,qBACE,gCAAC;QAAI,MAAK;QAAe,KAAK;QAAK,WAAW;QAAW,OAAO,0CAAkB,YAAY,WAAW;OACtG;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,aAAa;QACf,KAAK,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,SAAS,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QACnD,CAAC,UAAU,EAAE,WAAW,IAAI,CAAC,CAAC,GAAI,CAAA,SAAS,OAAO,IAAI,CAAC,CAAC,GAAG,CAAA;QAC3D,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;IAEA,IAAI,QAAuB;QACzB,UAAU,WAAW,QAAQ,GAAG,WAAW;QAC3C,qJAAqJ;QACrJ,SAAS,WAAW,QAAQ,GAAG,iBAAiB;QAChD,UAAU,WAAW,aAAa,GAAG,YAAY;QACjD,YAAY;QACZ,kBAAkB;QAClB,0BAA0B;QAC1B,oBAAoB;QACpB,SAAS,WAAW,OAAO;QAC3B,QAAQ,WAAW,MAAM;QACzB,WAAW,WAAW,SAAS;QAC/B,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, ReactNode, useRef} from 'react';\nimport {useLocale} from '@react-aria/i18n';\nimport {useVirtualizerItem, VirtualizerItemOptions} from './useVirtualizerItem';\n\ninterface VirtualizerItemProps extends Omit<VirtualizerItemOptions, 'ref'> {\n parent?: LayoutInfo,\n className?: string,\n children: ReactNode\n}\n\nexport function VirtualizerItem(props: VirtualizerItemProps) {\n let {className, layoutInfo, virtualizer, parent, children} = props;\n let {direction} = useLocale();\n let ref = useRef();\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)}>\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 = {\n top: layoutInfo.rect.y - (parent ? parent.rect.y : 0),\n [xProperty]: layoutInfo.rect.x - (parent ? 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 transition: 'all',\n WebkitTransition: 'all',\n WebkitTransitionDuration: 'inherit',\n transitionDuration: 'inherit',\n opacity: layoutInfo.opacity,\n zIndex: layoutInfo.zIndex,\n transform: layoutInfo.transform,\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"}
|