You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@react-aria/utils

Package Overview
Dependencies
Maintainers
2
Versions
1093
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@react-aria/utils - npm Package Compare versions

Comparing version

to
3.0.0-nightly-9c6057f3f-250708

dist/useLoadMoreSentinel.main.js

3

dist/isFocusable.main.js

@@ -21,3 +21,4 @@

'video[controls]',
'[contenteditable]:not([contenteditable^="false"])'
'[contenteditable]:not([contenteditable^="false"])',
'permission'
];

@@ -24,0 +25,0 @@ const $506b33fd893eab7d$var$FOCUSABLE_ELEMENT_SELECTOR = $506b33fd893eab7d$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';

@@ -14,3 +14,4 @@ const $b4b717babfbb907b$var$focusableElements = [

'video[controls]',
'[contenteditable]:not([contenteditable^="false"])'
'[contenteditable]:not([contenteditable^="false"])',
'permission'
];

@@ -17,0 +18,0 @@ const $b4b717babfbb907b$var$FOCUSABLE_ELEMENT_SELECTOR = $b4b717babfbb907b$var$focusableElements.join(':not([hidden]),') + ',[tabindex]:not([disabled]):not([hidden])';

@@ -36,2 +36,3 @@ var $8c61827343eed941$exports = require("./useId.main.js");

var $faa6ccd6fb62f877$exports = require("./useLoadMore.main.js");
var $f6a4874a7c582761$exports = require("./useLoadMoreSentinel.main.js");
var $13915169b1e4142c$exports = require("./inertValue.main.js");

@@ -109,2 +110,3 @@ var $a0850d0add29d276$exports = require("./constants.main.js");

$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);

@@ -171,2 +173,3 @@ $parcel$export(module.exports, "CLEAR_FOCUS_EVENT", () => $a0850d0add29d276$exports.CLEAR_FOCUS_EVENT);

//# 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 @@

@@ -36,2 +36,3 @@ import {mergeIds as $bdb11010cef70236$export$cd8c9cb68f842629, useId as $bdb11010cef70236$export$f680877a34711e37, useSlotId as $bdb11010cef70236$export$b4cc09c592e8fdb8} from "./useId.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";

@@ -97,3 +98,4 @@ import {CLEAR_FOCUS_EVENT as $5671b20cf9b562b2$export$447a38995de2c711, FOCUS_EVENT as $5671b20cf9b562b2$export$831c820ad60f9d12} from "./constants.module.js";

export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $dfc540311bf7f109$export$4d0f8be8b12a7ef6 as createShadowTreeWalker, $dfc540311bf7f109$export$63eb3ababa9c55c4 as ShadowTreeWalker, $d4ee10de306f2510$export$cd4e5573fbe2b576 as getActiveElement, $d4ee10de306f2510$export$e58f029f0fbfdb29 as getEventTarget, $d4ee10de306f2510$export$4282f70798064fe0 as nodeContains, $431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow, $431fbd86ca7dc216$export$af51f0f06c0f328a as isShadowRoot, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $ca9b37712f007381$export$72ef708ab07251f1 as useUpdateLayoutEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $a40c673dc9f6d9c7$export$94ed1c92c7beeb22 as getScrollParents, $cc38e7bd3fc7b213$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $c87311424ea30a05$export$b7d78993b74f766d as isFirefox, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent, $5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo, $99facab73266f662$export$5add1d006293d136 as useFormReset, $26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore, $cdc5a6778b766db2$export$a9d04c5684123369 as inertValue, $5671b20cf9b562b2$export$447a38995de2c711 as CLEAR_FOCUS_EVENT, $5671b20cf9b562b2$export$831c820ad60f9d12 as FOCUS_EVENT, $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};
export {$bdb11010cef70236$export$f680877a34711e37 as useId, $bdb11010cef70236$export$cd8c9cb68f842629 as mergeIds, $bdb11010cef70236$export$b4cc09c592e8fdb8 as useSlotId, $ff5963eb1fccf552$export$e08e3b67e392101e as chain, $dfc540311bf7f109$export$4d0f8be8b12a7ef6 as createShadowTreeWalker, $dfc540311bf7f109$export$63eb3ababa9c55c4 as ShadowTreeWalker, $d4ee10de306f2510$export$cd4e5573fbe2b576 as getActiveElement, $d4ee10de306f2510$export$e58f029f0fbfdb29 as getEventTarget, $d4ee10de306f2510$export$4282f70798064fe0 as nodeContains, $431fbd86ca7dc216$export$b204af158042fbac as getOwnerDocument, $431fbd86ca7dc216$export$f21a1ffae260145a as getOwnerWindow, $431fbd86ca7dc216$export$af51f0f06c0f328a as isShadowRoot, $3ef42575df84b30b$export$9d1611c77c2fe928 as mergeProps, $5dc95899b306f630$export$c9058316764c140e as mergeRefs, $65484d02dcb7eb3e$export$457c3d6518dd4c6f as filterDOMProps, $7215afc6de606d6b$export$de79e2c695e052f3 as focusWithoutScrolling, $ab71dadb03a6fb2e$export$622cea445a1c5b7d as getOffset, $ea8dcbcb9ea1b556$export$95185d699e05d4d7 as openLink, $ea8dcbcb9ea1b556$export$51437d503373d223 as getSyntheticLinkProps, $ea8dcbcb9ea1b556$export$bdc77b0c0a3a85d6 as useSyntheticLinkProps, $ea8dcbcb9ea1b556$export$323e4fc2fa4753fb as RouterProvider, $ea8dcbcb9ea1b556$export$efa8c9099e530235 as shouldClientNavigate, $ea8dcbcb9ea1b556$export$9a302a45f65d0572 as useRouter, $ea8dcbcb9ea1b556$export$7e924b3091a3bd18 as useLinkProps, $bbed8b41f857bcc0$export$24490316f764c430 as runAfterTransition, $9cc09df9fd7676be$export$7bbed75feba39706 as useDrag1D, $03deb23ff14920c4$export$4eaf04e54aa8eed6 as useGlobalListeners, $313b98861ee5dd6c$export$d6875122194c7b44 as useLabels, $df56164dff5785e2$export$4338b53315abf666 as useObjectRef, $4f58c5f72bcf79f7$export$496315a1608d9602 as useUpdateEffect, $ca9b37712f007381$export$72ef708ab07251f1 as useUpdateLayoutEffect, $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c as useLayoutEffect, $9daab02d461809db$export$683480f191c0e3ea as useResizeObserver, $e7801be82b4b2a53$export$4debdb1a3f0fa79e as useSyncRef, $62d8ded9296f3872$export$cfa2225e87938781 as getScrollParent, $a40c673dc9f6d9c7$export$94ed1c92c7beeb22 as getScrollParents, $cc38e7bd3fc7b213$export$2bb74740c4e19def as isScrollable, $5df64b3807dc15ee$export$d699905dd57c73ca as useViewportSize, $ef06256079686ba0$export$f8aeda7b10753fa1 as useDescription, $c87311424ea30a05$export$9ac100e40613ea10 as isMac, $c87311424ea30a05$export$186c6964ca17d99 as isIPhone, $c87311424ea30a05$export$7bef049ce92e4224 as isIPad, $c87311424ea30a05$export$fedb369cb70207f1 as isIOS, $c87311424ea30a05$export$e1865c3bedcd822b as isAppleDevice, $c87311424ea30a05$export$78551043582a6a98 as isWebKit, $c87311424ea30a05$export$6446a186d09e379e as isChrome, $c87311424ea30a05$export$a11b0059900ceec8 as isAndroid, $c87311424ea30a05$export$b7d78993b74f766d as isFirefox, $e9faafb641e167db$export$90fc3a17d93f704c as useEvent, $1dbecbe27a04f9af$export$14d238f342723f25 as useValueEffect, $2f04cbc44ee30ce0$export$53a0910f038337bd as scrollIntoView, $2f04cbc44ee30ce0$export$c826860796309d1b as scrollIntoViewport, $4507461a1b870123$re_export$clamp as clamp, $4507461a1b870123$re_export$snapValueToStep as snapValueToStep, $6a7db85432448f7f$export$60278871457622de as isVirtualClick, $6a7db85432448f7f$export$29bf1b5f2c56cf63 as isVirtualPointerEvent, $8ae05eaa5c114e9c$export$7f54fc3180508a52 as useEffectEvent, $5a387cc49350e6db$export$722debc0e56fea39 as useDeepMemo, $99facab73266f662$export$5add1d006293d136 as useFormReset, $26f7f3da73fcd9d6$export$7717c92ee915373e as useLoadMore, $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

@@ -82,3 +82,3 @@ var $1117b6c0d4c4c164$exports = require("./focusWithoutScrolling.main.js");

// 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',

@@ -85,0 +85,0 @@ metaKey: metaKey,

@@ -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',

@@ -69,0 +69,0 @@ metaKey: metaKey,

@@ -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.

@@ -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, ReactNode, HTMLAttributes, EffectCallback, Dispatch, RefObject as _RefObject1 } from "react";
import { AriaLabelingProps, DOMProps, LinkDOMProps, FocusableElement, Orientation, Href, RouterOptions, RefObject, AsyncLoadable, Collection } from "@react-types/shared";
export const useLayoutEffect: typeof React.useLayoutEffect;

@@ -42,3 +42,3 @@ /**

*/
export function getEventTarget(event: any): Element;
export function getEventTarget<T extends Event>(event: T): Element;
export class ShadowTreeWalker implements TreeWalker {

@@ -95,3 +95,3 @@ readonly filter: NodeFilter | null;

*/
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 {

@@ -116,3 +116,3 @@ /**

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;

@@ -141,3 +141,3 @@ export const isIPhone: () => boolean;

*/
export function RouterProvider(props: RouterProviderProps): React.JSX.Element;
export function RouterProvider(props: RouterProviderProps): JSX.Element;
export function useRouter(): Router;

@@ -152,27 +152,6 @@ interface Modifiers {

export function openLink(target: HTMLAnchorElement, modifiers: Modifiers, setOpening?: boolean): void;
export function useSyntheticLinkProps(props: LinkDOMProps): {
'data-href': string | undefined;
'data-target': React.HTMLAttributeAnchorTarget | undefined;
'data-rel': string | undefined;
'data-download': string | boolean | undefined;
'data-ping': string | undefined;
'data-referrer-policy': React.HTMLAttributeReferrerPolicy | undefined;
};
export function useSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement>;
/** @deprecated - For backward compatibility. */
export function getSyntheticLinkProps(props: LinkDOMProps): {
'data-href': string | undefined;
'data-target': React.HTMLAttributeAnchorTarget | undefined;
'data-rel': string | undefined;
'data-download': string | boolean | undefined;
'data-ping': string | undefined;
'data-referrer-policy': React.HTMLAttributeReferrerPolicy | undefined;
};
export function useLinkProps(props?: LinkDOMProps): {
href: string | undefined;
target: React.HTMLAttributeAnchorTarget | undefined;
rel: string | undefined;
download: string | boolean | undefined;
ping: string | undefined;
referrerPolicy: React.HTMLAttributeReferrerPolicy | undefined;
};
export function getSyntheticLinkProps(props: LinkDOMProps): DOMAttributes<HTMLElement>;
export function useLinkProps(props?: LinkDOMProps): LinkDOMProps;
export function runAfterTransition(fn: () => void): void;

@@ -213,7 +192,7 @@ interface UseDrag1DProps {

*
* @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;

@@ -281,3 +260,15 @@ export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void;

export function useLoadMore(props: LoadMoreProps, ref: _RefObject1<HTMLElement | null>): void;
export function inertValue(value?: boolean): boolean | "true" | undefined;
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";

@@ -284,0 +275,0 @@ export const FOCUS_EVENT = "react-aria-focus";

@@ -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,4 @@ var $78605a5d7424e31b$exports = require("./useLayoutEffect.main.js");

// This can happen in suspended components where mount/unmount is not called.
let $8c61827343eed941$var$registry = new FinalizationRegistry((heldValue)=>{
let $8c61827343eed941$var$registry;
if (typeof FinalizationRegistry !== 'undefined') $8c61827343eed941$var$registry = new FinalizationRegistry((heldValue)=>{
$8c61827343eed941$export$d41a04c74483c6ef.delete(heldValue);

@@ -43,3 +44,3 @@ });

let cleanupRef = (0, $dG5aF$react.useRef)(null);
$8c61827343eed941$var$registry.register(cleanupRef, res);
if ($8c61827343eed941$var$registry) $8c61827343eed941$var$registry.register(cleanupRef, res);
if ($8c61827343eed941$var$canUseDOM) {

@@ -57,3 +58,3 @@ const cacheIdRef = $8c61827343eed941$export$d41a04c74483c6ef.get(res);

// when it is though, also remove it from the finalization registry.
$8c61827343eed941$var$registry.unregister(cleanupRef);
if ($8c61827343eed941$var$registry) $8c61827343eed941$var$registry.unregister(cleanupRef);
$8c61827343eed941$export$d41a04c74483c6ef.delete(r);

@@ -60,0 +61,0 @@ };

@@ -26,3 +26,4 @@ import {useLayoutEffect as $f0a04ccd8dbdd83b$export$e5c5a5f917a5871c} from "./useLayoutEffect.module.js";

// This can happen in suspended components where mount/unmount is not called.
let $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{
let $bdb11010cef70236$var$registry;
if (typeof FinalizationRegistry !== 'undefined') $bdb11010cef70236$var$registry = new FinalizationRegistry((heldValue)=>{
$bdb11010cef70236$export$d41a04c74483c6ef.delete(heldValue);

@@ -35,3 +36,3 @@ });

let cleanupRef = (0, $eKkEp$useRef)(null);
$bdb11010cef70236$var$registry.register(cleanupRef, res);
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.register(cleanupRef, res);
if ($bdb11010cef70236$var$canUseDOM) {

@@ -49,3 +50,3 @@ const cacheIdRef = $bdb11010cef70236$export$d41a04c74483c6ef.get(res);

// when it is though, also remove it from the finalization registry.
$bdb11010cef70236$var$registry.unregister(cleanupRef);
if ($bdb11010cef70236$var$registry) $bdb11010cef70236$var$registry.unregister(cleanupRef);
$bdb11010cef70236$export$d41a04c74483c6ef.delete(r);

@@ -52,0 +53,0 @@ };

@@ -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 @@ }

{
"name": "@react-aria/utils",
"version": "3.0.0-nightly-9bd8a5f19-250304",
"version": "3.0.0-nightly-9c6057f3f-250708",
"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,6 +30,6 @@ "require": "./dist/main.js"

"dependencies": {
"@react-aria/ssr": "3.0.0-nightly-9bd8a5f19-250304",
"@react-stately/flags": "3.0.0-nightly-9bd8a5f19-250304",
"@react-stately/utils": "3.0.0-nightly-9bd8a5f19-250304",
"@react-types/shared": "3.0.0-nightly-9bd8a5f19-250304",
"@react-aria/ssr": "3.0.0-nightly-9c6057f3f-250708",
"@react-stately/flags": "3.0.0-nightly-9c6057f3f-250708",
"@react-stately/utils": "3.0.0-nightly-9c6057f3f-250708",
"@react-types/shared": "3.0.0-nightly-9c6057f3f-250708",
"@swc/helpers": "^0.5.0",

@@ -32,0 +36,0 @@ "clsx": "^2.0.0"

@@ -17,6 +17,6 @@ /*

export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true) {
export function useEnterAnimation(ref: RefObject<HTMLElement | null>, isReady: boolean = true): boolean {
let [isEntering, setEntering] = useState(true);
let isAnimationReady = isEntering && isReady;
// There are two cases for entry animations:

@@ -42,3 +42,3 @@ // 1. CSS @keyframes. The `animation` property is set during the isEntering state, and it is removed after the animation finishes.

export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean) {
export function useExitAnimation(ref: RefObject<HTMLElement | null>, isOpen: boolean): boolean {
let [exitState, setExitState] = useState<'closed' | 'open' | 'exiting'>(isOpen ? 'open' : 'closed');

@@ -76,3 +76,3 @@

function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void) {
function useAnimation(ref: RefObject<HTMLElement | null>, isActive: boolean, onEnd: () => void): void {
useLayoutEffect(() => {

@@ -85,3 +85,3 @@ if (isActive && ref.current) {

}
let animations = ref.current.getAnimations();

@@ -101,3 +101,3 @@ if (animations.length === 0) {

}).catch(() => {});
return () => {

@@ -104,0 +104,0 @@ canceled = true;

@@ -31,3 +31,3 @@ /*

export function focusWithoutScrolling(element: FocusableElement) {
export function focusWithoutScrolling(element: FocusableElement): void {
if (supportsPreventScroll()) {

@@ -34,0 +34,0 @@ element.focus({preventScroll: true});

@@ -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) {

@@ -48,2 +48,3 @@ /*

export {useLoadMore} from './useLoadMore';
export {UNSTABLE_useLoadMoreSentinel} from './useLoadMoreSentinel';
export {inertValue} from './inertValue';

@@ -54,1 +55,3 @@ export {CLEAR_FOCUS_EVENT, FOCUS_EVENT} from './constants';

export {isFocusable, isTabbable} from './isFocusable';
export type {LoadMoreSentinelProps} from './useLoadMoreSentinel';
import {version} from 'react';
export function inertValue(value?: boolean) {
export function inertValue(value?: boolean): string | boolean | undefined {
const pieces = version.split('.');

@@ -5,0 +5,0 @@ const major = parseInt(pieces[0], 10);

@@ -14,3 +14,4 @@ const focusableElements = [

'video[controls]',
'[contenteditable]:not([contenteditable^="false"])'
'[contenteditable]:not([contenteditable^="false"])',
'permission'
];

@@ -23,8 +24,8 @@

export function isFocusable(element: Element) {
export function isFocusable(element: Element): boolean {
return element.matches(FOCUSABLE_ELEMENT_SELECTOR);
}
export function isTabbable(element: Element) {
export function isTabbable(element: Element): boolean {
return element.matches(TABBABLE_ELEMENT_SELECTOR);
}

@@ -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

@@ -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.

@@ -25,3 +25,3 @@ /*

*/
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement) {
export function scrollIntoView(scrollView: HTMLElement, element: HTMLElement): void {
let offsetX = relativeOffset(scrollView, element, 'left');

@@ -101,3 +101,3 @@ let offsetY = relativeOffset(scrollView, element, 'top');

*/
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts) {
export function scrollIntoViewport(targetElement: Element | null, opts?: ScrollIntoViewportOpts): void {
if (targetElement && document.contains(targetElement)) {

@@ -104,0 +104,0 @@ let root = document.scrollingElement || document.documentElement;

@@ -46,3 +46,3 @@ // Source: https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/DOMFunctions.ts#L16

*/
export const getActiveElement = (doc: Document = document) => {
export const getActiveElement = (doc: Document = document): Element | null => {
if (!shadowDOM()) {

@@ -64,9 +64,9 @@ return doc.activeElement;

*/
export function getEventTarget(event): Element {
if (shadowDOM() && event.target.shadowRoot) {
export function getEventTarget<T extends Event>(event: T): Element {
if (shadowDOM() && (event.target as HTMLElement).shadowRoot) {
if (event.composedPath) {
return event.composedPath()[0];
return event.composedPath()[0] as Element;
}
}
return event.target;
return event.target as Element;
}

@@ -314,3 +314,3 @@ // https://github.com/microsoft/tabster/blob/a89fc5d7e332d48f68d03b1ca6e344489d1c3898/src/Shadowdomize/ShadowTreeWalker.ts

filter?: NodeFilter | null
) {
): TreeWalker {
if (shadowDOM()) {

@@ -317,0 +317,0 @@ return new ShadowTreeWalker(doc, root, whatToShow, filter);

@@ -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,3 +14,3 @@ /*

import {RefObject} from '@react-types/shared';
import {useEffect, useRef} from 'react';
import {useEffect} from 'react';
import {useEffectEvent} from './useEffectEvent';

@@ -22,7 +22,6 @@

onReset: (value: T) => void
) {
let resetValue = useRef(initialValue);
): void {
let handleReset = useEffectEvent(() => {
if (onReset) {
onReset(resetValue.current);
onReset(initialValue);
}

@@ -33,2 +32,3 @@ });

let form = ref?.current?.form;
form?.addEventListener('reset', handleReset);

@@ -35,0 +35,0 @@ return () => {

@@ -29,5 +29,8 @@ /*

// This can happen in suspended components where mount/unmount is not called.
let registry = new FinalizationRegistry<string>((heldValue) => {
idsUpdaterMap.delete(heldValue);
});
let registry;
if (typeof FinalizationRegistry !== 'undefined') {
registry = new FinalizationRegistry<string>((heldValue) => {
idsUpdaterMap.delete(heldValue);
});
}

@@ -45,3 +48,5 @@ /**

registry.register(cleanupRef, res);
if (registry) {
registry.register(cleanupRef, res);
}

@@ -62,3 +67,5 @@ if (canUseDOM) {

// when it is though, also remove it from the finalization registry.
registry.unregister(cleanupRef);
if (registry) {
registry.unregister(cleanupRef);
}
idsUpdaterMap.delete(r);

@@ -65,0 +72,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';
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) {

@@ -17,3 +17,3 @@ /*

// Like useLayoutEffect, but only called for updates after the initial render.
export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]) {
export function useUpdateLayoutEffect(effect: EffectCallback, dependencies: any[]): void {
const isInitialMount = useRef(true);

@@ -20,0 +20,0 @@ const lastDeps = useRef<any[] | null>(null);

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

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.