import { type RefObject } from 'react'; export interface UseOverflowCollapseReturn { /** * Attach to the element whose inner width caps the content — the available * space. It must stay mounted in BOTH the expanded and the collapsed render * (it is the only thing left to measure once the content is swapped out). */ containerRef: RefObject; /** * Attach (as `ref={contentRef}`) to the natural-width content — its * `scrollWidth` is the space it needs. A callback ref, so the hook re-measures * the instant the content mounts or unmounts. Present only while expanded; the * hook remembers its last width so the collapsed branch keeps a threshold. */ contentRef: (node: N | null) => void; /** The content does not fit the container — swap to the compact form. */ isOverflowing: boolean; } /** * Reports whether a row of content is wider than the box it lives in, so a * caller can swap an overflowing strip for a compact form (a horizontal nav for * a dropdown, a toolbar for a "more" menu). Unlike a viewport media query, this * reacts to the CONTAINER — the same strip collapses in a narrow column on a * wide screen (e.g. a page squeezed between two sidebars) as on a small one. * * The catch with collapse-on-overflow is reversibility: once the content is * swapped out there is nothing left to measure, so a naive check can never * un-collapse. This remembers the content's width from the last frame it was * mounted (`naturalWidthRef`) — captured at the moment it overflowed, that is * its true min-content width — and keeps comparing it against the still-mounted * container, so the strip restores the instant the container grows back. * * The content is tracked as STATE via a callback ref (not a plain ref), so the * measurement effect re-subscribes whenever the content mounts/unmounts — for * ANY reason, not just an overflow-driven flip. A caller may collapse on a * second signal this hook can't see (a viewport media query *as well as* * overflow); keying re-subscription on the actual content node, rather than on * `isOverflowing`, keeps the observer attached across those transitions too. * `enabled` switches it off — e.g. when the host never collapses this strip — * clearing the flag so it renders expanded. * * Purely a layout decision; the content swap it drives stays fully in the DOM * and keyboard-reachable in either form, so assistive tech is unaffected. */ export declare function useOverflowCollapse(enabled?: boolean): UseOverflowCollapseReturn; //# sourceMappingURL=use-overflow-collapse.d.ts.map