@types/react-measure
TypeScript icon, indicating that this package has built-in type declarations

2.0.12 • Public • Published

Installation

npm install --save @types/react-measure

Summary

This package contains type definitions for react-measure (https://github.com/souporserious/react-measure).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-measure.

index.d.ts

import * as React from "react";

export type MeasurementType = "client" | "offset" | "scroll" | "bounds" | "margin";

interface TopLeft {
    readonly top: number;
    readonly left: number;
}

interface BottomRight {
    readonly bottom: number;
    readonly right: number;
}

interface Dimensions {
    readonly width: number;
    readonly height: number;
}

export type Margin = TopLeft & BottomRight;

export type Rect = TopLeft & Dimensions;

export type BoundingRect = Dimensions & Margin;

export interface ContentRect {
    client?: Rect | undefined;
    offset?: Rect | undefined;
    scroll?: Rect | undefined;
    bounds?: BoundingRect | undefined;
    margin?: Margin | undefined;
    entry?: any;
}

export interface MeasuredComponentProps {
    measureRef(ref: Element | null): void;
    measure(): void;
    contentRect: ContentRect;
}

type MeasuredComponent<T> = React.ComponentType<T & MeasuredComponentProps>;

export interface MeasureProps {
    client?: boolean | undefined;
    offset?: boolean | undefined;
    scroll?: boolean | undefined;
    bounds?: boolean | undefined;
    margin?: boolean | undefined;
    innerRef?: React.Ref<Element> | undefined;
    onResize?(contentRect: ContentRect): void;
    children?: React.FC<MeasuredComponentProps> | undefined;
}

export function withContentRect(
    types: readonly MeasurementType[] | MeasurementType,
): <T extends {}>(fn: MeasuredComponent<T>) => React.ComponentType<T>;

declare class Measure extends React.Component<MeasureProps> {}
export default Measure;

Additional Details

  • Last updated: Mon, 20 Nov 2023 23:36:24 GMT
  • Dependencies: @types/react

Credits

These definitions were written by Alexey Svetliakov, and Marc Fallows.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/react-measure

Weekly Downloads

95,547

Version

2.0.12

License

MIT

Unpacked Size

5.96 kB

Total Files

5

Last publish

Collaborators

  • types