UNPKG

@hitachivantara/uikit-react-core

Version:
49 lines (48 loc) 1.72 kB
import { theme } from "@hitachivantara/uikit-styles"; import { createClasses } from "@hitachivantara/uikit-react-utils"; import { jsx } from "react/jsx-runtime"; import MuiLinearProgress from "@mui/material/LinearProgress"; //#region src/Table/renderers/ProgressColumnCell.tsx var { useClasses } = createClasses("HvProgressColumnCell", { root: { display: "flex", width: "100%" }, linearProgressContainer: { width: "100%", margin: "auto" }, linearProgress: { height: 8 }, linearProgressRoot: { backgroundColor: theme.colors.border }, linearProgressColorPrimary: { backgroundColor: theme.colors.border }, linearProgressBarColorPrimary: { backgroundColor: theme.colors.positive }, linearProgressBarColorSecondary: { backgroundColor: theme.colors.text } }); var normalizeProgressBar = (value, max) => { return max > 0 ? Math.floor(value * 100 / max) : 0; }; var HvProgressColumnCell = ({ partial, total, color = "primary", "aria-labelledby": ariaLabelledBy }) => { const { classes } = useClasses(); const percentage = normalizeProgressBar(partial, total); return /* @__PURE__ */ jsx("div", { className: classes.root, children: /* @__PURE__ */ jsx("div", { className: classes.linearProgressContainer, children: /* @__PURE__ */ jsx(MuiLinearProgress, { className: classes.linearProgress, classes: { root: classes.linearProgressRoot, colorPrimary: classes.linearProgressColorPrimary, barColorPrimary: classes.linearProgressBarColorPrimary, barColorSecondary: classes.linearProgressBarColorSecondary }, color, variant: "determinate", value: percentage, "aria-labelledby": ariaLabelledBy }) }) }); }; //#endregion export { HvProgressColumnCell };