UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

74 lines (73 loc) 2.64 kB
import { jsx, jsxs } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useTheme } from "@mui/material/styles"; import useMediaQuery from "@mui/material/useMediaQuery"; import { useDefaultProps } from "@hitachivantara/uikit-react-utils"; import { useClasses, getBreakpointStyles } from "./GlobalActions.styles.js"; import { staticClasses } from "./GlobalActions.styles.js"; import { HvTypography } from "../Typography/Typography.js"; const HvGlobalActions = forwardRef(function HvGlobalActions2(props, ref) { const { children, classes: classesProp, className, title, variant = "global", backButton, headingLevel, position: positionProp, ...others } = useDefaultProps("HvGlobalActions", props); const muiTheme = useTheme(); const { classes, cx, css } = useClasses(classesProp); const isSmDown = useMediaQuery(muiTheme.breakpoints.down("sm")); const isUpMd = useMediaQuery(muiTheme.breakpoints.up("md")); const headingLevelToApply = headingLevel || (variant === "global" ? 1 : 2); const position = positionProp || (variant === "global" ? "sticky" : "relative"); return /* @__PURE__ */ jsx( "div", { ref, className: cx( classes.root, { [classes.positionSticky]: position === "sticky", [classes.positionFixed]: position === "fixed", [classes.global]: variant === "global", [classes.section]: variant === "section" }, position === "fixed" && css(getBreakpointStyles(isUpMd, isSmDown)), className ), ...others, children: /* @__PURE__ */ jsxs( "div", { className: cx(classes.wrapper, { [classes.globalWrapperComplement]: variant === "global", [classes.globalSectionArea]: variant === "section" }), children: [ variant === "global" && backButton && /* @__PURE__ */ jsx("div", { className: classes.backButton, children: backButton }), typeof title !== "string" ? title : /* @__PURE__ */ jsx( HvTypography, { variant: variant === "global" ? "title3" : "title4", component: `h${headingLevelToApply}`, className: cx(classes.name, { [classes.sectionName]: variant !== "global" }), children: title } ), children && /* @__PURE__ */ jsx("div", { className: classes.actions, children }) ] } ) } ); }); export { HvGlobalActions, staticClasses as globalActionsClasses };