UNPKG

fui-fancyui

Version:
17 lines (16 loc) 780 B
"use client"; import { jsx as o } from "react/jsx-runtime"; import { useState as s, useRef as x, useEffect as b } from "react"; import { InnerContentWrapper as m } from "./AutoSizingBox.style.js"; function v(c) { const { children: e, startHeight: u, startWidth: h, adjustHeight: r = !0, adjustWidth: i, changeTrigger: f } = c, [d, a] = s(u || "auto"), [l, g] = s(h || "auto"), t = x(null); return b(() => { const n = new ResizeObserver(() => { t.current && (r && a(t.current.scrollHeight), i && g(t.current.scrollWidth)); }); return t.current && n.observe(t.current), () => n.disconnect(); }, [e, r, i, f]), /* @__PURE__ */ o(m, { style: { height: d, width: l }, children: /* @__PURE__ */ o("div", { ref: t, children: e }) }); } export { v as default };