UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

46 lines (45 loc) 1.26 kB
import { jsx } from "react/jsx-runtime"; import { useContext } from "react"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { setId } from "../../utils/setId.js"; import { HvFormElementContext } from "../context.js"; import { useClasses } from "./InfoMessage.styles.js"; import { staticClasses } from "./InfoMessage.styles.js"; import { HvTypography } from "../../Typography/Typography.js"; const HvInfoMessage = (props) => { const { id: idProp, classes: classesProp, className, children, disabled: disabledProp, disableGutter, ...others } = useDefaultProps("HvInfoMessage", props); const { classes, cx } = useClasses(classesProp); const context = useContext(HvFormElementContext); const disabled = disabledProp ?? context.disabled; const id = idProp ?? setId(context.id, "description"); return /* @__PURE__ */ jsx( HvTypography, { id, className: cx( classes.root, { [classes.infoDisabled]: !!disabled, [classes.gutter]: !disableGutter }, className ), variant: "body", component: "label", ...others, children } ); }; export { HvInfoMessage, staticClasses as infoMessageClasses };