UNPKG

@teamsparta/stack-custom-modal

Version:
46 lines (42 loc) 1.44 kB
"use client"; import { ScrollArea } from "./chunk-QC2XRG6L.mjs"; import { useCustomModal } from "./chunk-VHPHVMAP.mjs"; import { bodyCss } from "./chunk-YJGPPUJG.mjs"; import { __objRest, __spreadProps, __spreadValues } from "./chunk-FUJQIYOF.mjs"; // src/compounds/CustomModalBody.tsx import { useResizeObserver } from "@teamsparta/react"; import { useComposedRefs } from "@teamsparta/stack-utils"; import { forwardRef, useRef } from "react"; import { jsx } from "@emotion/react/jsx-runtime"; var CustomModalBody = forwardRef( (_a, ref) => { var _b = _a, { children } = _b, restProps = __objRest(_b, ["children"]); const { setHasScroll } = useCustomModal("CustomModalBody"); const scrollAreaRef = useRef(null); const resizeObserverRef = useResizeObserver({ onResize: ({ target }) => { var _a2, _b2; const { scrollHeight } = target; setHasScroll( scrollHeight > ((_b2 = (_a2 = scrollAreaRef == null ? void 0 : scrollAreaRef.current) == null ? void 0 : _a2.clientHeight) != null ? _b2 : 0) ); } }); const combinedRef = useComposedRefs(ref, resizeObserverRef); return /* @__PURE__ */ jsx(ScrollArea, { ref: scrollAreaRef, children: /* @__PURE__ */ jsx("div", __spreadProps(__spreadValues({ ref: combinedRef, css: bodyCss }, restProps), { children })) }); } ); CustomModalBody.displayName = "CustomModalBody"; export { CustomModalBody };