@react-aria/utils
Advanced tools
Comparing version
@@ -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 |
@@ -36,7 +36,50 @@ | ||
]); | ||
const $8d15d0e1797d4238$var$globalAttrs = new Set([ | ||
'dir', | ||
'lang', | ||
'hidden', | ||
'inert', | ||
'translate' | ||
]); | ||
const $8d15d0e1797d4238$var$globalEvents = new Set([ | ||
'onClick', | ||
'onAuxClick', | ||
'onContextMenu', | ||
'onDoubleClick', | ||
'onMouseDown', | ||
'onMouseEnter', | ||
'onMouseLeave', | ||
'onMouseMove', | ||
'onMouseOut', | ||
'onMouseOver', | ||
'onMouseUp', | ||
'onTouchCancel', | ||
'onTouchEnd', | ||
'onTouchMove', | ||
'onTouchStart', | ||
'onPointerDown', | ||
'onPointerMove', | ||
'onPointerUp', | ||
'onPointerCancel', | ||
'onPointerEnter', | ||
'onPointerLeave', | ||
'onPointerOver', | ||
'onPointerOut', | ||
'onGotPointerCapture', | ||
'onLostPointerCapture', | ||
'onScroll', | ||
'onWheel', | ||
'onAnimationStart', | ||
'onAnimationEnd', | ||
'onAnimationIteration', | ||
'onTransitionCancel', | ||
'onTransitionEnd', | ||
'onTransitionRun', | ||
'onTransitionStart' | ||
]); | ||
const $8d15d0e1797d4238$var$propRe = /^(data-.*)$/; | ||
function $8d15d0e1797d4238$export$457c3d6518dd4c6f(props, opts = {}) { | ||
let { labelable: labelable, isLink: isLink, propNames: propNames } = opts; | ||
let { labelable: labelable, isLink: isLink, global: global, events: events = global, propNames: propNames } = opts; | ||
let filteredProps = {}; | ||
for(const prop in props)if (Object.prototype.hasOwnProperty.call(props, prop) && ($8d15d0e1797d4238$var$DOMPropNames.has(prop) || labelable && $8d15d0e1797d4238$var$labelablePropNames.has(prop) || isLink && $8d15d0e1797d4238$var$linkPropNames.has(prop) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $8d15d0e1797d4238$var$propRe.test(prop))) filteredProps[prop] = props[prop]; | ||
for(const prop in props)if (Object.prototype.hasOwnProperty.call(props, prop) && ($8d15d0e1797d4238$var$DOMPropNames.has(prop) || labelable && $8d15d0e1797d4238$var$labelablePropNames.has(prop) || isLink && $8d15d0e1797d4238$var$linkPropNames.has(prop) || global && $8d15d0e1797d4238$var$globalAttrs.has(prop) || events && $8d15d0e1797d4238$var$globalEvents.has(prop) || prop.endsWith('Capture') && $8d15d0e1797d4238$var$globalEvents.has(prop.slice(0, -7)) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $8d15d0e1797d4238$var$propRe.test(prop))) filteredProps[prop] = props[prop]; | ||
return filteredProps; | ||
@@ -43,0 +86,0 @@ } |
@@ -30,7 +30,50 @@ /* | ||
]); | ||
const $65484d02dcb7eb3e$var$globalAttrs = new Set([ | ||
'dir', | ||
'lang', | ||
'hidden', | ||
'inert', | ||
'translate' | ||
]); | ||
const $65484d02dcb7eb3e$var$globalEvents = new Set([ | ||
'onClick', | ||
'onAuxClick', | ||
'onContextMenu', | ||
'onDoubleClick', | ||
'onMouseDown', | ||
'onMouseEnter', | ||
'onMouseLeave', | ||
'onMouseMove', | ||
'onMouseOut', | ||
'onMouseOver', | ||
'onMouseUp', | ||
'onTouchCancel', | ||
'onTouchEnd', | ||
'onTouchMove', | ||
'onTouchStart', | ||
'onPointerDown', | ||
'onPointerMove', | ||
'onPointerUp', | ||
'onPointerCancel', | ||
'onPointerEnter', | ||
'onPointerLeave', | ||
'onPointerOver', | ||
'onPointerOut', | ||
'onGotPointerCapture', | ||
'onLostPointerCapture', | ||
'onScroll', | ||
'onWheel', | ||
'onAnimationStart', | ||
'onAnimationEnd', | ||
'onAnimationIteration', | ||
'onTransitionCancel', | ||
'onTransitionEnd', | ||
'onTransitionRun', | ||
'onTransitionStart' | ||
]); | ||
const $65484d02dcb7eb3e$var$propRe = /^(data-.*)$/; | ||
function $65484d02dcb7eb3e$export$457c3d6518dd4c6f(props, opts = {}) { | ||
let { labelable: labelable, isLink: isLink, propNames: propNames } = opts; | ||
let { labelable: labelable, isLink: isLink, global: global, events: events = global, propNames: propNames } = opts; | ||
let filteredProps = {}; | ||
for(const prop in props)if (Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || isLink && $65484d02dcb7eb3e$var$linkPropNames.has(prop) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $65484d02dcb7eb3e$var$propRe.test(prop))) filteredProps[prop] = props[prop]; | ||
for(const prop in props)if (Object.prototype.hasOwnProperty.call(props, prop) && ($65484d02dcb7eb3e$var$DOMPropNames.has(prop) || labelable && $65484d02dcb7eb3e$var$labelablePropNames.has(prop) || isLink && $65484d02dcb7eb3e$var$linkPropNames.has(prop) || global && $65484d02dcb7eb3e$var$globalAttrs.has(prop) || events && $65484d02dcb7eb3e$var$globalEvents.has(prop) || prop.endsWith('Capture') && $65484d02dcb7eb3e$var$globalEvents.has(prop.slice(0, -7)) || (propNames === null || propNames === void 0 ? void 0 : propNames.has(prop)) || $65484d02dcb7eb3e$var$propRe.test(prop))) filteredProps[prop] = props[prop]; | ||
return filteredProps; | ||
@@ -37,0 +80,0 @@ } |
@@ -39,3 +39,3 @@ | ||
}); | ||
} catch (e) { | ||
} catch { | ||
// Ignore | ||
@@ -42,0 +42,0 @@ } |
@@ -33,3 +33,3 @@ /* | ||
}); | ||
} catch (e) { | ||
} catch { | ||
// Ignore | ||
@@ -36,0 +36,0 @@ } |
@@ -18,2 +18,3 @@ | ||
*/ function $9a54e9cd5db23b5d$export$2bb74740c4e19def(node, checkForOverflow) { | ||
if (!node) return false; | ||
let style = window.getComputedStyle(node); | ||
@@ -20,0 +21,0 @@ let isScrollable = /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY); |
@@ -12,2 +12,3 @@ /* | ||
*/ function $cc38e7bd3fc7b213$export$2bb74740c4e19def(node, checkForOverflow) { | ||
if (!node) return false; | ||
let style = window.getComputedStyle(node); | ||
@@ -14,0 +15,0 @@ let isScrollable = /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY); |
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,8 @@ var $37733e1652f47193$exports = require("./useResizeObserver.main.js"); | ||
var $faa6ccd6fb62f877$exports = require("./useLoadMore.main.js"); | ||
var $f6a4874a7c582761$exports = require("./useLoadMoreSentinel.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 +55,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); | ||
@@ -61,2 +76,3 @@ $parcel$export(module.exports, "mergeRefs", () => $f05dc24eafaeb7e2$exports.mergeRefs); | ||
$parcel$export(module.exports, "useLinkProps", () => $4068a0fae83b6d84$exports.useLinkProps); | ||
$parcel$export(module.exports, "handleLinkClick", () => $4068a0fae83b6d84$exports.handleLinkClick); | ||
$parcel$export(module.exports, "runAfterTransition", () => $e8117ebcab55be6a$exports.runAfterTransition); | ||
@@ -68,2 +84,3 @@ $parcel$export(module.exports, "useDrag1D", () => $28ed3fb20343b78b$exports.useDrag1D); | ||
$parcel$export(module.exports, "useUpdateEffect", () => $29293a6f5c75b37e$exports.useUpdateEffect); | ||
$parcel$export(module.exports, "useUpdateLayoutEffect", () => $0fa310503218f75f$exports.useUpdateLayoutEffect); | ||
$parcel$export(module.exports, "useLayoutEffect", () => $78605a5d7424e31b$exports.useLayoutEffect); | ||
@@ -98,2 +115,11 @@ $parcel$export(module.exports, "useResizeObserver", () => $37733e1652f47193$exports.useResizeObserver); | ||
$parcel$export(module.exports, "useLoadMore", () => $faa6ccd6fb62f877$exports.useLoadMore); | ||
$parcel$export(module.exports, "UNSTABLE_useLoadMoreSentinel", () => $f6a4874a7c582761$exports.UNSTABLE_useLoadMoreSentinel); | ||
$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, "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); | ||
/* | ||
@@ -144,2 +170,11 @@ * Copyright 2020 Adobe. All rights reserved. | ||
//# sourceMappingURL=main.js.map |
@@ -20,10 +20,22 @@ | ||
return (value)=>{ | ||
for (let ref of refs){ | ||
if (typeof ref === 'function') ref(value); | ||
else if (ref != null) ref.current = value; | ||
} | ||
let hasCleanup = false; | ||
const cleanups = refs.map((ref)=>{ | ||
const cleanup = $f05dc24eafaeb7e2$var$setRef(ref, value); | ||
hasCleanup || (hasCleanup = typeof cleanup == 'function'); | ||
return cleanup; | ||
}); | ||
if (hasCleanup) return ()=>{ | ||
cleanups.forEach((cleanup, i)=>{ | ||
if (typeof cleanup === 'function') cleanup(); | ||
else $f05dc24eafaeb7e2$var$setRef(refs[i], null); | ||
}); | ||
}; | ||
}; | ||
} | ||
function $f05dc24eafaeb7e2$var$setRef(ref, value) { | ||
if (typeof ref === 'function') return ref(value); | ||
else if (ref != null) ref.current = value; | ||
} | ||
//# sourceMappingURL=mergeRefs.main.js.map |
@@ -14,8 +14,20 @@ /* | ||
return (value)=>{ | ||
for (let ref of refs){ | ||
if (typeof ref === 'function') ref(value); | ||
else if (ref != null) ref.current = value; | ||
} | ||
let hasCleanup = false; | ||
const cleanups = refs.map((ref)=>{ | ||
const cleanup = $5dc95899b306f630$var$setRef(ref, value); | ||
hasCleanup || (hasCleanup = typeof cleanup == 'function'); | ||
return cleanup; | ||
}); | ||
if (hasCleanup) return ()=>{ | ||
cleanups.forEach((cleanup, i)=>{ | ||
if (typeof cleanup === 'function') cleanup(); | ||
else $5dc95899b306f630$var$setRef(refs[i], null); | ||
}); | ||
}; | ||
}; | ||
} | ||
function $5dc95899b306f630$var$setRef(ref, value) { | ||
if (typeof ref === 'function') return ref(value); | ||
else if (ref != null) ref.current = value; | ||
} | ||
@@ -22,0 +34,0 @@ |
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"; | ||
@@ -9,3 +11,3 @@ import {mergeRefs as $5dc95899b306f630$export$c9058316764c140e} from "./mergeRefs.module.js"; | ||
import {getOffset as $ab71dadb03a6fb2e$export$622cea445a1c5b7d} from "./getOffset.module.js"; | ||
import {getSyntheticLinkProps as $ea8dcbcb9ea1b556$export$51437d503373d223, openLink as $ea8dcbcb9ea1b556$export$95185d699e05d4d7, RouterProvider as $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb, shouldClientNavigate as $ea8dcbcb9ea1b556$export$efa8c9099e530235, useLinkProps as $ea8dcbcb9ea1b556$export$7e924b3091a3bd18, useRouter as $ea8dcbcb9ea1b556$export$9a302a45f65d0572, useSyntheticLinkProps as $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6} from "./openLink.module.js"; | ||
import {getSyntheticLinkProps as $ea8dcbcb9ea1b556$export$51437d503373d223, handleLinkClick as $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f, openLink as $ea8dcbcb9ea1b556$export$95185d699e05d4d7, RouterProvider as $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb, shouldClientNavigate as $ea8dcbcb9ea1b556$export$efa8c9099e530235, useLinkProps as $ea8dcbcb9ea1b556$export$7e924b3091a3bd18, useRouter as $ea8dcbcb9ea1b556$export$9a302a45f65d0572, useSyntheticLinkProps as $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6} from "./openLink.module.js"; | ||
import {runAfterTransition as $bbed8b41f857bcc0$export$24490316f764c430} from "./runAfterTransition.module.js"; | ||
@@ -17,2 +19,3 @@ import {useDrag1D as $9cc09df9fd7676be$export$7bbed75feba39706} from "./useDrag1D.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"; | ||
@@ -35,2 +38,8 @@ import {useResizeObserver as $9daab02d461809db$export$683480f191c0e3ea} from "./useResizeObserver.module.js"; | ||
import {useLoadMore as $26f7f3da73fcd9d6$export$7717c92ee915373e} from "./useLoadMore.module.js"; | ||
import {UNSTABLE_useLoadMoreSentinel as $a5fa973c1850dd36$export$90a12e6abf95cbe0} from "./useLoadMoreSentinel.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} 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"; | ||
@@ -83,3 +92,12 @@ | ||
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, $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f as handleLinkClick, $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, $a5fa973c1850dd36$export$90a12e6abf95cbe0 as UNSTABLE_useLoadMoreSentinel, $cdc5a6778b766db2$export$a9d04c5684123369 as inertValue, $5671b20cf9b562b2$export$447a38995de2c711 as CLEAR_FOCUS_EVENT, $5671b20cf9b562b2$export$831c820ad60f9d12 as FOCUS_EVENT, $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 |
@@ -21,2 +21,3 @@ var $1117b6c0d4c4c164$exports = require("./focusWithoutScrolling.main.js"); | ||
$parcel$export(module.exports, "useLinkProps", () => $4068a0fae83b6d84$export$7e924b3091a3bd18); | ||
$parcel$export(module.exports, "handleLinkClick", () => $4068a0fae83b6d84$export$13aea1a3cb5e3f1f); | ||
/* | ||
@@ -83,3 +84,3 @@ * Copyright 2023 Adobe. All rights reserved. | ||
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184 | ||
let event = (0, $9e20cff0af27e8cc$exports.isWebKit)() && (0, $9e20cff0af27e8cc$exports.isMac)() && !(0, $9e20cff0af27e8cc$exports.isIPad)() && true ? new KeyboardEvent('keydown', { | ||
let event = (0, $9e20cff0af27e8cc$exports.isWebKit)() && (0, $9e20cff0af27e8cc$exports.isMac)() && !(0, $9e20cff0af27e8cc$exports.isIPad)() && process.env.NODE_ENV !== 'test' ? new KeyboardEvent('keydown', { | ||
keyIdentifier: 'Enter', | ||
@@ -159,4 +160,12 @@ metaKey: metaKey, | ||
} | ||
function $4068a0fae83b6d84$export$13aea1a3cb5e3f1f(e, router, href, routerOptions) { | ||
// If a custom router is provided, prevent default and forward if this link should client navigate. | ||
if (!router.isNative && e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.href && // If props are applied to a router Link component, it may have already prevented default. | ||
!e.isDefaultPrevented() && $4068a0fae83b6d84$export$efa8c9099e530235(e.currentTarget, e) && href) { | ||
e.preventDefault(); | ||
router.open(e.currentTarget, e, href, routerOptions); | ||
} | ||
} | ||
//# sourceMappingURL=openLink.main.js.map |
@@ -66,3 +66,3 @@ import {focusWithoutScrolling as $7215afc6de606d6b$export$de79e2c695e052f3} from "./focusWithoutScrolling.module.js"; | ||
// https://github.com/WebKit/WebKit/blob/c03d0ac6e6db178f90923a0a63080b5ca210d25f/Source/WebCore/html/HTMLAnchorElement.cpp#L184 | ||
let event = (0, $c87311424ea30a05$export$78551043582a6a98)() && (0, $c87311424ea30a05$export$9ac100e40613ea10)() && !(0, $c87311424ea30a05$export$7bef049ce92e4224)() && true ? new KeyboardEvent('keydown', { | ||
let event = (0, $c87311424ea30a05$export$78551043582a6a98)() && (0, $c87311424ea30a05$export$9ac100e40613ea10)() && !(0, $c87311424ea30a05$export$7bef049ce92e4224)() && process.env.NODE_ENV !== 'test' ? new KeyboardEvent('keydown', { | ||
keyIdentifier: 'Enter', | ||
@@ -142,5 +142,13 @@ metaKey: metaKey, | ||
} | ||
function $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f(e, router, href, routerOptions) { | ||
// If a custom router is provided, prevent default and forward if this link should client navigate. | ||
if (!router.isNative && e.currentTarget instanceof HTMLAnchorElement && e.currentTarget.href && // If props are applied to a router Link component, it may have already prevented default. | ||
!e.isDefaultPrevented() && $ea8dcbcb9ea1b556$export$efa8c9099e530235(e.currentTarget, e) && href) { | ||
e.preventDefault(); | ||
router.open(e.currentTarget, e, href, routerOptions); | ||
} | ||
} | ||
export {$ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps}; | ||
export {$ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $ea8dcbcb9ea1b556$export$13aea1a3cb5e3f1f as handleLinkClick}; | ||
//# sourceMappingURL=openLink.module.js.map |
@@ -28,3 +28,4 @@ | ||
if (typeof window === 'undefined' || window.navigator == null) return false; | ||
return ((_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands.some((brand)=>re.test(brand.brand))) || re.test(window.navigator.userAgent); | ||
let brands = (_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands; | ||
return Array.isArray(brands) && brands.some((brand)=>re.test(brand.brand)) || re.test(window.navigator.userAgent); | ||
} | ||
@@ -36,2 +37,3 @@ function $9e20cff0af27e8cc$var$testPlatform(re) { | ||
function $9e20cff0af27e8cc$var$cached(fn) { | ||
if (process.env.NODE_ENV === 'test') return fn; | ||
let res = null; | ||
@@ -38,0 +40,0 @@ return ()=>{ |
@@ -14,3 +14,4 @@ /* | ||
if (typeof window === 'undefined' || window.navigator == null) return false; | ||
return ((_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands.some((brand)=>re.test(brand.brand))) || re.test(window.navigator.userAgent); | ||
let brands = (_window_navigator_userAgentData = window.navigator['userAgentData']) === null || _window_navigator_userAgentData === void 0 ? void 0 : _window_navigator_userAgentData.brands; | ||
return Array.isArray(brands) && brands.some((brand)=>re.test(brand.brand)) || re.test(window.navigator.userAgent); | ||
} | ||
@@ -22,2 +23,3 @@ function $c87311424ea30a05$var$testPlatform(re) { | ||
function $c87311424ea30a05$var$cached(fn) { | ||
if (process.env.NODE_ENV === 'test') return fn; | ||
let res = null; | ||
@@ -24,0 +26,0 @@ return ()=>{ |
@@ -71,5 +71,15 @@ | ||
} | ||
/** | ||
* Cleans up any elements that are no longer in the document. | ||
* This is necessary because we can't rely on transitionend events to fire | ||
* for elements that are removed from the document while transitioning. | ||
*/ function $e8117ebcab55be6a$var$cleanupDetachedElements() { | ||
for (const [eventTarget] of $e8117ebcab55be6a$var$transitionsByElement)// Similar to `eventTarget instanceof Element && !eventTarget.isConnected`, but avoids | ||
// the explicit instanceof check, since it may be different in different contexts. | ||
if ('isConnected' in eventTarget && !eventTarget.isConnected) $e8117ebcab55be6a$var$transitionsByElement.delete(eventTarget); | ||
} | ||
function $e8117ebcab55be6a$export$24490316f764c430(fn) { | ||
// Wait one frame to see if an animation starts, e.g. a transition on mount. | ||
requestAnimationFrame(()=>{ | ||
$e8117ebcab55be6a$var$cleanupDetachedElements(); | ||
// If no transitions are running, call the function immediately. | ||
@@ -76,0 +86,0 @@ // Otherwise, add it to a list of callbacks to run at the end of the animation. |
@@ -65,5 +65,15 @@ /* | ||
} | ||
/** | ||
* Cleans up any elements that are no longer in the document. | ||
* This is necessary because we can't rely on transitionend events to fire | ||
* for elements that are removed from the document while transitioning. | ||
*/ function $bbed8b41f857bcc0$var$cleanupDetachedElements() { | ||
for (const [eventTarget] of $bbed8b41f857bcc0$var$transitionsByElement)// Similar to `eventTarget instanceof Element && !eventTarget.isConnected`, but avoids | ||
// the explicit instanceof check, since it may be different in different contexts. | ||
if ('isConnected' in eventTarget && !eventTarget.isConnected) $bbed8b41f857bcc0$var$transitionsByElement.delete(eventTarget); | ||
} | ||
function $bbed8b41f857bcc0$export$24490316f764c430(fn) { | ||
// Wait one frame to see if an animation starts, e.g. a transition on mount. | ||
requestAnimationFrame(()=>{ | ||
$bbed8b41f857bcc0$var$cleanupDetachedElements(); | ||
// If no transitions are running, call the function immediately. | ||
@@ -70,0 +80,0 @@ // Otherwise, add it to a list of callbacks to run at the end of the animation. |
@@ -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; | ||
@@ -64,3 +70,3 @@ scrollView.scrollTop = y; | ||
function $449412113267a1fe$export$c826860796309d1b(targetElement, opts) { | ||
if (document.contains(targetElement)) { | ||
if (targetElement && document.contains(targetElement)) { | ||
let root = document.scrollingElement || document.documentElement; | ||
@@ -67,0 +73,0 @@ let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden'; |
@@ -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; | ||
@@ -57,3 +63,3 @@ scrollView.scrollTop = y; | ||
function $2f04cbc44ee30ce0$export$c826860796309d1b(targetElement, opts) { | ||
if (document.contains(targetElement)) { | ||
if (targetElement && document.contains(targetElement)) { | ||
let root = document.scrollingElement || document.documentElement; | ||
@@ -60,0 +66,0 @@ let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden'; |
@@ -1,3 +0,3 @@ | ||
import React, { ForwardedRef, MutableRefObject, ReactNode, HTMLAttributes, EffectCallback, Dispatch, RefObject as _RefObject1 } from "react"; | ||
import { AriaLabelingProps, DOMProps, LinkDOMProps, FocusableElement, Href, RouterOptions, Orientation, RefObject } from "@react-types/shared"; | ||
import React, { MutableRefObject, Ref, DOMAttributes, JSX, MouseEvent, ReactNode, HTMLAttributes, EffectCallback, Dispatch, RefObject as _RefObject1 } from "react"; | ||
import { AriaLabelingProps, DOMProps, GlobalDOMAttributes, LinkDOMProps, FocusableElement, Orientation, Href, RouterOptions, RefObject, AsyncLoadable, Collection } from "@react-types/shared"; | ||
export const useLayoutEffect: typeof React.useLayoutEffect; | ||
@@ -26,2 +26,48 @@ /** | ||
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<T extends Event>(event: T): 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 { | ||
@@ -49,3 +95,3 @@ [key: string]: any; | ||
*/ | ||
export function mergeRefs<T>(...refs: Array<ForwardedRef<T> | MutableRefObject<T> | null | undefined>): ForwardedRef<T>; | ||
export function mergeRefs<T>(...refs: Array<Ref<T> | MutableRefObject<T> | null | undefined>): Ref<T>; | ||
interface Options { | ||
@@ -58,2 +104,6 @@ /** | ||
isLink?: boolean; | ||
/** Whether to include global DOM attributes. */ | ||
global?: boolean; | ||
/** Whether to include DOM events. */ | ||
events?: boolean; | ||
/** | ||
@@ -69,5 +119,5 @@ * A Set of other property names that should be included in the filter. | ||
*/ | ||
export function filterDOMProps(props: DOMProps & AriaLabelingProps & LinkDOMProps, opts?: Options): DOMProps & AriaLabelingProps; | ||
export function filterDOMProps(props: DOMProps & AriaLabelingProps & LinkDOMProps & GlobalDOMAttributes, opts?: Options): DOMProps & AriaLabelingProps & GlobalDOMAttributes; | ||
export function focusWithoutScrolling(element: FocusableElement): void; | ||
export function getOffset(element: any, reverse: any, orientation?: string): any; | ||
export function getOffset(element: HTMLElement, reverse?: boolean, orientation?: Orientation): number; | ||
export const isMac: () => boolean; | ||
@@ -96,3 +146,3 @@ export const isIPhone: () => boolean; | ||
*/ | ||
export function RouterProvider(props: RouterProviderProps): React.JSX.Element; | ||
export function RouterProvider(props: RouterProviderProps): JSX.Element; | ||
export function useRouter(): Router; | ||
@@ -107,27 +157,7 @@ interface Modifiers { | ||
export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening?: boolean): void; | ||
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; | ||
}; | ||
export function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement>; | ||
/** @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; | ||
}; | ||
export function useLinkProps(props: LinkDOMProps): { | ||
href: string; | ||
target: React.HTMLAttributeAnchorTarget; | ||
rel: string; | ||
download: string | boolean; | ||
ping: string; | ||
referrerPolicy: React.HTMLAttributeReferrerPolicy; | ||
}; | ||
export function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement>; | ||
export function useLinkProps(props?: LinkDOMProps): LinkDOMProps; | ||
export function handleLinkClick(e: MouseEvent, router: Router, href: Href | undefined, routerOptions: RouterOptions | undefined): void; | ||
export function runAfterTransition(fn: () => void): void; | ||
@@ -149,2 +179,3 @@ interface UseDrag1DProps { | ||
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; | ||
@@ -168,8 +199,9 @@ addGlobalListener(el: EventTarget, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; | ||
* | ||
* @param forwardedRef The original ref intended to be used. | ||
* @param ref The original ref intended to be used. | ||
* @returns An object ref that updates the given ref. | ||
* @see https://reactjs.org/docs/forwarding-refs.html | ||
* @see https://react.dev/reference/react/forwardRef | ||
*/ | ||
export function useObjectRef<T>(forwardedRef?: ((instance: T | null) => void) | MutableRefObject<T | null> | null): MutableRefObject<T | null>; | ||
export function useObjectRef<T>(ref?: ((instance: T | null) => (() => void) | void) | MutableRefObject<T | null> | null): MutableRefObject<T | null>; | ||
export function useUpdateEffect(effect: EffectCallback, dependencies: any[]): void; | ||
export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void; | ||
type useResizeObserverOptionsType<T> = { | ||
@@ -185,3 +217,3 @@ ref: RefObject<T | undefined | null> | undefined; | ||
export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void; | ||
export function isScrollable(node: Element, checkForOverflow?: boolean): boolean; | ||
export function isScrollable(node: Element | null, checkForOverflow?: boolean): boolean; | ||
export function getScrollParent(node: Element, checkForOverflow?: boolean): Element; | ||
@@ -201,3 +233,3 @@ export function getScrollParents(node: Element, checkForOverflow?: boolean): Element[]; | ||
/** The optional containing element of the target to be centered in the viewport. */ | ||
containingElement?: Element; | ||
containingElement?: Element | null; | ||
} | ||
@@ -215,7 +247,7 @@ /** | ||
*/ | ||
export function scrollIntoViewport(targetElement: Element, opts?: ScrollIntoViewportOpts): void; | ||
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts): void; | ||
export function isVirtualClick(event: MouseEvent | PointerEvent): boolean; | ||
export function isVirtualPointerEvent(event: PointerEvent): boolean; | ||
export function useDeepMemo<T>(value: T, isEqual: (a: T, b: T) => boolean): T; | ||
export function useFormReset<T>(ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null>, initialValue: T, onReset: (value: T) => void): void; | ||
export function useFormReset<T>(ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined, initialValue: T, onReset: (value: T) => void): void; | ||
interface LoadMoreProps { | ||
@@ -238,4 +270,29 @@ /** Whether data is currently being loaded. */ | ||
export function useLoadMore(props: LoadMoreProps, ref: _RefObject1<HTMLElement | null>): void; | ||
export interface LoadMoreSentinelProps extends Omit<AsyncLoadable, 'isLoading'> { | ||
collection: Collection<any>; | ||
/** | ||
* The amount of offset from the bottom of your scrollable region that should trigger load more. | ||
* Uses a percentage value relative to the scroll body's client height. Load more is then triggered | ||
* when your current scroll position's distance from the bottom of the currently loaded list of items is less than | ||
* or equal to the provided value. (e.g. 1 = 100% of the scroll region's height). | ||
* @default 1 | ||
*/ | ||
scrollOffset?: number; | ||
} | ||
export function UNSTABLE_useLoadMoreSentinel(props: LoadMoreSentinelProps, ref: _RefObject1<HTMLElement | null>): void; | ||
export function inertValue(value?: boolean): string | boolean | undefined; | ||
export const CLEAR_FOCUS_EVENT = "react-aria-clear-focus"; | ||
export const FOCUS_EVENT = "react-aria-focus"; | ||
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 |
@@ -5,2 +5,6 @@ var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js"); | ||
function $parcel$interopDefault(a) { | ||
return a && a.__esModule ? a.default : a; | ||
} | ||
function $parcel$export(e, n, v, s) { | ||
@@ -23,5 +27,9 @@ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true}); | ||
var $1254e5bb94ac8761$var$_React_useInsertionEffect; | ||
// Use the earliest effect type possible. useInsertionEffect runs during the mutation phase, | ||
// before all layout effects, but is available only in React 18 and later. | ||
const $1254e5bb94ac8761$var$useEarlyEffect = ($1254e5bb94ac8761$var$_React_useInsertionEffect = (0, ($parcel$interopDefault($gErir$react)))['useInsertionEffect']) !== null && $1254e5bb94ac8761$var$_React_useInsertionEffect !== void 0 ? $1254e5bb94ac8761$var$_React_useInsertionEffect : (0, $78605a5d7424e31b$exports.useLayoutEffect); | ||
function $1254e5bb94ac8761$export$7f54fc3180508a52(fn) { | ||
const ref = (0, $gErir$react.useRef)(null); | ||
(0, $78605a5d7424e31b$exports.useLayoutEffect)(()=>{ | ||
$1254e5bb94ac8761$var$useEarlyEffect(()=>{ | ||
ref.current = fn; | ||
@@ -28,0 +36,0 @@ }, [ |
import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js"; | ||
import {useRef as $lmaYr$useRef, useCallback as $lmaYr$useCallback} from "react"; | ||
import $lmaYr$react, {useRef as $lmaYr$useRef, useCallback as $lmaYr$useCallback} from "react"; | ||
@@ -16,5 +16,9 @@ /* | ||
var $8ae05eaa5c114e9c$var$_React_useInsertionEffect; | ||
// Use the earliest effect type possible. useInsertionEffect runs during the mutation phase, | ||
// before all layout effects, but is available only in React 18 and later. | ||
const $8ae05eaa5c114e9c$var$useEarlyEffect = ($8ae05eaa5c114e9c$var$_React_useInsertionEffect = (0, $lmaYr$react)['useInsertionEffect']) !== null && $8ae05eaa5c114e9c$var$_React_useInsertionEffect !== void 0 ? $8ae05eaa5c114e9c$var$_React_useInsertionEffect : (0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c); | ||
function $8ae05eaa5c114e9c$export$7f54fc3180508a52(fn) { | ||
const ref = (0, $lmaYr$useRef)(null); | ||
(0, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c)(()=>{ | ||
$8ae05eaa5c114e9c$var$useEarlyEffect(()=>{ | ||
ref.current = fn; | ||
@@ -21,0 +25,0 @@ }, [ |
@@ -23,5 +23,4 @@ var $1254e5bb94ac8761$exports = require("./useEffectEvent.main.js"); | ||
function $1f205e845604a423$export$5add1d006293d136(ref, initialValue, onReset) { | ||
let resetValue = (0, $81vbz$react.useRef)(initialValue); | ||
let handleReset = (0, $1254e5bb94ac8761$exports.useEffectEvent)(()=>{ | ||
if (onReset) onReset(resetValue.current); | ||
if (onReset) onReset(initialValue); | ||
}); | ||
@@ -28,0 +27,0 @@ (0, $81vbz$react.useEffect)(()=>{ |
import {useEffectEvent as $8ae05eaa5c114e9c$export$7f54fc3180508a52} from "./useEffectEvent.module.js"; | ||
import {useRef as $8rM3G$useRef, useEffect as $8rM3G$useEffect} from "react"; | ||
import {useEffect as $8rM3G$useEffect} from "react"; | ||
@@ -17,5 +17,4 @@ /* | ||
function $99facab73266f662$export$5add1d006293d136(ref, initialValue, onReset) { | ||
let resetValue = (0, $8rM3G$useRef)(initialValue); | ||
let handleReset = (0, $8ae05eaa5c114e9c$export$7f54fc3180508a52)(()=>{ | ||
if (onReset) onReset(resetValue.current); | ||
if (onReset) onReset(initialValue); | ||
}); | ||
@@ -22,0 +21,0 @@ (0, $8rM3G$useEffect)(()=>{ |
@@ -34,3 +34,3 @@ var $eHdSW$react = require("react"); | ||
}); | ||
eventTarget.addEventListener(type, listener, options); | ||
eventTarget.addEventListener(type, fn, options); | ||
}, []); | ||
@@ -50,3 +50,2 @@ let removeGlobalListener = (0, $eHdSW$react.useCallback)((eventTarget, type, listener, options)=>{ | ||
]); | ||
// eslint-disable-next-line arrow-body-style | ||
(0, $eHdSW$react.useEffect)(()=>{ | ||
@@ -53,0 +52,0 @@ return removeAllGlobalListeners; |
@@ -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); | ||
}, []); | ||
@@ -44,3 +44,2 @@ let removeGlobalListener = (0, $lPAwt$useCallback)((eventTarget, type, listener, options)=>{ | ||
]); | ||
// eslint-disable-next-line arrow-body-style | ||
(0, $lPAwt$useEffect)(()=>{ | ||
@@ -47,0 +46,0 @@ return removeAllGlobalListeners; |
@@ -30,3 +30,10 @@ 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; | ||
if (typeof FinalizationRegistry !== 'undefined') $8c61827343eed941$var$registry = new FinalizationRegistry((heldValue)=>{ | ||
$8c61827343eed941$export$d41a04c74483c6ef.delete(heldValue); | ||
}); | ||
function $8c61827343eed941$export$f680877a34711e37(defaultId) { | ||
@@ -36,14 +43,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); | ||
if ($8c61827343eed941$var$registry) $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 +56,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. | ||
if ($8c61827343eed941$var$registry) $8c61827343eed941$var$registry.unregister(cleanupRef); | ||
$8c61827343eed941$export$d41a04c74483c6ef.delete(r); | ||
}; | ||
@@ -59,10 +65,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 +79,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 +89,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,10 @@ | ||
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; | ||
if (typeof FinalizationRegistry !== 'undefined') $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{ | ||
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue); | ||
}); | ||
function $bdb11010cef70236$export$f680877a34711e37(defaultId) { | ||
@@ -28,14 +35,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); | ||
if ($bdb11010cef70236$var$registry) $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 +48,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. | ||
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.unregister(cleanupRef); | ||
$bdb11010cef70236$export$d41a04c74483c6ef.delete(r); | ||
}; | ||
@@ -51,10 +57,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 +71,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 +105,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 |
@@ -20,4 +20,22 @@ var $eMoU1$react = require("react"); | ||
*/ | ||
function $475b35fe72ba49b3$export$4338b53315abf666(forwardedRef) { | ||
function $475b35fe72ba49b3$export$4338b53315abf666(ref) { | ||
const objRef = (0, $eMoU1$react.useRef)(null); | ||
const cleanupRef = (0, $eMoU1$react.useRef)(undefined); | ||
const refEffect = (0, $eMoU1$react.useCallback)((instance)=>{ | ||
if (typeof ref === 'function') { | ||
const refCallback = ref; | ||
const refCleanup = refCallback(instance); | ||
return ()=>{ | ||
if (typeof refCleanup === 'function') refCleanup(); | ||
else refCallback(null); | ||
}; | ||
} else if (ref) { | ||
ref.current = instance; | ||
return ()=>{ | ||
ref.current = null; | ||
}; | ||
} | ||
}, [ | ||
ref | ||
]); | ||
return (0, $eMoU1$react.useMemo)(()=>({ | ||
@@ -29,7 +47,10 @@ get current () { | ||
objRef.current = value; | ||
if (typeof forwardedRef === 'function') forwardedRef(value); | ||
else if (forwardedRef) forwardedRef.current = value; | ||
if (cleanupRef.current) { | ||
cleanupRef.current(); | ||
cleanupRef.current = undefined; | ||
} | ||
if (value != null) cleanupRef.current = refEffect(value); | ||
} | ||
}), [ | ||
forwardedRef | ||
refEffect | ||
]); | ||
@@ -36,0 +57,0 @@ } |
@@ -1,2 +0,2 @@ | ||
import {useRef as $gbmns$useRef, useMemo as $gbmns$useMemo} from "react"; | ||
import {useRef as $gbmns$useRef, useCallback as $gbmns$useCallback, useMemo as $gbmns$useMemo} from "react"; | ||
@@ -14,4 +14,22 @@ /* | ||
*/ | ||
function $df56164dff5785e2$export$4338b53315abf666(forwardedRef) { | ||
function $df56164dff5785e2$export$4338b53315abf666(ref) { | ||
const objRef = (0, $gbmns$useRef)(null); | ||
const cleanupRef = (0, $gbmns$useRef)(undefined); | ||
const refEffect = (0, $gbmns$useCallback)((instance)=>{ | ||
if (typeof ref === 'function') { | ||
const refCallback = ref; | ||
const refCleanup = refCallback(instance); | ||
return ()=>{ | ||
if (typeof refCleanup === 'function') refCleanup(); | ||
else refCallback(null); | ||
}; | ||
} else if (ref) { | ||
ref.current = instance; | ||
return ()=>{ | ||
ref.current = null; | ||
}; | ||
} | ||
}, [ | ||
ref | ||
]); | ||
return (0, $gbmns$useMemo)(()=>({ | ||
@@ -23,7 +41,10 @@ get current () { | ||
objRef.current = value; | ||
if (typeof forwardedRef === 'function') forwardedRef(value); | ||
else if (forwardedRef) forwardedRef.current = value; | ||
if (cleanupRef.current) { | ||
cleanupRef.current(); | ||
cleanupRef.current = undefined; | ||
} | ||
if (value != null) cleanupRef.current = refEffect(value); | ||
} | ||
}), [ | ||
forwardedRef | ||
refEffect | ||
]); | ||
@@ -30,0 +51,0 @@ } |
@@ -30,4 +30,5 @@ var $cagC1$react = require("react"); | ||
(0, $cagC1$react.useEffect)(()=>{ | ||
let prevDeps = lastDeps.current; | ||
if (isInitialMount.current) isInitialMount.current = false; | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect(); | ||
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i]))) effect(); | ||
lastDeps.current = dependencies; | ||
@@ -34,0 +35,0 @@ // eslint-disable-next-line react-hooks/exhaustive-deps |
@@ -24,4 +24,5 @@ import {useRef as $9vW05$useRef, useEffect as $9vW05$useEffect} from "react"; | ||
(0, $9vW05$useEffect)(()=>{ | ||
let prevDeps = lastDeps.current; | ||
if (isInitialMount.current) isInitialMount.current = false; | ||
else if (!lastDeps.current || dependencies.some((dep, i)=>!Object.is(dep, lastDeps[i]))) effect(); | ||
else if (!prevDeps || dependencies.some((dep, i)=>!Object.is(dep, prevDeps[i]))) effect(); | ||
lastDeps.current = dependencies; | ||
@@ -28,0 +29,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-e60fb427c-240930", | ||
"version": "3.0.0-nightly-e67726023-250709", | ||
"description": "Spectrum UI components in React", | ||
@@ -9,3 +9,7 @@ "license": "Apache-2.0", | ||
"exports": { | ||
"types": "./dist/types.d.ts", | ||
"source": "./src/index.ts", | ||
"types": [ | ||
"./dist/types.d.ts", | ||
"./src/index.ts" | ||
], | ||
"import": "./dist/import.mjs", | ||
@@ -26,5 +30,6 @@ "require": "./dist/main.js" | ||
"dependencies": { | ||
"@react-aria/ssr": "^3.0.0-nightly-e60fb427c-240930", | ||
"@react-stately/utils": "^3.0.0-nightly-e60fb427c-240930", | ||
"@react-types/shared": "^3.0.0-nightly-e60fb427c-240930", | ||
"@react-aria/ssr": "3.0.0-nightly-e67726023-250709", | ||
"@react-stately/flags": "3.0.0-nightly-e67726023-250709", | ||
"@react-stately/utils": "3.0.0-nightly-e67726023-250709", | ||
"@react-types/shared": "3.0.0-nightly-e67726023-250709", | ||
"@swc/helpers": "^0.5.0", | ||
@@ -34,8 +39,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.2" | ||
} | ||
} |
@@ -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; | ||
} |
@@ -13,3 +13,3 @@ /* | ||
import {AriaLabelingProps, DOMProps, LinkDOMProps} from '@react-types/shared'; | ||
import {AriaLabelingProps, DOMProps, GlobalDOMAttributes, LinkDOMProps} from '@react-types/shared'; | ||
@@ -38,2 +38,47 @@ const DOMPropNames = new Set([ | ||
const globalAttrs = new Set([ | ||
'dir', | ||
'lang', | ||
'hidden', | ||
'inert', | ||
'translate' | ||
]); | ||
const globalEvents = new Set([ | ||
'onClick', | ||
'onAuxClick', | ||
'onContextMenu', | ||
'onDoubleClick', | ||
'onMouseDown', | ||
'onMouseEnter', | ||
'onMouseLeave', | ||
'onMouseMove', | ||
'onMouseOut', | ||
'onMouseOver', | ||
'onMouseUp', | ||
'onTouchCancel', | ||
'onTouchEnd', | ||
'onTouchMove', | ||
'onTouchStart', | ||
'onPointerDown', | ||
'onPointerMove', | ||
'onPointerUp', | ||
'onPointerCancel', | ||
'onPointerEnter', | ||
'onPointerLeave', | ||
'onPointerOver', | ||
'onPointerOut', | ||
'onGotPointerCapture', | ||
'onLostPointerCapture', | ||
'onScroll', | ||
'onWheel', | ||
'onAnimationStart', | ||
'onAnimationEnd', | ||
'onAnimationIteration', | ||
'onTransitionCancel', | ||
'onTransitionEnd', | ||
'onTransitionRun', | ||
'onTransitionStart' | ||
]); | ||
interface Options { | ||
@@ -46,2 +91,6 @@ /** | ||
isLink?: boolean, | ||
/** Whether to include global DOM attributes. */ | ||
global?: boolean, | ||
/** Whether to include DOM events. */ | ||
events?: boolean, | ||
/** | ||
@@ -60,4 +109,4 @@ * A Set of other property names that should be included in the filter. | ||
*/ | ||
export function filterDOMProps(props: DOMProps & AriaLabelingProps & LinkDOMProps, opts: Options = {}): DOMProps & AriaLabelingProps { | ||
let {labelable, isLink, propNames} = opts; | ||
export function filterDOMProps(props: DOMProps & AriaLabelingProps & LinkDOMProps & GlobalDOMAttributes, opts: Options = {}): DOMProps & AriaLabelingProps & GlobalDOMAttributes { | ||
let {labelable, isLink, global, events = global, propNames} = opts; | ||
let filteredProps = {}; | ||
@@ -71,2 +120,4 @@ | ||
(isLink && linkPropNames.has(prop)) || | ||
(global && globalAttrs.has(prop)) || | ||
(events && globalEvents.has(prop) || (prop.endsWith('Capture') && globalEvents.has(prop.slice(0, -7)))) || | ||
propNames?.has(prop) || | ||
@@ -73,0 +124,0 @@ propRe.test(prop) |
@@ -31,3 +31,3 @@ /* | ||
export function focusWithoutScrolling(element: FocusableElement) { | ||
export function focusWithoutScrolling(element: FocusableElement): void { | ||
if (supportsPreventScroll()) { | ||
@@ -54,3 +54,3 @@ element.focus({preventScroll: true}); | ||
}); | ||
} catch (e) { | ||
} catch { | ||
// Ignore | ||
@@ -57,0 +57,0 @@ } |
@@ -13,3 +13,5 @@ /* | ||
export function getOffset(element, reverse, orientation = 'horizontal') { | ||
import {Orientation} from '@react-types/shared'; | ||
export function getOffset(element: HTMLElement, reverse?: boolean, orientation: Orientation = 'horizontal'): number { | ||
let rect = element.getBoundingClientRect(); | ||
@@ -16,0 +18,0 @@ if (reverse) { |
@@ -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'; | ||
@@ -21,3 +23,3 @@ export {mergeRefs} from './mergeRefs'; | ||
export {getOffset} from './getOffset'; | ||
export {openLink, getSyntheticLinkProps, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps} from './openLink'; | ||
export {openLink, getSyntheticLinkProps, useSyntheticLinkProps, RouterProvider, shouldClientNavigate, useRouter, useLinkProps, handleLinkClick} from './openLink'; | ||
export {runAfterTransition} from './runAfterTransition'; | ||
@@ -29,2 +31,3 @@ export {useDrag1D} from './useDrag1D'; | ||
export {useUpdateEffect} from './useUpdateEffect'; | ||
export {useUpdateLayoutEffect} from './useUpdateLayoutEffect'; | ||
export {useLayoutEffect} from './useLayoutEffect'; | ||
@@ -48,1 +51,9 @@ export {useResizeObserver} from './useResizeObserver'; | ||
export {useLoadMore} from './useLoadMore'; | ||
export {UNSTABLE_useLoadMoreSentinel} from './useLoadMoreSentinel'; | ||
export {inertValue} from './inertValue'; | ||
export {CLEAR_FOCUS_EVENT, FOCUS_EVENT} from './constants'; | ||
export {isCtrlKeyPressed} from './keyboard'; | ||
export {useEnterAnimation, useExitAnimation} from './animation'; | ||
export {isFocusable, isTabbable} from './isFocusable'; | ||
export type {LoadMoreSentinelProps} from './useLoadMoreSentinel'; |
@@ -13,3 +13,6 @@ /* | ||
export function isScrollable(node: Element, checkForOverflow?: boolean): boolean { | ||
export function isScrollable(node: Element | null, checkForOverflow?: boolean): boolean { | ||
if (!node) { | ||
return false; | ||
} | ||
let style = window.getComputedStyle(node); | ||
@@ -16,0 +19,0 @@ let isScrollable = /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY); |
@@ -42,3 +42,3 @@ /* | ||
export function isVirtualPointerEvent(event: PointerEvent) { | ||
export function isVirtualPointerEvent(event: PointerEvent): boolean { | ||
// If the pointer size is zero, then we assume it's from a screen reader. | ||
@@ -45,0 +45,0 @@ // Android TalkBack double tap will sometimes return a event with width and height of 1 |
@@ -26,3 +26,3 @@ /* | ||
type NullToObject<T> = T extends (null | undefined) ? {} : T; | ||
// eslint-disable-next-line no-undef, @typescript-eslint/no-unused-vars | ||
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never; | ||
@@ -29,0 +29,0 @@ |
@@ -13,3 +13,3 @@ /* | ||
import {ForwardedRef, MutableRefObject} from 'react'; | ||
import {MutableRefObject, Ref} from 'react'; | ||
@@ -19,3 +19,3 @@ /** | ||
*/ | ||
export function mergeRefs<T>(...refs: Array<ForwardedRef<T> | MutableRefObject<T> | null | undefined>): ForwardedRef<T> { | ||
export function mergeRefs<T>(...refs: Array<Ref<T> | MutableRefObject<T> | null | undefined>): Ref<T> { | ||
if (refs.length === 1 && refs[0]) { | ||
@@ -26,10 +26,30 @@ return refs[0]; | ||
return (value: T | null) => { | ||
for (let ref of refs) { | ||
if (typeof ref === 'function') { | ||
ref(value); | ||
} else if (ref != null) { | ||
ref.current = value; | ||
} | ||
let hasCleanup = false; | ||
const cleanups = refs.map(ref => { | ||
const cleanup = setRef(ref, value); | ||
hasCleanup ||= typeof cleanup == 'function'; | ||
return cleanup; | ||
}); | ||
if (hasCleanup) { | ||
return () => { | ||
cleanups.forEach((cleanup, i) => { | ||
if (typeof cleanup === 'function') { | ||
cleanup(); | ||
} else { | ||
setRef(refs[i], null); | ||
} | ||
}); | ||
}; | ||
} | ||
}; | ||
} | ||
function setRef<T>(ref: Ref<T> | MutableRefObject<T> | null | undefined, value: T) { | ||
if (typeof ref === 'function') { | ||
return ref(value); | ||
} else if (ref != null) { | ||
ref.current = value; | ||
} | ||
} |
@@ -17,6 +17,5 @@ /* | ||
} | ||
return ( | ||
window.navigator['userAgentData']?.brands.some((brand: {brand: string, version: string}) => re.test(brand.brand)) | ||
) || | ||
re.test(window.navigator.userAgent); | ||
let brands = window.navigator['userAgentData']?.brands; | ||
return Array.isArray(brands) && brands.some((brand: {brand: string, version: string}) => re.test(brand.brand)) || | ||
re.test(window.navigator.userAgent); | ||
} | ||
@@ -34,3 +33,3 @@ | ||
} | ||
let res: boolean | null = null; | ||
@@ -45,11 +44,11 @@ return () => { | ||
export const isMac = cached(function () { | ||
export const isMac: () => boolean = cached(function () { | ||
return testPlatform(/^Mac/i); | ||
}); | ||
export const isIPhone = cached(function () { | ||
export const isIPhone: () => boolean = cached(function () { | ||
return testPlatform(/^iPhone/i); | ||
}); | ||
export const isIPad = cached(function () { | ||
export const isIPad: () => boolean = cached(function () { | ||
return testPlatform(/^iPad/i) || | ||
@@ -60,24 +59,24 @@ // iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support. | ||
export const isIOS = cached(function () { | ||
export const isIOS: () => boolean = cached(function () { | ||
return isIPhone() || isIPad(); | ||
}); | ||
export const isAppleDevice = cached(function () { | ||
export const isAppleDevice: () => boolean = cached(function () { | ||
return isMac() || isIOS(); | ||
}); | ||
export const isWebKit = cached(function () { | ||
export const isWebKit: () => boolean = cached(function () { | ||
return testUserAgent(/AppleWebKit/i) && !isChrome(); | ||
}); | ||
export const isChrome = cached(function () { | ||
export const isChrome: () => boolean = cached(function () { | ||
return testUserAgent(/Chrome/i); | ||
}); | ||
export const isAndroid = cached(function () { | ||
export const isAndroid: () => boolean = cached(function () { | ||
return testUserAgent(/Android/i); | ||
}); | ||
export const isFirefox = cached(function () { | ||
export const isFirefox: () => boolean = cached(function () { | ||
return testUserAgent(/Firefox/i); | ||
}); |
@@ -94,5 +94,21 @@ /* | ||
export function runAfterTransition(fn: () => void) { | ||
/** | ||
* Cleans up any elements that are no longer in the document. | ||
* This is necessary because we can't rely on transitionend events to fire | ||
* for elements that are removed from the document while transitioning. | ||
*/ | ||
function cleanupDetachedElements() { | ||
for (const [eventTarget] of transitionsByElement) { | ||
// Similar to `eventTarget instanceof Element && !eventTarget.isConnected`, but avoids | ||
// the explicit instanceof check, since it may be different in different contexts. | ||
if ('isConnected' in eventTarget && !eventTarget.isConnected) { | ||
transitionsByElement.delete(eventTarget); | ||
} | ||
} | ||
} | ||
export function runAfterTransition(fn: () => void): void { | ||
// Wait one frame to see if an animation starts, e.g. a transition on mount. | ||
requestAnimationFrame(() => { | ||
cleanupDetachedElements(); | ||
// If no transitions are running, call the function immediately. | ||
@@ -99,0 +115,0 @@ // Otherwise, add it to a list of callbacks to run at the end of the animation. |
@@ -17,3 +17,3 @@ /* | ||
/** The optional containing element of the target to be centered in the viewport. */ | ||
containingElement?: Element | ||
containingElement?: Element | null | ||
} | ||
@@ -26,3 +26,3 @@ | ||
*/ | ||
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement) { | ||
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void { | ||
let offsetX = relativeOffset(scrollView, element, 'left'); | ||
@@ -35,6 +35,14 @@ let offsetY = relativeOffset(scrollView, element, 'top'); | ||
// 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 | ||
@@ -44,12 +52,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; | ||
@@ -88,4 +104,4 @@ scrollView.scrollTop = y; | ||
*/ | ||
export function scrollIntoViewport(targetElement: Element, opts?: ScrollIntoViewportOpts) { | ||
if (document.contains(targetElement)) { | ||
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts): void { | ||
if (targetElement && document.contains(targetElement)) { | ||
let root = document.scrollingElement || document.documentElement; | ||
@@ -92,0 +108,0 @@ let isScrollPrevented = window.getComputedStyle(root).overflow === 'hidden'; |
@@ -13,8 +13,12 @@ /* | ||
import {useCallback, useRef} from 'react'; | ||
import React, {useCallback, useRef} from 'react'; | ||
import {useLayoutEffect} from './useLayoutEffect'; | ||
// Use the earliest effect type possible. useInsertionEffect runs during the mutation phase, | ||
// before all layout effects, but is available only in React 18 and later. | ||
const useEarlyEffect = React['useInsertionEffect'] ?? useLayoutEffect; | ||
export function useEffectEvent<T extends Function>(fn?: T): T { | ||
const ref = useRef<T | null | undefined>(null); | ||
useLayoutEffect(() => { | ||
useEarlyEffect(() => { | ||
ref.current = fn; | ||
@@ -21,0 +25,0 @@ }, [fn]); |
@@ -22,3 +22,3 @@ /* | ||
options?: boolean | AddEventListenerOptions | ||
) { | ||
): void { | ||
let handleEvent = useEffectEvent(handler); | ||
@@ -25,0 +25,0 @@ let isDisabled = handler == null; |
@@ -14,14 +14,13 @@ /* | ||
import {RefObject} from '@react-types/shared'; | ||
import {useEffect, useRef} from 'react'; | ||
import {useEffect} from 'react'; | ||
import {useEffectEvent} from './useEffectEvent'; | ||
export function useFormReset<T>( | ||
ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null>, | ||
ref: RefObject<HTMLInputElement | HTMLTextAreaElement | HTMLSelectElement | null> | undefined, | ||
initialValue: T, | ||
onReset: (value: T) => void | ||
) { | ||
let resetValue = useRef(initialValue); | ||
): void { | ||
let handleReset = useEffectEvent(() => { | ||
if (onReset) { | ||
onReset(resetValue.current); | ||
onReset(initialValue); | ||
} | ||
@@ -32,2 +31,3 @@ }); | ||
let form = ref?.current?.form; | ||
form?.addEventListener('reset', handleReset); | ||
@@ -34,0 +34,0 @@ return () => { |
@@ -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); | ||
}, []); | ||
@@ -47,3 +48,3 @@ let removeGlobalListener = useCallback((eventTarget, type, listener, options) => { | ||
// eslint-disable-next-line arrow-body-style | ||
useEffect(() => { | ||
@@ -50,0 +51,0 @@ return removeAllGlobalListeners; |
@@ -25,3 +25,12 @@ /* | ||
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; | ||
if (typeof FinalizationRegistry !== 'undefined') { | ||
registry = new FinalizationRegistry<string>((heldValue) => { | ||
idsUpdaterMap.delete(heldValue); | ||
}); | ||
} | ||
@@ -37,13 +46,14 @@ /** | ||
let res = useSSRSafeId(value); | ||
let cleanupRef = useRef(null); | ||
let updateValue = useCallback((val) => { | ||
nextId.current = val; | ||
}, []); | ||
if (registry) { | ||
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 +65,7 @@ } | ||
return () => { | ||
// In Suspense, the cleanup function may be not called | ||
// when it is though, also remove it from the finalization registry. | ||
if (registry) { | ||
registry.unregister(cleanupRef); | ||
} | ||
idsUpdaterMap.delete(r); | ||
@@ -60,10 +75,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 +101,3 @@ | ||
if (setIdsA) { | ||
setIdsA.forEach(fn => fn(idB)); | ||
setIdsA.forEach(ref => (ref.current = idB)); | ||
return idB; | ||
@@ -92,3 +108,3 @@ } | ||
if (setIdsB) { | ||
setIdsB.forEach(fn => fn(idA)); | ||
setIdsB.forEach((ref) => (ref.current = idA)); | ||
return idA; | ||
@@ -95,0 +111,0 @@ } |
@@ -18,4 +18,4 @@ /* | ||
// we can suppress this by replace it with a noop on the server. | ||
export const useLayoutEffect = typeof document !== 'undefined' | ||
export const useLayoutEffect: typeof React.useLayoutEffect = typeof document !== 'undefined' | ||
? React.useLayoutEffect | ||
: () => {}; |
@@ -15,3 +15,3 @@ /* | ||
import {useEvent} from './useEvent'; | ||
// eslint-disable-next-line rulesdir/useLayoutEffectRule | ||
import {useLayoutEffect} from './useLayoutEffect'; | ||
@@ -36,3 +36,3 @@ | ||
export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>) { | ||
export function useLoadMore(props: LoadMoreProps, ref: RefObject<HTMLElement | null>): void { | ||
let {isLoading, onLoadMore, scrollOffset = 1, items} = props; | ||
@@ -39,0 +39,0 @@ |
@@ -13,3 +13,3 @@ /* | ||
import {MutableRefObject, useMemo, useRef} from 'react'; | ||
import {MutableRefObject, useCallback, useMemo, useRef} from 'react'; | ||
@@ -21,21 +21,51 @@ /** | ||
* | ||
* @param forwardedRef The original ref intended to be used. | ||
* @param ref The original ref intended to be used. | ||
* @returns An object ref that updates the given ref. | ||
* @see https://reactjs.org/docs/forwarding-refs.html | ||
* @see https://react.dev/reference/react/forwardRef | ||
*/ | ||
export function useObjectRef<T>(forwardedRef?: ((instance: T | null) => void) | MutableRefObject<T | null> | null): MutableRefObject<T | null> { | ||
export function useObjectRef<T>(ref?: ((instance: T | null) => (() => void) | void) | MutableRefObject<T | null> | null): MutableRefObject<T | null> { | ||
const objRef: MutableRefObject<T | null> = useRef<T>(null); | ||
return useMemo(() => ({ | ||
get current() { | ||
return objRef.current; | ||
const cleanupRef: MutableRefObject<(() => void) | void> = useRef(undefined); | ||
const refEffect = useCallback( | ||
(instance: T | null) => { | ||
if (typeof ref === 'function') { | ||
const refCallback = ref; | ||
const refCleanup = refCallback(instance); | ||
return () => { | ||
if (typeof refCleanup === 'function') { | ||
refCleanup(); | ||
} else { | ||
refCallback(null); | ||
} | ||
}; | ||
} else if (ref) { | ||
ref.current = instance; | ||
return () => { | ||
ref.current = null; | ||
}; | ||
} | ||
}, | ||
set current(value) { | ||
objRef.current = value; | ||
if (typeof forwardedRef === 'function') { | ||
forwardedRef(value); | ||
} else if (forwardedRef) { | ||
forwardedRef.current = value; | ||
[ref] | ||
); | ||
return useMemo( | ||
() => ({ | ||
get current() { | ||
return objRef.current; | ||
}, | ||
set current(value) { | ||
objRef.current = value; | ||
if (cleanupRef.current) { | ||
cleanupRef.current(); | ||
cleanupRef.current = undefined; | ||
} | ||
if (value != null) { | ||
cleanupRef.current = refEffect(value); | ||
} | ||
} | ||
} | ||
}), [forwardedRef]); | ||
}), | ||
[refEffect] | ||
); | ||
} |
@@ -15,3 +15,3 @@ | ||
export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>) { | ||
export function useResizeObserver<T extends Element>(options: useResizeObserverOptionsType<T>): void { | ||
const {ref, box, onResize} = options; | ||
@@ -18,0 +18,0 @@ |
@@ -22,3 +22,3 @@ /* | ||
// Syncs ref from context with ref passed to hook | ||
export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>) { | ||
export function useSyncRef<T>(context?: ContextValue<T> | null, ref?: RefObject<T | null>): void { | ||
useLayoutEffect(() => { | ||
@@ -25,0 +25,0 @@ if (context && context.ref && ref) { |
@@ -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 { | ||
const isInitialMount = useRef(true); | ||
@@ -29,5 +29,6 @@ const lastDeps = useRef<any[] | null>(null); | ||
useEffect(() => { | ||
let prevDeps = lastDeps.current; | ||
if (isInitialMount.current) { | ||
isInitialMount.current = false; | ||
} else if (!lastDeps.current || dependencies.some((dep, i) => !Object.is(dep, lastDeps[i]))) { | ||
} else if (!prevDeps || dependencies.some((dep, i) => !Object.is(dep, prevDeps[i]))) { | ||
effect(); | ||
@@ -34,0 +35,0 @@ } |
@@ -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
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
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
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 11 instances in 1 package
Unidentified License
License(Experimental) Something that seems like a license was found, but its contents could not be matched with a known license.
Found 10 instances in 1 package
771557
37.9%256
26.73%9229
39.9%8
33.33%17
6.25%4
300%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed