UNPKG

@frontify/fondue

Version:
24 lines (23 loc) 753 B
import { useState as g, useLayoutEffect as c } from "react"; const a = "auto", d = (n) => { let t = "auto"; if (n.current) { const { innerHeight: e } = window, { bottom: o } = n.current.getBoundingClientRect(); t = `${Math.max(e - (o + 33 + 8), 130)}px`; } return t; }, u = (n, { isOpen: t, autoResize: e }) => { const [o, i] = g(a); return c(() => { const r = () => i(d(n)); return e && t ? (r(), window.addEventListener("resize", r)) : e && !t && i(a), () => { t && e && window.removeEventListener("resize", r); }; }, [t, e, n]), { maxHeight: o }; }; export { a as DEFAULT_DROPDOWN_MAX_HEIGHT, d as getInnerOverlayHeight, u as useDropdownAutoHeight }; //# sourceMappingURL=useDropdownAutoHeight.es.js.map