UNPKG

@frontify/fondue

Version:
24 lines (23 loc) 621 B
import { useState as c, useRef as u, useCallback as d } from "react"; import { debounce as f } from "../../../utilities/debounce.es.js"; const l = () => { const [s, t] = c(0), n = u(f((e) => t(e))); return { editorRef: d((e) => { if (!e) return; t(e.clientWidth); const r = new ResizeObserver((i) => { if (i.length === 0) return; const o = i[0].target.clientWidth; o > 0 && n.current(o); }); return setTimeout(() => { r.observe(e); }, 0), r; }, []), editorWidth: s }; }; export { l as useEditorResize }; //# sourceMappingURL=useEditorResize.es.js.map