Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@reach/rect

Package Overview
Dependencies
Maintainers
3
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@reach/rect - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

76

index.d.ts

@@ -1,15 +0,69 @@

declare module "@reach/rect" {
import * as React from "react";
/**
* Measures DOM elements (aka. bounding client rect).
*
* @see getBoundingClientRect https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect
* @see Docs https://reacttraining.com/reach-ui/rect
* @see Source https://github.com/reach/reach-ui/tree/master/packages/rect
*/
export type RectProps = {
observe?: boolean;
onChange?: (rect: DOMRect) => void;
children?(args: { rect: DOMRect; ref: React.Ref<any> }): React.ReactNode;
};
import * as React from "react";
declare const Rect: React.FunctionComponent<RectProps>;
/**
* @see Docs https://reacttraining.com/reach-ui/rect#rect-props
*/
export type RectProps<T = any> = {
/**
* Tells `Rect` to observe the position of the node or not. While observing,
* the `children` render prop may call back very quickly (especially while
* scrolling) so it can be important for performance to avoid observing when
* you don't need to.
*
* This is typically used for elements that pop over other elements (like a
* dropdown menu), so you don't need to observe all the time, only when the
* popup is active.
*
* Pass `true` to observe, `false` to ignore.
*
* @see Docs https://reacttraining.com/reach-ui/rect#rect-observe
*/
observe?: boolean;
/**
* Calls back whenever the `rect` of the element changes.
*
* @see Docs https://reacttraining.com/reach-ui/rect#rect-onchange
*/
onChange?: (rect: DOMRect) => void;
/**
* A function that calls back to you with a `ref` to place on an element and
* the `rect` measurements of the dom node.
*
* **Note**: On the first render `rect` will be `undefined` because we can't
* measure a node that has not yet been rendered. Make sure your code accounts
* for this.
*
* @see Docs https://reacttraining.com/reach-ui/rect#rect-onchange
*/
children?(args: { rect: DOMRect; ref: React.Ref<T> }): React.ReactNode;
};
export function useRect(ref: React.Ref<any>, isSelected?: boolean): DOMRect;
/**
* @see Docs https://reacttraining.com/reach-ui/rect#rect
*/
declare const Rect: React.FunctionComponent<RectProps>;
export default Rect;
}
/**
*
* @template T The type for React.Ref to expect (default: `any`)
* @param {React.Ref<T>} ref The ref that will be passed to the DOM node for measuring
* @param {boolean} [observe] The condition for observing the node.
* @param {(rect: DOMRect) => void} [onChange] Callback to fire when `rect` changes
*
* @see Docs https://reacttraining.com/reach-ui/rect#use-rect
*/
export function useRect<T = any>(
ref: React.Ref<T>,
observe?: boolean,
onChange?: (rect: DOMRect) => void
): DOMRect;
export default Rect;

4

package.json
{
"name": "@reach/rect",
"version": "0.4.0",
"version": "0.5.0",
"description": "Measure React elements position in the DOM",

@@ -28,3 +28,3 @@ "main": "index.js",

],
"gitHead": "0f3d2c7e530cd80e1d1bd338182ac89a3ba23999"
"gitHead": "7e33672d882cd6df77ac8cdb76b6b4a21dbf28c2"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc