@react-aria/utils
Advanced tools
Comparing version 3.0.0-nightly-3f67667d5-241111 to 3.0.0-nightly-412a51816-250219
@@ -8,2 +8,3 @@ | ||
$parcel$export(module.exports, "getOwnerWindow", () => $aaa611146751592e$export$f21a1ffae260145a); | ||
$parcel$export(module.exports, "isShadowRoot", () => $aaa611146751592e$export$af51f0f06c0f328a); | ||
const $aaa611146751592e$export$b204af158042fbac = (el)=>{ | ||
@@ -18,4 +19,12 @@ var _el_ownerDocument; | ||
}; | ||
/** | ||
* Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property. | ||
*/ function $aaa611146751592e$var$isNode(value) { | ||
return value !== null && typeof value === 'object' && 'nodeType' in value && typeof value.nodeType === 'number'; | ||
} | ||
function $aaa611146751592e$export$af51f0f06c0f328a(node) { | ||
return $aaa611146751592e$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'host' in node; | ||
} | ||
//# sourceMappingURL=domHelpers.main.js.map |
@@ -10,5 +10,13 @@ const $431fbd86ca7dc216$export$b204af158042fbac = (el)=>{ | ||
}; | ||
/** | ||
* Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property. | ||
*/ function $431fbd86ca7dc216$var$isNode(value) { | ||
return value !== null && typeof value === 'object' && 'nodeType' in value && typeof value.nodeType === 'number'; | ||
} | ||
function $431fbd86ca7dc216$export$af51f0f06c0f328a(node) { | ||
return $431fbd86ca7dc216$var$isNode(node) && node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && 'host' in node; | ||
} | ||
export {$431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow}; | ||
export {$431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow, $431fbd86ca7dc216$export$af51f0f06c0f328a as isShadowRoot}; | ||
//# sourceMappingURL=domHelpers.module.js.map |
var $8c61827343eed941$exports = require("./useId.main.js"); | ||
var $1e2191638e54f613$exports = require("./chain.main.js"); | ||
var $8e13b2545651735a$exports = require("./ShadowTreeWalker.main.js"); | ||
var $d723bea02f3e2567$exports = require("./DOMFunctions.main.js"); | ||
var $aaa611146751592e$exports = require("./domHelpers.main.js"); | ||
@@ -16,2 +18,3 @@ var $f847cd1382ea7cd4$exports = require("./mergeProps.main.js"); | ||
var $29293a6f5c75b37e$exports = require("./useUpdateEffect.main.js"); | ||
var $0fa310503218f75f$exports = require("./useUpdateLayoutEffect.main.js"); | ||
var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js"); | ||
@@ -34,2 +37,7 @@ var $37733e1652f47193$exports = require("./useResizeObserver.main.js"); | ||
var $faa6ccd6fb62f877$exports = require("./useLoadMore.main.js"); | ||
var $13915169b1e4142c$exports = require("./inertValue.main.js"); | ||
var $a0850d0add29d276$exports = require("./constants.main.js"); | ||
var $2308dc377e184bb0$exports = require("./keyboard.main.js"); | ||
var $5bd06107f98811f5$exports = require("./animation.main.js"); | ||
var $506b33fd893eab7d$exports = require("./isFocusable.main.js"); | ||
var $1Yh1N$reactstatelyutils = require("@react-stately/utils"); | ||
@@ -46,4 +54,10 @@ | ||
$parcel$export(module.exports, "chain", () => $1e2191638e54f613$exports.chain); | ||
$parcel$export(module.exports, "createShadowTreeWalker", () => $8e13b2545651735a$exports.createShadowTreeWalker); | ||
$parcel$export(module.exports, "ShadowTreeWalker", () => $8e13b2545651735a$exports.ShadowTreeWalker); | ||
$parcel$export(module.exports, "getActiveElement", () => $d723bea02f3e2567$exports.getActiveElement); | ||
$parcel$export(module.exports, "getEventTarget", () => $d723bea02f3e2567$exports.getEventTarget); | ||
$parcel$export(module.exports, "nodeContains", () => $d723bea02f3e2567$exports.nodeContains); | ||
$parcel$export(module.exports, "getOwnerDocument", () => $aaa611146751592e$exports.getOwnerDocument); | ||
$parcel$export(module.exports, "getOwnerWindow", () => $aaa611146751592e$exports.getOwnerWindow); | ||
$parcel$export(module.exports, "isShadowRoot", () => $aaa611146751592e$exports.isShadowRoot); | ||
$parcel$export(module.exports, "mergeProps", () => $f847cd1382ea7cd4$exports.mergeProps); | ||
@@ -67,2 +81,3 @@ $parcel$export(module.exports, "mergeRefs", () => $f05dc24eafaeb7e2$exports.mergeRefs); | ||
$parcel$export(module.exports, "useUpdateEffect", () => $29293a6f5c75b37e$exports.useUpdateEffect); | ||
$parcel$export(module.exports, "useUpdateLayoutEffect", () => $0fa310503218f75f$exports.useUpdateLayoutEffect); | ||
$parcel$export(module.exports, "useLayoutEffect", () => $78605a5d7424e31b$exports.useLayoutEffect); | ||
@@ -97,2 +112,11 @@ $parcel$export(module.exports, "useResizeObserver", () => $37733e1652f47193$exports.useResizeObserver); | ||
$parcel$export(module.exports, "useLoadMore", () => $faa6ccd6fb62f877$exports.useLoadMore); | ||
$parcel$export(module.exports, "inertValue", () => $13915169b1e4142c$exports.inertValue); | ||
$parcel$export(module.exports, "CLEAR_FOCUS_EVENT", () => $a0850d0add29d276$exports.CLEAR_FOCUS_EVENT); | ||
$parcel$export(module.exports, "FOCUS_EVENT", () => $a0850d0add29d276$exports.FOCUS_EVENT); | ||
$parcel$export(module.exports, "UPDATE_ACTIVEDESCENDANT", () => $a0850d0add29d276$exports.UPDATE_ACTIVEDESCENDANT); | ||
$parcel$export(module.exports, "isCtrlKeyPressed", () => $2308dc377e184bb0$exports.isCtrlKeyPressed); | ||
$parcel$export(module.exports, "useEnterAnimation", () => $5bd06107f98811f5$exports.useEnterAnimation); | ||
$parcel$export(module.exports, "useExitAnimation", () => $5bd06107f98811f5$exports.useExitAnimation); | ||
$parcel$export(module.exports, "isFocusable", () => $506b33fd893eab7d$exports.isFocusable); | ||
$parcel$export(module.exports, "isTabbable", () => $506b33fd893eab7d$exports.isTabbable); | ||
/* | ||
@@ -143,2 +167,10 @@ * Copyright 2020 Adobe. All rights reserved. | ||
//# sourceMappingURL=main.js.map |
import {mergeIds as $bdb11010cef70236$export$cd8c9cb68f842629, useId as $bdb11010cef70236$export$f680877a34711e37, useSlotId as $bdb11010cef70236$export$b4cc09c592e8fdb8} from "./useId.module.js"; | ||
import {chain as $ff5963eb1fccf552$export$e08e3b67e392101e} from "./chain.module.js"; | ||
import {getOwnerDocument as $431fbd86ca7dc216$export$b204af158042fbac, getOwnerWindow as $431fbd86ca7dc216$export$f21a1ffae260145a} from "./domHelpers.module.js"; | ||
import {createShadowTreeWalker as $dfc540311bf7f109$export$4d0f8be8b12a7ef6, ShadowTreeWalker as $dfc540311bf7f109$export$63eb3ababa9c55c4} from "./ShadowTreeWalker.module.js"; | ||
import {getActiveElement as $d4ee10de306f2510$export$cd4e5573fbe2b576, getEventTarget as $d4ee10de306f2510$export$e58f029f0fbfdb29, nodeContains as $d4ee10de306f2510$export$4282f70798064fe0} from "./DOMFunctions.module.js"; | ||
import {getOwnerDocument as $431fbd86ca7dc216$export$b204af158042fbac, getOwnerWindow as $431fbd86ca7dc216$export$f21a1ffae260145a, isShadowRoot as $431fbd86ca7dc216$export$af51f0f06c0f328a} from "./domHelpers.module.js"; | ||
import {mergeProps as $3ef42575df84b30b$export$9d1611c77c2fe928} from "./mergeProps.module.js"; | ||
@@ -16,2 +18,3 @@ import {mergeRefs as $5dc95899b306f630$export$c9058316764c140e} from "./mergeRefs.module.js"; | ||
import {useUpdateEffect as $4f58c5f72bcf79f7$export$496315a1608d9602} from "./useUpdateEffect.module.js"; | ||
import {useUpdateLayoutEffect as $ca9b37712f007381$export$72ef708ab07251f1} from "./useUpdateLayoutEffect.module.js"; | ||
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js"; | ||
@@ -34,2 +37,7 @@ import {useResizeObserver as $9daab02d461809db$export$683480f191c0e3ea} from "./useResizeObserver.module.js"; | ||
import {useLoadMore as $26f7f3da73fcd9d6$export$7717c92ee915373e} from "./useLoadMore.module.js"; | ||
import {inertValue as $cdc5a6778b766db2$export$a9d04c5684123369} from "./inertValue.module.js"; | ||
import {CLEAR_FOCUS_EVENT as $5671b20cf9b562b2$export$447a38995de2c711, FOCUS_EVENT as $5671b20cf9b562b2$export$831c820ad60f9d12, UPDATE_ACTIVEDESCENDANT as $5671b20cf9b562b2$export$9db568f6321ad9dc} from "./constants.module.js"; | ||
import {isCtrlKeyPressed as $21f1aa98acb08317$export$16792effe837dba3} from "./keyboard.module.js"; | ||
import {useEnterAnimation as $d3f049242431219c$export$6d3443f2c48bfc20, useExitAnimation as $d3f049242431219c$export$45fda7c47f93fd48} from "./animation.module.js"; | ||
import {isFocusable as $b4b717babfbb907b$export$4c063cf1350e6fed, isTabbable as $b4b717babfbb907b$export$bebd5a1431fec25d} from "./isFocusable.module.js"; | ||
import {clamp as $4507461a1b870123$re_export$clamp, snapValueToStep as $4507461a1b870123$re_export$snapValueToStep} from "@react-stately/utils"; | ||
@@ -82,3 +90,11 @@ | ||
export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $a40c673dc9f6d9c7$export$94ed1c92c7beeb22 as getScrollParents, $cc38e7bd3fc7b213$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $c87311424ea30a05$export$b7d78993b74f766d as isFirefox, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent, $5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo, $99facab73266f662$export$5add1d006293d136 as useFormReset, $26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore}; | ||
export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $dfc540311bf7f109$export$4d0f8be8b12a7ef6 as createShadowTreeWalker, $dfc540311bf7f109$export$63eb3ababa9c55c4 as ShadowTreeWalker, $d4ee10de306f2510$export$cd4e5573fbe2b576 as getActiveElement, $d4ee10de306f2510$export$e58f029f0fbfdb29 as getEventTarget, $d4ee10de306f2510$export$4282f70798064fe0 as nodeContains, $431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow, $431fbd86ca7dc216$export$af51f0f06c0f328a as isShadowRoot, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $ca9b37712f007381$export$72ef708ab07251f1 as useUpdateLayoutEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $a40c673dc9f6d9c7$export$94ed1c92c7beeb22 as getScrollParents, $cc38e7bd3fc7b213$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $c87311424ea30a05$export$b7d78993b74f766d as isFirefox, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent, $5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo, $99facab73266f662$export$5add1d006293d136 as useFormReset, $26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore, $cdc5a6778b766db2$export$a9d04c5684123369 as inertValue, $5671b20cf9b562b2$export$447a38995de2c711 as CLEAR_FOCUS_EVENT, $5671b20cf9b562b2$export$831c820ad60f9d12 as FOCUS_EVENT, $5671b20cf9b562b2$export$9db568f6321ad9dc as UPDATE_ACTIVEDESCENDANT, $21f1aa98acb08317$export$16792effe837dba3 as isCtrlKeyPressed, $d3f049242431219c$export$6d3443f2c48bfc20 as useEnterAnimation, $d3f049242431219c$export$45fda7c47f93fd48 as useExitAnimation, $b4b717babfbb907b$export$4c063cf1350e6fed as isFocusable, $b4b717babfbb907b$export$bebd5a1431fec25d as isTabbable}; | ||
//# sourceMappingURL=module.js.map |
@@ -28,13 +28,19 @@ var $49f0d9486c2408aa$exports = require("./getScrollParents.main.js"); | ||
let y = scrollView.scrollTop; | ||
// Account for top/left border offsetting the scroll top/Left | ||
let { borderTopWidth: borderTopWidth, borderLeftWidth: borderLeftWidth } = getComputedStyle(scrollView); | ||
let borderAdjustedX = scrollView.scrollLeft + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = scrollView.scrollTop + parseInt(borderTopWidth, 10); | ||
// Account for top/left border offsetting the scroll top/Left + scroll padding | ||
let { borderTopWidth: borderTopWidth, borderLeftWidth: borderLeftWidth, scrollPaddingTop: scrollPaddingTop, scrollPaddingRight: scrollPaddingRight, scrollPaddingBottom: scrollPaddingBottom, scrollPaddingLeft: scrollPaddingLeft } = getComputedStyle(scrollView); | ||
let borderAdjustedX = x + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = y + parseInt(borderTopWidth, 10); | ||
// Ignore end/bottom border via clientHeight/Width instead of offsetHeight/Width | ||
let maxX = borderAdjustedX + scrollView.clientWidth; | ||
let maxY = borderAdjustedY + scrollView.clientHeight; | ||
if (offsetX <= x) x = offsetX - parseInt(borderLeftWidth, 10); | ||
else if (offsetX + width > maxX) x += offsetX + width - maxX; | ||
if (offsetY <= borderAdjustedY) y = offsetY - parseInt(borderTopWidth, 10); | ||
else if (offsetY + height > maxY) y += offsetY + height - maxY; | ||
// Get scroll padding values as pixels - defaults to 0 if no scroll padding | ||
// is used. | ||
let scrollPaddingTopNumber = parseInt(scrollPaddingTop, 10) || 0; | ||
let scrollPaddingBottomNumber = parseInt(scrollPaddingBottom, 10) || 0; | ||
let scrollPaddingRightNumber = parseInt(scrollPaddingRight, 10) || 0; | ||
let scrollPaddingLeftNumber = parseInt(scrollPaddingLeft, 10) || 0; | ||
if (offsetX <= x + scrollPaddingLeftNumber) x = offsetX - parseInt(borderLeftWidth, 10) - scrollPaddingLeftNumber; | ||
else if (offsetX + width > maxX - scrollPaddingRightNumber) x += offsetX + width - maxX + scrollPaddingRightNumber; | ||
if (offsetY <= borderAdjustedY + scrollPaddingTopNumber) y = offsetY - parseInt(borderTopWidth, 10) - scrollPaddingTopNumber; | ||
else if (offsetY + height > maxY - scrollPaddingBottomNumber) y += offsetY + height - maxY + scrollPaddingBottomNumber; | ||
scrollView.scrollLeft = x; | ||
@@ -41,0 +47,0 @@ scrollView.scrollTop = y; |
@@ -21,13 +21,19 @@ import {getScrollParents as $a40c673dc9f6d9c7$export$94ed1c92c7beeb22} from "./getScrollParents.module.js"; | ||
let y = scrollView.scrollTop; | ||
// Account for top/left border offsetting the scroll top/Left | ||
let { borderTopWidth: borderTopWidth, borderLeftWidth: borderLeftWidth } = getComputedStyle(scrollView); | ||
let borderAdjustedX = scrollView.scrollLeft + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = scrollView.scrollTop + parseInt(borderTopWidth, 10); | ||
// Account for top/left border offsetting the scroll top/Left + scroll padding | ||
let { borderTopWidth: borderTopWidth, borderLeftWidth: borderLeftWidth, scrollPaddingTop: scrollPaddingTop, scrollPaddingRight: scrollPaddingRight, scrollPaddingBottom: scrollPaddingBottom, scrollPaddingLeft: scrollPaddingLeft } = getComputedStyle(scrollView); | ||
let borderAdjustedX = x + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = y + parseInt(borderTopWidth, 10); | ||
// Ignore end/bottom border via clientHeight/Width instead of offsetHeight/Width | ||
let maxX = borderAdjustedX + scrollView.clientWidth; | ||
let maxY = borderAdjustedY + scrollView.clientHeight; | ||
if (offsetX <= x) x = offsetX - parseInt(borderLeftWidth, 10); | ||
else if (offsetX + width > maxX) x += offsetX + width - maxX; | ||
if (offsetY <= borderAdjustedY) y = offsetY - parseInt(borderTopWidth, 10); | ||
else if (offsetY + height > maxY) y += offsetY + height - maxY; | ||
// Get scroll padding values as pixels - defaults to 0 if no scroll padding | ||
// is used. | ||
let scrollPaddingTopNumber = parseInt(scrollPaddingTop, 10) || 0; | ||
let scrollPaddingBottomNumber = parseInt(scrollPaddingBottom, 10) || 0; | ||
let scrollPaddingRightNumber = parseInt(scrollPaddingRight, 10) || 0; | ||
let scrollPaddingLeftNumber = parseInt(scrollPaddingLeft, 10) || 0; | ||
if (offsetX <= x + scrollPaddingLeftNumber) x = offsetX - parseInt(borderLeftWidth, 10) - scrollPaddingLeftNumber; | ||
else if (offsetX + width > maxX - scrollPaddingRightNumber) x += offsetX + width - maxX + scrollPaddingRightNumber; | ||
if (offsetY <= borderAdjustedY + scrollPaddingTopNumber) y = offsetY - parseInt(borderTopWidth, 10) - scrollPaddingTopNumber; | ||
else if (offsetY + height > maxY - scrollPaddingBottomNumber) y += offsetY + height - maxY + scrollPaddingBottomNumber; | ||
scrollView.scrollLeft = x; | ||
@@ -34,0 +40,0 @@ scrollView.scrollTop = y; |
@@ -26,2 +26,48 @@ import React, { ForwardedRef, MutableRefObject, ReactNode, HTMLAttributes, EffectCallback, Dispatch, RefObject as _RefObject1 } from "react"; | ||
export const getOwnerWindow: (el: (Window & typeof global) | Element | null | undefined) => Window & typeof global; | ||
/** | ||
* Type guard that checks if a node is a ShadowRoot. Uses nodeType and host property checks to | ||
* distinguish ShadowRoot from other DocumentFragments. | ||
*/ | ||
export function isShadowRoot(node: Node | null): node is ShadowRoot; | ||
/** | ||
* ShadowDOM safe version of Node.contains. | ||
*/ | ||
export function nodeContains(node: Node | null | undefined, otherNode: Node | null | undefined): boolean; | ||
/** | ||
* ShadowDOM safe version of document.activeElement. | ||
*/ | ||
export const getActiveElement: (doc?: Document) => Element | null; | ||
/** | ||
* ShadowDOM safe version of event.target. | ||
*/ | ||
export function getEventTarget(event: any): Element; | ||
export class ShadowTreeWalker implements TreeWalker { | ||
readonly filter: NodeFilter | null; | ||
readonly root: Node; | ||
readonly whatToShow: number; | ||
constructor(doc: Document, root: Node, whatToShow?: number, filter?: NodeFilter | null); | ||
get currentNode(): Node; | ||
set currentNode(node: Node); | ||
get doc(): Document; | ||
firstChild(): Node | null; | ||
lastChild(): Node | null; | ||
nextNode(): Node | null; | ||
previousNode(): Node | null; | ||
/** | ||
* @deprecated | ||
*/ | ||
nextSibling(): Node | null; | ||
/** | ||
* @deprecated | ||
*/ | ||
previousSibling(): Node | null; | ||
/** | ||
* @deprecated | ||
*/ | ||
parentNode(): Node | null; | ||
} | ||
/** | ||
* ShadowDOM safe version of document.createTreeWalker. | ||
*/ | ||
export function createShadowTreeWalker(doc: Document, root: Node, whatToShow?: number, filter?: NodeFilter | null): TreeWalker; | ||
interface Props { | ||
@@ -104,25 +150,25 @@ [key: string]: any; | ||
export function useSyntheticLinkProps(props: LinkDOMProps): { | ||
'data-href': string; | ||
'data-target': React.HTMLAttributeAnchorTarget; | ||
'data-rel': string; | ||
'data-download': string | boolean; | ||
'data-ping': string; | ||
'data-referrer-policy': React.HTMLAttributeReferrerPolicy; | ||
'data-href': string | undefined; | ||
'data-target': React.HTMLAttributeAnchorTarget | undefined; | ||
'data-rel': string | undefined; | ||
'data-download': string | boolean | undefined; | ||
'data-ping': string | undefined; | ||
'data-referrer-policy': React.HTMLAttributeReferrerPolicy | undefined; | ||
}; | ||
/** @deprecated - For backward compatibility. */ | ||
export function getSyntheticLinkProps(props: LinkDOMProps): { | ||
'data-href': string; | ||
'data-target': React.HTMLAttributeAnchorTarget; | ||
'data-rel': string; | ||
'data-download': string | boolean; | ||
'data-ping': string; | ||
'data-referrer-policy': React.HTMLAttributeReferrerPolicy; | ||
'data-href': string | undefined; | ||
'data-target': React.HTMLAttributeAnchorTarget | undefined; | ||
'data-rel': string | undefined; | ||
'data-download': string | boolean | undefined; | ||
'data-ping': string | undefined; | ||
'data-referrer-policy': React.HTMLAttributeReferrerPolicy | undefined; | ||
}; | ||
export function useLinkProps(props: LinkDOMProps): { | ||
href: string; | ||
target: React.HTMLAttributeAnchorTarget; | ||
rel: string; | ||
download: string | boolean; | ||
ping: string; | ||
referrerPolicy: React.HTMLAttributeReferrerPolicy; | ||
export function useLinkProps(props?: LinkDOMProps): { | ||
href: string | undefined; | ||
target: React.HTMLAttributeAnchorTarget | undefined; | ||
rel: string | undefined; | ||
download: string | boolean | undefined; | ||
ping: string | undefined; | ||
referrerPolicy: React.HTMLAttributeReferrerPolicy | undefined; | ||
}; | ||
@@ -145,2 +191,3 @@ export function runAfterTransition(fn: () => void): void; | ||
interface GlobalListeners { | ||
addGlobalListener<K extends keyof WindowEventMap>(el: Window, type: K, listener: (this: Document, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; | ||
addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; | ||
@@ -169,3 +216,4 @@ addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; | ||
export function useObjectRef<T>(forwardedRef?: ((instance: T | null) => void) | MutableRefObject<T | null> | null): MutableRefObject<T | null>; | ||
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): void; | ||
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): (() => void) | void; | ||
export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void; | ||
type useResizeObserverOptionsType<T> = { | ||
@@ -196,3 +244,3 @@ ref: RefObject<T | undefined | null> | undefined; | ||
/** The optional containing element of the target to be centered in the viewport. */ | ||
containingElement?: Element; | ||
containingElement?: Element | null; | ||
} | ||
@@ -232,4 +280,18 @@ /** | ||
export function useLoadMore(props: LoadMoreProps, ref: _RefObject1<HTMLElement | null>): void; | ||
export function inertValue(value?: boolean): boolean | "true" | undefined; | ||
export const CLEAR_FOCUS_EVENT = "react-aria-clear-focus"; | ||
export const FOCUS_EVENT = "react-aria-focus"; | ||
export const UPDATE_ACTIVEDESCENDANT = "react-aria-update-activedescendant"; | ||
interface Event { | ||
altKey: boolean; | ||
ctrlKey: boolean; | ||
metaKey: boolean; | ||
} | ||
export function isCtrlKeyPressed(e: Event): boolean; | ||
export function useEnterAnimation(ref: _RefObject1<HTMLElement | null>, isReady?: boolean): boolean; | ||
export function useExitAnimation(ref: _RefObject1<HTMLElement | null>, isOpen: boolean): boolean; | ||
export function isFocusable(element: Element): boolean; | ||
export function isTabbable(element: Element): boolean; | ||
export { clamp, snapValueToStep } from '@react-stately/utils'; | ||
//# sourceMappingURL=types.d.ts.map |
@@ -34,3 +34,3 @@ var $eHdSW$react = require("react"); | ||
}); | ||
eventTarget.addEventListener(type, listener, options); | ||
eventTarget.addEventListener(type, fn, options); | ||
}, []); | ||
@@ -37,0 +37,0 @@ let removeGlobalListener = (0, $eHdSW$react.useCallback)((eventTarget, type, listener, options)=>{ |
@@ -28,3 +28,3 @@ import {useRef as $lPAwt$useRef, useCallback as $lPAwt$useCallback, useEffect as $lPAwt$useEffect} from "react"; | ||
}); | ||
eventTarget.addEventListener(type, listener, options); | ||
eventTarget.addEventListener(type, fn, options); | ||
}, []); | ||
@@ -31,0 +31,0 @@ let removeGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{ |
@@ -30,3 +30,9 @@ var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js"); | ||
let $8c61827343eed941$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
let $8c61827343eed941$var$idsUpdaterMap = new Map(); | ||
let $8c61827343eed941$export$d41a04c74483c6ef = new Map(); | ||
// This allows us to clean up the idsUpdaterMap when the id is no longer used. | ||
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise. | ||
// This can happen in suspended components where mount/unmount is not called. | ||
let $8c61827343eed941$var$registry = new FinalizationRegistry((heldValue)=>{ | ||
$8c61827343eed941$export$d41a04c74483c6ef.delete(heldValue); | ||
}); | ||
function $8c61827343eed941$export$f680877a34711e37(defaultId) { | ||
@@ -36,14 +42,10 @@ let [value, setValue] = (0, $dG5aF$react.useState)(defaultId); | ||
let res = (0, $dG5aF$reactariassr.useSSRSafeId)(value); | ||
let updateValue = (0, $dG5aF$react.useCallback)((val)=>{ | ||
nextId.current = val; | ||
}, []); | ||
let cleanupRef = (0, $dG5aF$react.useRef)(null); | ||
$8c61827343eed941$var$registry.register(cleanupRef, res); | ||
if ($8c61827343eed941$var$canUseDOM) { | ||
// TS not smart enough to know that `has` means the value exists | ||
if ($8c61827343eed941$var$idsUpdaterMap.has(res) && !$8c61827343eed941$var$idsUpdaterMap.get(res).includes(updateValue)) $8c61827343eed941$var$idsUpdaterMap.set(res, [ | ||
...$8c61827343eed941$var$idsUpdaterMap.get(res), | ||
updateValue | ||
const cacheIdRef = $8c61827343eed941$export$d41a04c74483c6ef.get(res); | ||
if (cacheIdRef && !cacheIdRef.includes(nextId)) cacheIdRef.push(nextId); | ||
else $8c61827343eed941$export$d41a04c74483c6ef.set(res, [ | ||
nextId | ||
]); | ||
else $8c61827343eed941$var$idsUpdaterMap.set(res, [ | ||
updateValue | ||
]); | ||
} | ||
@@ -53,3 +55,6 @@ (0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{ | ||
return ()=>{ | ||
$8c61827343eed941$var$idsUpdaterMap.delete(r); | ||
// In Suspense, the cleanup function may be not called | ||
// when it is though, also remove it from the finalization registry. | ||
$8c61827343eed941$var$registry.unregister(cleanupRef); | ||
$8c61827343eed941$export$d41a04c74483c6ef.delete(r); | ||
}; | ||
@@ -59,10 +64,10 @@ }, [ | ||
]); | ||
// This cannot cause an infinite loop because the ref is updated first. | ||
// This cannot cause an infinite loop because the ref is always cleaned up. | ||
// eslint-disable-next-line | ||
(0, $dG5aF$react.useEffect)(()=>{ | ||
let newId = nextId.current; | ||
if (newId) { | ||
nextId.current = null; | ||
setValue(newId); | ||
} | ||
if (newId) setValue(newId); | ||
return ()=>{ | ||
if (newId) nextId.current = null; | ||
}; | ||
}); | ||
@@ -73,10 +78,10 @@ return res; | ||
if (idA === idB) return idA; | ||
let setIdsA = $8c61827343eed941$var$idsUpdaterMap.get(idA); | ||
let setIdsA = $8c61827343eed941$export$d41a04c74483c6ef.get(idA); | ||
if (setIdsA) { | ||
setIdsA.forEach((fn)=>fn(idB)); | ||
setIdsA.forEach((ref)=>ref.current = idB); | ||
return idB; | ||
} | ||
let setIdsB = $8c61827343eed941$var$idsUpdaterMap.get(idB); | ||
let setIdsB = $8c61827343eed941$export$d41a04c74483c6ef.get(idB); | ||
if (setIdsB) { | ||
setIdsB.forEach((fn)=>fn(idA)); | ||
setIdsB.forEach((ref)=>ref.current = idA); | ||
return idA; | ||
@@ -83,0 +88,0 @@ } |
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js"; | ||
import {useValueEffect as $1dbecbe27a04f9af$export$14d238f342723f25} from "./useValueEffect.module.js"; | ||
import {useState as $eKkEp$useState, useRef as $eKkEp$useRef, useCallback as $eKkEp$useCallback, useEffect as $eKkEp$useEffect} from "react"; | ||
import {useState as $eKkEp$useState, useRef as $eKkEp$useRef, useEffect as $eKkEp$useEffect, useCallback as $eKkEp$useCallback} from "react"; | ||
import {useSSRSafeId as $eKkEp$useSSRSafeId} from "@react-aria/ssr"; | ||
@@ -22,3 +22,9 @@ | ||
let $bdb11010cef70236$var$canUseDOM = Boolean(typeof window !== 'undefined' && window.document && window.document.createElement); | ||
let $bdb11010cef70236$var$idsUpdaterMap = new Map(); | ||
let $bdb11010cef70236$export$d41a04c74483c6ef = new Map(); | ||
// This allows us to clean up the idsUpdaterMap when the id is no longer used. | ||
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise. | ||
// This can happen in suspended components where mount/unmount is not called. | ||
let $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{ | ||
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue); | ||
}); | ||
function $bdb11010cef70236$export$f680877a34711e37(defaultId) { | ||
@@ -28,14 +34,10 @@ let [value, setValue] = (0, $eKkEp$useState)(defaultId); | ||
let res = (0, $eKkEp$useSSRSafeId)(value); | ||
let updateValue = (0, $eKkEp$useCallback)((val)=>{ | ||
nextId.current = val; | ||
}, []); | ||
let cleanupRef = (0, $eKkEp$useRef)(null); | ||
$bdb11010cef70236$var$registry.register(cleanupRef, res); | ||
if ($bdb11010cef70236$var$canUseDOM) { | ||
// TS not smart enough to know that `has` means the value exists | ||
if ($bdb11010cef70236$var$idsUpdaterMap.has(res) && !$bdb11010cef70236$var$idsUpdaterMap.get(res).includes(updateValue)) $bdb11010cef70236$var$idsUpdaterMap.set(res, [ | ||
...$bdb11010cef70236$var$idsUpdaterMap.get(res), | ||
updateValue | ||
const cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res); | ||
if (cacheIdRef && !cacheIdRef.includes(nextId)) cacheIdRef.push(nextId); | ||
else $bdb11010cef70236$export$d41a04c74483c6ef.set(res, [ | ||
nextId | ||
]); | ||
else $bdb11010cef70236$var$idsUpdaterMap.set(res, [ | ||
updateValue | ||
]); | ||
} | ||
@@ -45,3 +47,6 @@ (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{ | ||
return ()=>{ | ||
$bdb11010cef70236$var$idsUpdaterMap.delete(r); | ||
// In Suspense, the cleanup function may be not called | ||
// when it is though, also remove it from the finalization registry. | ||
$bdb11010cef70236$var$registry.unregister(cleanupRef); | ||
$bdb11010cef70236$export$d41a04c74483c6ef.delete(r); | ||
}; | ||
@@ -51,10 +56,10 @@ }, [ | ||
]); | ||
// This cannot cause an infinite loop because the ref is updated first. | ||
// This cannot cause an infinite loop because the ref is always cleaned up. | ||
// eslint-disable-next-line | ||
(0, $eKkEp$useEffect)(()=>{ | ||
let newId = nextId.current; | ||
if (newId) { | ||
nextId.current = null; | ||
setValue(newId); | ||
} | ||
if (newId) setValue(newId); | ||
return ()=>{ | ||
if (newId) nextId.current = null; | ||
}; | ||
}); | ||
@@ -65,10 +70,10 @@ return res; | ||
if (idA === idB) return idA; | ||
let setIdsA = $bdb11010cef70236$var$idsUpdaterMap.get(idA); | ||
let setIdsA = $bdb11010cef70236$export$d41a04c74483c6ef.get(idA); | ||
if (setIdsA) { | ||
setIdsA.forEach((fn)=>fn(idB)); | ||
setIdsA.forEach((ref)=>ref.current = idB); | ||
return idB; | ||
} | ||
let setIdsB = $bdb11010cef70236$var$idsUpdaterMap.get(idB); | ||
let setIdsB = $bdb11010cef70236$export$d41a04c74483c6ef.get(idB); | ||
if (setIdsB) { | ||
setIdsB.forEach((fn)=>fn(idA)); | ||
setIdsB.forEach((ref)=>ref.current = idA); | ||
return idA; | ||
@@ -99,3 +104,3 @@ } | ||
export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId}; | ||
export {$bdb11010cef70236$export$d41a04c74483c6ef as idsUpdaterMap, $bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId}; | ||
//# sourceMappingURL=useId.module.js.map |
@@ -31,3 +31,3 @@ var $cagC1$react = require("react"); | ||
if (isInitialMount.current) isInitialMount.current = false; | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect(); | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) return effect(); | ||
lastDeps.current = dependencies; | ||
@@ -34,0 +34,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -25,3 +25,3 @@ import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react"; | ||
if (isInitialMount.current) isInitialMount.current = false; | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect(); | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) return effect(); | ||
lastDeps.current = dependencies; | ||
@@ -28,0 +28,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -22,3 +22,2 @@ var $4gIVO$react = require("react"); | ||
// @ts-ignore | ||
let $8b24bab62f5c65ad$var$visualViewport = typeof document !== 'undefined' && window.visualViewport; | ||
@@ -25,0 +24,0 @@ function $8b24bab62f5c65ad$export$d699905dd57c73ca() { |
@@ -16,3 +16,2 @@ import {useState as $fuDHA$useState, useEffect as $fuDHA$useEffect} from "react"; | ||
// @ts-ignore | ||
let $5df64b3807dc15ee$var$visualViewport = typeof document !== 'undefined' && window.visualViewport; | ||
@@ -19,0 +18,0 @@ function $5df64b3807dc15ee$export$d699905dd57c73ca() { |
{ | ||
"name": "@react-aria/utils", | ||
"version": "3.0.0-nightly-3f67667d5-241111", | ||
"version": "3.0.0-nightly-412a51816-250219", | ||
"description": "Spectrum UI components in React", | ||
@@ -25,5 +25,6 @@ "license": "Apache-2.0", | ||
"dependencies": { | ||
"@react-aria/ssr": "^3.0.0-nightly-3f67667d5-241111", | ||
"@react-stately/utils": "^3.0.0-nightly-3f67667d5-241111", | ||
"@react-types/shared": "^3.0.0-nightly-3f67667d5-241111", | ||
"@react-aria/ssr": "3.0.0-nightly-412a51816-250219", | ||
"@react-stately/flags": "3.0.0-nightly-412a51816-250219", | ||
"@react-stately/utils": "3.0.0-nightly-412a51816-250219", | ||
"@react-types/shared": "3.0.0-nightly-412a51816-250219", | ||
"@swc/helpers": "^0.5.0", | ||
@@ -33,8 +34,8 @@ "clsx": "^2.0.0" | ||
"peerDependencies": { | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0" | ||
"react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1", | ||
"react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0 || ^19.0.0-rc.1" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"stableVersion": "3.25.3" | ||
} | ||
} |
@@ -15,1 +15,20 @@ export const getOwnerDocument = (el: Element | null | undefined): Document => { | ||
}; | ||
/** | ||
* Type guard that checks if a value is a Node. Verifies the presence and type of the nodeType property. | ||
*/ | ||
function isNode(value: unknown): value is Node { | ||
return value !== null && | ||
typeof value === 'object' && | ||
'nodeType' in value && | ||
typeof (value as Node).nodeType === 'number'; | ||
} | ||
/** | ||
* Type guard that checks if a node is a ShadowRoot. Uses nodeType and host property checks to | ||
* distinguish ShadowRoot from other DocumentFragments. | ||
*/ | ||
export function isShadowRoot(node: Node | null): node is ShadowRoot { | ||
return isNode(node) && | ||
node.nodeType === Node.DOCUMENT_FRAGMENT_NODE && | ||
'host' in node; | ||
} |
@@ -14,3 +14,5 @@ /* | ||
export {chain} from './chain'; | ||
export {getOwnerDocument, getOwnerWindow} from './domHelpers'; | ||
export {createShadowTreeWalker, ShadowTreeWalker} from './shadowdom/ShadowTreeWalker'; | ||
export {getActiveElement, getEventTarget, nodeContains} from './shadowdom/DOMFunctions'; | ||
export {getOwnerDocument, getOwnerWindow, isShadowRoot} from './domHelpers'; | ||
export {mergeProps} from './mergeProps'; | ||
@@ -28,2 +30,3 @@ export {mergeRefs} from './mergeRefs'; | ||
export {useUpdateEffect} from './useUpdateEffect'; | ||
export {useUpdateLayoutEffect} from './useUpdateLayoutEffect'; | ||
export {useLayoutEffect} from './useLayoutEffect'; | ||
@@ -47,1 +50,6 @@ export {useResizeObserver} from './useResizeObserver'; | ||
export {useLoadMore} from './useLoadMore'; | ||
export {inertValue} from './inertValue'; | ||
export {CLEAR_FOCUS_EVENT, FOCUS_EVENT, UPDATE_ACTIVEDESCENDANT} from './constants'; | ||
export {isCtrlKeyPressed} from './keyboard'; | ||
export {useEnterAnimation, useExitAnimation} from './animation'; | ||
export {isFocusable, isTabbable} from './isFocusable'; |
@@ -26,3 +26,3 @@ /* | ||
type NullToObject<T> = T extends (null | undefined) ? {} : T; | ||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; | ||
@@ -29,0 +29,0 @@ |
@@ -17,3 +17,3 @@ /* | ||
/** The optional containing element of the target to be centered in the viewport. */ | ||
containingElement?: Element | ||
containingElement?: Element | null | ||
} | ||
@@ -34,6 +34,14 @@ | ||
// Account for top/left border offsetting the scroll top/Left | ||
let {borderTopWidth, borderLeftWidth} = getComputedStyle(scrollView); | ||
let borderAdjustedX = scrollView.scrollLeft + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = scrollView.scrollTop + parseInt(borderTopWidth, 10); | ||
// Account for top/left border offsetting the scroll top/Left + scroll padding | ||
let { | ||
borderTopWidth, | ||
borderLeftWidth, | ||
scrollPaddingTop, | ||
scrollPaddingRight, | ||
scrollPaddingBottom, | ||
scrollPaddingLeft | ||
} = getComputedStyle(scrollView); | ||
let borderAdjustedX = x + parseInt(borderLeftWidth, 10); | ||
let borderAdjustedY = y + parseInt(borderTopWidth, 10); | ||
// Ignore end/bottom border via clientHeight/Width instead of offsetHeight/Width | ||
@@ -43,12 +51,20 @@ let maxX = borderAdjustedX + scrollView.clientWidth; | ||
if (offsetX <= x) { | ||
x = offsetX - parseInt(borderLeftWidth, 10); | ||
} else if (offsetX + width > maxX) { | ||
x += offsetX + width - maxX; | ||
// Get scroll padding values as pixels - defaults to 0 if no scroll padding | ||
// is used. | ||
let scrollPaddingTopNumber = parseInt(scrollPaddingTop, 10) || 0; | ||
let scrollPaddingBottomNumber = parseInt(scrollPaddingBottom, 10) || 0; | ||
let scrollPaddingRightNumber = parseInt(scrollPaddingRight, 10) || 0; | ||
let scrollPaddingLeftNumber = parseInt(scrollPaddingLeft, 10) || 0; | ||
if (offsetX <= x + scrollPaddingLeftNumber) { | ||
x = offsetX - parseInt(borderLeftWidth, 10) - scrollPaddingLeftNumber; | ||
} else if (offsetX + width > maxX - scrollPaddingRightNumber) { | ||
x += offsetX + width - maxX + scrollPaddingRightNumber; | ||
} | ||
if (offsetY <= borderAdjustedY) { | ||
y = offsetY - parseInt(borderTopWidth, 10); | ||
} else if (offsetY + height > maxY) { | ||
y += offsetY + height - maxY; | ||
if (offsetY <= borderAdjustedY + scrollPaddingTopNumber) { | ||
y = offsetY - parseInt(borderTopWidth, 10) - scrollPaddingTopNumber; | ||
} else if (offsetY + height > maxY - scrollPaddingBottomNumber) { | ||
y += offsetY + height - maxY + scrollPaddingBottomNumber; | ||
} | ||
scrollView.scrollLeft = x; | ||
@@ -55,0 +71,0 @@ scrollView.scrollTop = y; |
@@ -16,2 +16,3 @@ /* | ||
interface GlobalListeners { | ||
addGlobalListener<K extends keyof WindowEventMap>(el: Window, type: K, listener: (this: Document, ev: WindowEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void, | ||
addGlobalListener<K extends keyof DocumentEventMap>(el: EventTarget, type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void, | ||
@@ -33,3 +34,3 @@ addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void, | ||
globalListeners.current.set(listener, {type, eventTarget, fn, options}); | ||
eventTarget.addEventListener(type, listener, options); | ||
eventTarget.addEventListener(type, fn, options); | ||
}, []); | ||
@@ -36,0 +37,0 @@ let removeGlobalListener = useCallback((eventTarget, type, listener, options) => { |
@@ -25,3 +25,9 @@ /* | ||
let idsUpdaterMap: Map<string, Array<(v: string) => void>> = new Map(); | ||
export let idsUpdaterMap: Map<string, { current: string | null }[]> = new Map(); | ||
// This allows us to clean up the idsUpdaterMap when the id is no longer used. | ||
// Map is a strong reference, so unused ids wouldn't be cleaned up otherwise. | ||
// This can happen in suspended components where mount/unmount is not called. | ||
let registry = new FinalizationRegistry<string>((heldValue) => { | ||
idsUpdaterMap.delete(heldValue); | ||
}); | ||
@@ -37,13 +43,12 @@ /** | ||
let res = useSSRSafeId(value); | ||
let cleanupRef = useRef(null); | ||
let updateValue = useCallback((val) => { | ||
nextId.current = val; | ||
}, []); | ||
registry.register(cleanupRef, res); | ||
if (canUseDOM) { | ||
// TS not smart enough to know that `has` means the value exists | ||
if (idsUpdaterMap.has(res) && !idsUpdaterMap.get(res)!.includes(updateValue)) { | ||
idsUpdaterMap.set(res, [...idsUpdaterMap.get(res)!, updateValue]); | ||
const cacheIdRef = idsUpdaterMap.get(res); | ||
if (cacheIdRef && !cacheIdRef.includes(nextId)) { | ||
cacheIdRef.push(nextId); | ||
} else { | ||
idsUpdaterMap.set(res, [updateValue]); | ||
idsUpdaterMap.set(res, [nextId]); | ||
} | ||
@@ -55,2 +60,5 @@ } | ||
return () => { | ||
// In Suspense, the cleanup function may be not called | ||
// when it is though, also remove it from the finalization registry. | ||
registry.unregister(cleanupRef); | ||
idsUpdaterMap.delete(r); | ||
@@ -60,10 +68,11 @@ }; | ||
// This cannot cause an infinite loop because the ref is updated first. | ||
// This cannot cause an infinite loop because the ref is always cleaned up. | ||
// eslint-disable-next-line | ||
useEffect(() => { | ||
let newId = nextId.current; | ||
if (newId) { | ||
nextId.current = null; | ||
setValue(newId); | ||
} | ||
if (newId) { setValue(newId); } | ||
return () => { | ||
if (newId) { nextId.current = null; } | ||
}; | ||
}); | ||
@@ -85,3 +94,3 @@ | ||
if (setIdsA) { | ||
setIdsA.forEach(fn => fn(idB)); | ||
setIdsA.forEach(ref => (ref.current = idB)); | ||
return idB; | ||
@@ -92,3 +101,3 @@ } | ||
if (setIdsB) { | ||
setIdsB.forEach(fn => fn(idA)); | ||
setIdsB.forEach((ref) => (ref.current = idA)); | ||
return idA; | ||
@@ -95,0 +104,0 @@ } |
@@ -16,3 +16,3 @@ /* | ||
// Like useEffect, but only called for updates after the initial render. | ||
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]) { | ||
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): (() => void) | void { | ||
const isInitialMount = useRef(true); | ||
@@ -32,3 +32,3 @@ const lastDeps = useRef<any[] | null>(null); | ||
} else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) { | ||
effect(); | ||
return effect(); | ||
} | ||
@@ -35,0 +35,0 @@ lastDeps.current = dependencies; |
@@ -21,3 +21,2 @@ /* | ||
// @ts-ignore | ||
let visualViewport = typeof document !== 'undefined' && window.visualViewport; | ||
@@ -24,0 +23,0 @@ |
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
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
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
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 6 instances in 1 package
717936
250
8580
8
58
+ Added@react-aria/ssr@3.0.0-nightly-412a51816-250219(transitive)
+ Added@react-stately/flags@3.0.0-nightly-412a51816-250219(transitive)
+ Added@react-stately/utils@3.0.0-nightly-412a51816-250219(transitive)
+ Added@react-types/shared@3.0.0-nightly-412a51816-250219(transitive)
+ Addedreact-dom@19.0.0(transitive)
+ Addedscheduler@0.25.0(transitive)
- Removed@react-aria/ssr@3.9.7(transitive)
- Removed@react-stately/utils@3.10.5(transitive)
- Removed@react-types/shared@3.27.0(transitive)