@react-aria/utils
Advanced tools
Comparing version 3.0.0-nightly.706 to 3.0.0-nightly.709
@@ -642,2 +642,39 @@ var _clsx = $parcel$interopDefault(require("clsx")); | ||
exports.runAfterTransition = runAfterTransition; | ||
function $f58f1969071f2661185e38312efabfc$var$hasResizeObserver() { | ||
return typeof window.ResizeObserver !== 'undefined'; | ||
} | ||
function useResizeObserver(options) { | ||
const { | ||
ref, | ||
onResize | ||
} = options; | ||
useEffect(() => { | ||
if (!ref) { | ||
return; | ||
} | ||
if (!$f58f1969071f2661185e38312efabfc$var$hasResizeObserver()) { | ||
window.addEventListener('resize', onResize, false); | ||
return () => { | ||
window.removeEventListener('resize', onResize, false); | ||
}; | ||
} else { | ||
const resizeObserverInstance = new window.ResizeObserver(entries => { | ||
if (!entries.length) { | ||
return; | ||
} | ||
onResize(); | ||
}); | ||
resizeObserverInstance.observe(ref.current); | ||
return () => { | ||
resizeObserverInstance.unobserve(ref.current); | ||
}; | ||
} | ||
}, [onResize, ref]); | ||
} | ||
exports.useResizeObserver = useResizeObserver; | ||
//# sourceMappingURL=main.js.map |
@@ -592,2 +592,37 @@ import _clsx from "clsx"; | ||
} | ||
function $d642970c01dc21e3fe2261c17768$var$hasResizeObserver() { | ||
return typeof window.ResizeObserver !== 'undefined'; | ||
} | ||
export function useResizeObserver(options) { | ||
const { | ||
ref, | ||
onResize | ||
} = options; | ||
useEffect(() => { | ||
if (!ref) { | ||
return; | ||
} | ||
if (!$d642970c01dc21e3fe2261c17768$var$hasResizeObserver()) { | ||
window.addEventListener('resize', onResize, false); | ||
return () => { | ||
window.removeEventListener('resize', onResize, false); | ||
}; | ||
} else { | ||
const resizeObserverInstance = new window.ResizeObserver(entries => { | ||
if (!entries.length) { | ||
return; | ||
} | ||
onResize(); | ||
}); | ||
resizeObserverInstance.observe(ref.current); | ||
return () => { | ||
resizeObserverInstance.unobserve(ref.current); | ||
}; | ||
} | ||
}, [onResize, ref]); | ||
} | ||
//# sourceMappingURL=module.js.map |
@@ -1,2 +0,2 @@ | ||
import React, { HTMLAttributes, MutableRefObject, EffectCallback } from "react"; | ||
import React, { HTMLAttributes, MutableRefObject, EffectCallback, RefObject } from "react"; | ||
import { Orientation, AriaLabelingProps, DOMProps } from "@react-types/shared"; | ||
@@ -82,3 +82,8 @@ export const useLayoutEffect: typeof React.useLayoutEffect; | ||
export function runAfterTransition(fn: () => void): void; | ||
type useResizeObserverOptionsType<T> = { | ||
ref: RefObject<T>; | ||
onResize: () => void; | ||
}; | ||
export function useResizeObserver<T extends HTMLElement>(options: useResizeObserverOptionsType<T>): void; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@react-aria/utils", | ||
"version": "3.0.0-nightly.706+f5f16024", | ||
"version": "3.0.0-nightly.709+116f300e", | ||
"description": "Spectrum UI components in React", | ||
@@ -21,4 +21,4 @@ "license": "Apache-2.0", | ||
"@babel/runtime": "^7.6.2", | ||
"@react-aria/ssr": "3.0.1-nightly.2384+f5f16024", | ||
"@react-types/shared": "3.0.0-nightly.706+f5f16024", | ||
"@react-aria/ssr": "3.0.1-nightly.2387+116f300e", | ||
"@react-types/shared": "3.0.0-nightly.709+116f300e", | ||
"clsx": "^1.1.1" | ||
@@ -32,3 +32,3 @@ }, | ||
}, | ||
"gitHead": "f5f16024617a0ce88805cf845a5db16d94cc6ace" | ||
"gitHead": "116f300e4e8a6e0eb5cc2945b7a11a659f173c02" | ||
} |
@@ -25,1 +25,2 @@ /* | ||
export * from './useLayoutEffect'; | ||
export * from './useResizeObserver'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
174921
23
1868