UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

61 lines (60 loc) 1.71 kB
import { jsxs, jsx } from "react/jsx-runtime"; import { forwardRef } from "react"; import { useDefaultProps, mergeStyles } from "@hitachivantara/uikit-react-utils"; import { getColor } from "@hitachivantara/uikit-styles"; import { range } from "../utils/helpers.js"; import { useClasses } from "./Loading.styles.js"; import { staticClasses } from "./Loading.styles.js"; const HvLoading = forwardRef(function HvLoading2(props, ref) { const { color, hidden, small, label, classes: classesProp, style, className, ...others } = useDefaultProps("HvLoading", props); const { classes, cx } = useClasses(classesProp); const size = small ? "small" : "regular"; const colorVariant = color && `${size}Color`; return /* @__PURE__ */ jsxs( "div", { ref, hidden: !!hidden, style: mergeStyles(style, { color: getColor(color, small ? "text" : "brand"), "--customColor": getColor(color) }), className: cx( classes.root, { [classes.hidden]: hidden }, className ), ...others, children: [ /* @__PURE__ */ jsx("div", { className: classes.barContainer, children: range(3).map((e) => /* @__PURE__ */ jsx( "div", { className: cx( classes.loadingBar, // TODO: hoist to parent & remove unused `colorVariant` in v6 classes[size], classes[colorVariant] ) }, e )) }), label && /* @__PURE__ */ jsx("div", { className: classes.label, children: label }) ] } ); }); export { HvLoading, staticClasses as loadingClasses };