index.d.ts 878 B

1234567891011121314151617181920212223
  1. import { RefObject, RefCallback } from "react";
  2. export declare type ObservedSize = {
  3. width: number | undefined;
  4. height: number | undefined;
  5. };
  6. export declare type ResizeHandler = (size: ObservedSize) => void;
  7. declare type HookResponse<T extends Element> = {
  8. ref: RefCallback<T>;
  9. } & ObservedSize;
  10. export declare type ResizeObserverBoxOptions = "border-box" | "content-box" | "device-pixel-content-box";
  11. declare global {
  12. interface ResizeObserverEntry {
  13. readonly devicePixelContentBoxSize: ReadonlyArray<ResizeObserverSize>;
  14. }
  15. }
  16. export declare type RoundingFunction = (n: number) => number;
  17. declare function useResizeObserver<T extends Element>(opts?: {
  18. ref?: RefObject<T> | T | null | undefined;
  19. onResize?: ResizeHandler;
  20. box?: ResizeObserverBoxOptions;
  21. round?: RoundingFunction;
  22. }): HookResponse<T>;
  23. export default useResizeObserver;