@veracity/vui
Version:
Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.
56 lines (54 loc) • 1.61 kB
JavaScript
import { cs } from "../utils/styles.js";
import { useStyleConfig } from "../core/theme.js";
import styled from "../core/styled.js";
import vui from "../core/vui.js";
import { Box } from "../box/box.js";
import { useEffect, useState } from "react";
import { jsx } from "react/jsx-runtime";
//#region src/progress/progress.tsx
const ProgressBase = styled.divBox`
display: flex;
width: 100%;
`;
const minPercentageDisplay = 3;
const maxValue = 100;
/** Indicates a process progress. */
const Progress = vui((props, ref) => {
const { className, value = 0, showPercentage, ...rest } = props;
const [width, setWidth] = useState(0);
const styles = useStyleConfig("Progress", props);
useEffect(() => {
const w = !value ? 0 : Math.ceil(value);
setWidth(w > maxValue ? maxValue : w);
}, [value]);
const bg = rest.bg || styles.bg;
const color = rest.color || styles.color;
return /* @__PURE__ */ jsx(ProgressBase, {
className: cs("vui-progress", className),
ref,
...styles.container,
...rest,
bg,
borderRadius: "sm",
h: 1,
children: /* @__PURE__ */ jsx(Box, {
bg: color,
borderRadius: "sm",
position: "relative",
textAlign: "right",
transition: "width 0.4s ease-in-out;",
w: `${width}%`,
children: showPercentage && value >= minPercentageDisplay && /* @__PURE__ */ jsx(Box, {
...styles.percentage,
position: "absolute",
right: "0",
children: `${width}%`
})
})
});
});
Progress.displayName = "Progress";
//#endregion
export { Progress, Progress as default, ProgressBase };
globalThis.__vuiVersion__ = "5.3.1"
//# sourceMappingURL=progress.js.map