/** * @fileoverview IntersectionObserver hook for viewport visibility detection. * @author Saasflareâ„¢ * @module packages/ui/hooks/use-intersection-observer * @package ui * * @example * const ref = useRef(null); * const entry = useIntersectionObserver(ref, { threshold: 0.5 }); * const isVisible = entry?.isIntersecting ?? false; */ import { type RefObject } from 'react'; /** Options for the IntersectionObserver */ export interface UseIntersectionObserverOptions { /** Margin around the root. Default: `'0px'` */ rootMargin?: string; /** Visibility threshold(s) between 0 and 1. Default: `0` */ threshold?: number | number[]; /** Root element for intersection (defaults to viewport) */ root?: Element | null; /** Only trigger once then disconnect. Default: `false` */ triggerOnce?: boolean; /** Whether the observer is active. Default: `true` */ enabled?: boolean; } /** * Observes an element's intersection with the viewport or a root element. * Returns the latest IntersectionObserverEntry. * * @param {RefObject} ref - The element to observe * @param {UseIntersectionObserverOptions} [options] - Observer configuration * @returns {IntersectionObserverEntry | null} The latest intersection entry * * @example * const sectionRef = useRef(null); * const entry = useIntersectionObserver(sectionRef, { * threshold: [0, 0.25, 0.5, 0.75, 1], * rootMargin: '-100px', * }); * const ratio = entry?.intersectionRatio ?? 0; */ export declare function useIntersectionObserver(ref: RefObject, options?: UseIntersectionObserverOptions): IntersectionObserverEntry | null;