UNPKG

@konstructio/ui

Version:

A set of reusable and customizable React components built for konstruct.io

32 lines (31 loc) 797 B
import { i as z } from "./dist-D_9sBzad.js"; import * as a from "react"; function u(r) { const [h, i] = a.useState(void 0); return z(() => { if (r) { i({ width: r.offsetWidth, height: r.offsetHeight }); const f = new ResizeObserver((e) => { if (!Array.isArray(e) || !e.length) return; const b = e[0]; let o, t; if ("borderBoxSize" in b) { const s = b.borderBoxSize, d = Array.isArray(s) ? s[0] : s; o = d.inlineSize, t = d.blockSize; } else o = r.offsetWidth, t = r.offsetHeight; i({ width: o, height: t }); }); return f.observe(r, { box: "border-box" }), () => f.unobserve(r); } else i(void 0); }, [r]), h; } export { u as t };