UNPKG

@hitachivantara/uikit-react-core

Version:

Core React components for the NEXT Design System.

55 lines (54 loc) 2.12 kB
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const jsxRuntime = require("react/jsx-runtime"); const MuiLinearProgress = require("@mui/material/LinearProgress"); const uikitReactUtils = require("@hitachivantara/uikit-react-utils"); const uikitStyles = require("@hitachivantara/uikit-styles"); const _interopDefault = (e) => e && e.__esModule ? e : { default: e }; const MuiLinearProgress__default = /* @__PURE__ */ _interopDefault(MuiLinearProgress); const { useClasses } = uikitReactUtils.createClasses("HvProgressColumnCell", { root: { display: "flex", width: "100%" }, linearProgressContainer: { width: "100%", margin: "auto" }, linearProgress: { height: 8 }, linearProgressRoot: { backgroundColor: uikitStyles.theme.colors.border }, linearProgressColorPrimary: { backgroundColor: uikitStyles.theme.colors.border }, linearProgressBarColorPrimary: { backgroundColor: uikitStyles.theme.colors.positive }, linearProgressBarColorSecondary: { backgroundColor: uikitStyles.theme.colors.text } }); const normalizeProgressBar = (value, max) => { return max > 0 ? Math.floor(value * 100 / max) : 0; }; const HvProgressColumnCell = ({ partial, total, color = "primary", "aria-labelledby": ariaLabelledBy }) => { const { classes } = useClasses(); const percentage = normalizeProgressBar(partial, total); return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.root, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.linearProgressContainer, children: /* @__PURE__ */ jsxRuntime.jsx( MuiLinearProgress__default.default, { className: classes.linearProgress, classes: { root: classes.linearProgressRoot, colorPrimary: classes.linearProgressColorPrimary, barColorPrimary: classes.linearProgressBarColorPrimary, barColorSecondary: classes.linearProgressBarColorSecondary }, color, variant: "determinate", value: percentage, "aria-labelledby": ariaLabelledBy } ) }) }); }; exports.HvProgressColumnCell = HvProgressColumnCell;