@react-aria/virtualizer
Advanced tools
Comparing version 4.0.3-nightly.5042 to 4.0.3
@@ -114,5 +114,9 @@ var $efdd61e59e023a1d$exports = require("./utils.main.js"); | ||
}, []); | ||
let isUpdatingSize = (0, $kvIfm$react.useRef)(false); | ||
let updateSize = (0, $kvIfm$reactariautils.useEffectEvent)((flush)=>{ | ||
let dom = ref.current; | ||
if (!dom) return; | ||
if (!dom && !isUpdatingSize.current) return; | ||
// Prevent reentrancy when resize observer fires, triggers re-layout that results in | ||
// content size update, causing below layout effect to fire. This avoids infinite loops. | ||
isUpdatingSize.current = true; | ||
let isTestEnv = false; | ||
@@ -144,26 +148,20 @@ let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth'); | ||
} | ||
isUpdatingSize.current = false; | ||
}); | ||
let didUpdateSize = (0, $kvIfm$react.useRef)(false); | ||
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear. | ||
let lastContentSize = (0, $kvIfm$react.useRef)(null); | ||
(0, $kvIfm$reactariautils.useLayoutEffect)(()=>{ | ||
// React doesn't allow flushSync inside effects, so queue a microtask. | ||
// We also need to wait until all refs are set (e.g. when passing a ref down from a parent). | ||
queueMicrotask(()=>{ | ||
if (!didUpdateSize.current) { | ||
didUpdateSize.current = true; | ||
updateSize((0, $kvIfm$reactdom.flushSync)); | ||
} | ||
}); | ||
}, [ | ||
updateSize | ||
]); | ||
(0, $kvIfm$react.useEffect)(()=>{ | ||
if (!didUpdateSize.current) { | ||
// If useEffect ran before the above microtask, we are in a synchronous render (e.g. act). | ||
// Update the size here so that you don't need to mock timers in tests. | ||
didUpdateSize.current = true; | ||
updateSize((fn)=>fn()); | ||
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) { | ||
// React doesn't allow flushSync inside effects, so queue a microtask. | ||
// We also need to wait until all refs are set (e.g. when passing a ref down from a parent). | ||
// If we are in an `act` environment, update immediately without a microtask so you don't need | ||
// to mock timers in tests. In this case, the update is synchronous already. | ||
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global. | ||
// https://github.com/reactwg/react-18/discussions/102 | ||
// @ts-ignore | ||
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') updateSize((fn)=>fn()); | ||
else queueMicrotask(()=>updateSize((0, $kvIfm$reactdom.flushSync))); | ||
} | ||
}, [ | ||
updateSize | ||
]); | ||
lastContentSize.current = contentSize; | ||
}); | ||
let onResize = (0, $kvIfm$react.useCallback)(()=>{ | ||
@@ -170,0 +168,0 @@ updateSize((0, $kvIfm$reactdom.flushSync)); |
@@ -103,5 +103,9 @@ import {getScrollLeft as $ce415dc67314b753$export$1389d168952b34b5} from "./utils.module.js"; | ||
}, []); | ||
let isUpdatingSize = (0, $f9kpT$useRef)(false); | ||
let updateSize = (0, $f9kpT$useEffectEvent)((flush)=>{ | ||
let dom = ref.current; | ||
if (!dom) return; | ||
if (!dom && !isUpdatingSize.current) return; | ||
// Prevent reentrancy when resize observer fires, triggers re-layout that results in | ||
// content size update, causing below layout effect to fire. This avoids infinite loops. | ||
isUpdatingSize.current = true; | ||
let isTestEnv = false; | ||
@@ -133,26 +137,20 @@ let isClientWidthMocked = Object.getOwnPropertyNames(window.HTMLElement.prototype).includes('clientWidth'); | ||
} | ||
isUpdatingSize.current = false; | ||
}); | ||
let didUpdateSize = (0, $f9kpT$useRef)(false); | ||
// Update visible rect when the content size changes, in case scrollbars need to appear or disappear. | ||
let lastContentSize = (0, $f9kpT$useRef)(null); | ||
(0, $f9kpT$useLayoutEffect)(()=>{ | ||
// React doesn't allow flushSync inside effects, so queue a microtask. | ||
// We also need to wait until all refs are set (e.g. when passing a ref down from a parent). | ||
queueMicrotask(()=>{ | ||
if (!didUpdateSize.current) { | ||
didUpdateSize.current = true; | ||
updateSize((0, $f9kpT$flushSync)); | ||
} | ||
}); | ||
}, [ | ||
updateSize | ||
]); | ||
(0, $f9kpT$useEffect)(()=>{ | ||
if (!didUpdateSize.current) { | ||
// If useEffect ran before the above microtask, we are in a synchronous render (e.g. act). | ||
// Update the size here so that you don't need to mock timers in tests. | ||
didUpdateSize.current = true; | ||
updateSize((fn)=>fn()); | ||
if (!isUpdatingSize.current && (lastContentSize.current == null || !contentSize.equals(lastContentSize.current))) { | ||
// React doesn't allow flushSync inside effects, so queue a microtask. | ||
// We also need to wait until all refs are set (e.g. when passing a ref down from a parent). | ||
// If we are in an `act` environment, update immediately without a microtask so you don't need | ||
// to mock timers in tests. In this case, the update is synchronous already. | ||
// IS_REACT_ACT_ENVIRONMENT is used by React 18. Previous versions checked for the `jest` global. | ||
// https://github.com/reactwg/react-18/discussions/102 | ||
// @ts-ignore | ||
if (typeof IS_REACT_ACT_ENVIRONMENT === 'boolean' ? IS_REACT_ACT_ENVIRONMENT : typeof jest !== 'undefined') updateSize((fn)=>fn()); | ||
else queueMicrotask(()=>updateSize((0, $f9kpT$flushSync))); | ||
} | ||
}, [ | ||
updateSize | ||
]); | ||
lastContentSize.current = contentSize; | ||
}); | ||
let onResize = (0, $f9kpT$useCallback)(()=>{ | ||
@@ -159,0 +157,0 @@ updateSize((0, $f9kpT$flushSync)); |
@@ -316,2 +316,3 @@ import { Direction, Key, RefObject, Collection } from "@react-types/shared"; | ||
parent?: LayoutInfo | null; | ||
style?: CSSProperties; | ||
className?: string; | ||
@@ -318,0 +319,0 @@ children: ReactNode; |
@@ -30,3 +30,3 @@ var $7d70e069fceb2deb$exports = require("./useVirtualizerItem.main.js"); | ||
function $d6a26279cc31826b$export$6796df8ba7398521(props) { | ||
let { className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props; | ||
let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props; | ||
let { direction: direction } = (0, $eXWCF$reactariai18n.useLocale)(); | ||
@@ -43,3 +43,6 @@ let ref = (0, $eXWCF$react.useRef)(undefined); | ||
className: className, | ||
style: $d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, direction, parent) | ||
style: { | ||
...$d6a26279cc31826b$export$1481e64fbe01b8b3(layoutInfo, direction, parent), | ||
...style | ||
} | ||
}, children); | ||
@@ -59,4 +62,8 @@ } | ||
let rectStyles = { | ||
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0), | ||
[xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0), | ||
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container | ||
// 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 | ||
// 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 | ||
// calculated layoutInfo.y here | ||
top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0), | ||
[xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0), | ||
width: layoutInfo.rect.width, | ||
@@ -63,0 +70,0 @@ height: layoutInfo.rect.height |
@@ -19,3 +19,3 @@ import {useVirtualizerItem as $47736c1e63ba1c6d$export$1da781778207e0a2} from "./useVirtualizerItem.module.js"; | ||
function $ccf8a0a04e4175ae$export$6796df8ba7398521(props) { | ||
let { className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props; | ||
let { style: style, className: className, layoutInfo: layoutInfo, virtualizer: virtualizer, parent: parent, children: children } = props; | ||
let { direction: direction } = (0, $ivH3G$useLocale)(); | ||
@@ -32,3 +32,6 @@ let ref = (0, $ivH3G$useRef)(undefined); | ||
className: className, | ||
style: $ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent) | ||
style: { | ||
...$ccf8a0a04e4175ae$export$1481e64fbe01b8b3(layoutInfo, direction, parent), | ||
...style | ||
} | ||
}, children); | ||
@@ -48,4 +51,8 @@ } | ||
let rectStyles = { | ||
top: layoutInfo.rect.y - (parent ? parent.rect.y : 0), | ||
[xProperty]: layoutInfo.rect.x - (parent ? parent.rect.x : 0), | ||
// TODO: For layoutInfos that are sticky that have parents with overflow visible, their "top" will be relative to the to the nearest scrolling container | ||
// 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 | ||
// 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 | ||
// calculated layoutInfo.y here | ||
top: layoutInfo.rect.y - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.y : 0), | ||
[xProperty]: layoutInfo.rect.x - (parent && !(parent.allowOverflow && layoutInfo.isSticky) ? parent.rect.x : 0), | ||
width: layoutInfo.rect.width, | ||
@@ -52,0 +59,0 @@ height: layoutInfo.rect.height |
{ | ||
"name": "@react-aria/virtualizer", | ||
"version": "4.0.3-nightly.5042+68403fe55", | ||
"version": "4.0.3", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,7 +25,7 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/i18n": "3.0.0-nightly.3114+68403fe55", | ||
"@react-aria/interactions": "3.0.0-nightly.3114+68403fe55", | ||
"@react-aria/utils": "3.0.0-nightly.3114+68403fe55", | ||
"@react-stately/virtualizer": "4.0.3-nightly.5042+68403fe55", | ||
"@react-types/shared": "3.0.0-nightly.3114+68403fe55", | ||
"@react-aria/i18n": "^3.12.3", | ||
"@react-aria/interactions": "^3.22.3", | ||
"@react-aria/utils": "^3.25.3", | ||
"@react-stately/virtualizer": "^4.1.0", | ||
"@react-types/shared": "^3.25.0", | ||
"@swc/helpers": "^0.5.0" | ||
@@ -39,4 +39,3 @@ }, | ||
"access": "public" | ||
}, | ||
"gitHead": "68403fe55489dce3de1b3094c957d598ad719861" | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
2356
1
0
192138
40
+ Added@formatjs/ecma402-abstract@2.3.1(transitive)
+ Added@formatjs/fast-memoize@2.2.5(transitive)
+ Added@formatjs/icu-messageformat-parser@2.9.7(transitive)
+ Added@formatjs/icu-skeleton-parser@1.8.11(transitive)
+ Added@formatjs/intl-localematcher@0.5.9(transitive)
+ Added@internationalized/date@3.6.0(transitive)
+ Added@internationalized/message@3.1.6(transitive)
+ Added@internationalized/number@3.6.0(transitive)
+ Added@internationalized/string@3.2.5(transitive)
+ Added@react-aria/i18n@3.12.4(transitive)
+ Added@react-aria/interactions@3.22.5(transitive)
+ Added@react-aria/ssr@3.9.7(transitive)
+ Added@react-aria/utils@3.26.0(transitive)
+ Added@react-stately/utils@3.10.5(transitive)
+ Added@react-stately/virtualizer@4.2.0(transitive)
+ Added@react-types/shared@3.26.0(transitive)
+ Addedclsx@2.1.1(transitive)
+ Addeddecimal.js@10.4.3(transitive)
+ Addedintl-messageformat@10.7.10(transitive)
Updated@react-aria/i18n@^3.12.3
Updated@react-aria/utils@^3.25.3
Updated@react-types/shared@^3.25.0