@serendie/ui
Version:
Adaptive UI component library as part of Serendie Design System by Mitsubishi Electric
17 lines (16 loc) • 461 B
JavaScript
import { useRef as a, useState as c, useEffect as s } from "react";
const l = (r) => {
const t = a(null), [e, o] = c(
null
);
return s(() => {
if (!r || !t.current) return;
const n = t.current.closest(
'[data-scope="dialog"][data-part="content"], [data-scope="drawer"][data-part="content"]'
);
n && o(n);
}, [r]), { triggerRef: t, portalContainerRef: e ? { current: e } : void 0 };
};
export {
l as useAutoPortalContainer
};