UNPKG

@hitachivantara/uikit-react-core

Version:
34 lines (33 loc) 1.24 kB
import { HvTypography } from "../../Typography/Typography.js"; import { useClasses } from "./Content.styles.js"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { useState } from "react"; import { jsx } from "react/jsx-runtime"; import { useResizeDetector } from "react-resize-detector"; import MuiDialogContent from "@mui/material/DialogContent"; //#region src/Dialog/Content/Content.tsx var HvDialogContent = (props) => { const { classes: classesProp, className, children, indentContent, dividers, ...others } = useDefaultProps("HvDialogContent", props); const { classes, cx } = useClasses(classesProp); const [hasBorder, setHasBorder] = useState(false); const { ref: elRef } = useResizeDetector({ refreshMode: "throttle", refreshRate: 100, handleWidth: false, disableRerender: true, onResize: ({ entry }) => { if (!entry) return; setHasBorder(entry.target.scrollHeight > entry.target.clientHeight); } }); return /* @__PURE__ */ jsx(HvTypography, { ref: elRef, component: MuiDialogContent, dividers: dividers ?? hasBorder, className: cx(classes.root, { [classes.textContent]: !!indentContent }, className), ...others, children }); }; //#endregion export { HvDialogContent };