@payfit/unity-components
Version:
71 lines (70 loc) • 1.88 kB
JavaScript
import { forwardRef as e } from "react";
import { uyTv as t } from "@payfit/unity-themes";
import { jsx as n } from "react/jsx-runtime";
import { ProgressBar as r } from "react-aria-components/ProgressBar";
//#region src/core/components/progress-bar/ProgressBar.tsx
var i = t({
slots: {
base: "uy:relative uy:overflow-hidden uy:bg-surface-neutral-disabled uy:w-full",
meter: "uy:absolute uy:inset-y-0 uy:left-0"
},
variants: {
variant: {
success: { meter: "uy:bg-surface-success" },
primary: { meter: "uy:bg-surface-primary" }
},
size: {
small: {
base: "uy:h-75 uy:rounded-75",
meter: "uy:rounded-l-75"
},
large: {
base: "uy:h-150 uy:rounded-150",
meter: "uy:rounded-l-150"
}
},
isIndeterminate: { true: { meter: "uy:w-1/3 uy:animate-[progress-indeterminate_1.6s_linear_infinite] uy:motion-reduce:animate-none" } },
isFull: { true: {} }
},
compoundVariants: [{
size: "small",
isFull: !0,
class: { meter: "uy:rounded-r-75" }
}, {
size: "large",
isFull: !0,
class: { meter: "uy:rounded-r-150" }
}],
defaultVariants: {
variant: "success",
size: "large",
isFull: !1
}
}), a = e(({ value: e = 0, isIndeterminate: t = !1, range: a = [0, 100], variant: o = "success", size: s = "large", ...c }, l) => {
let [u, d] = a, { base: f, meter: p } = i({
isFull: !t && e >= d,
isIndeterminate: t,
variant: o,
size: s
});
return /* @__PURE__ */ n(r, {
ref: l,
className: "uy:w-full uy:shrink-0",
value: e,
isIndeterminate: t,
minValue: u,
maxValue: d,
"aria-label": c["aria-label"],
"data-dd-privacy": "allow",
children: ({ percentage: e }) => /* @__PURE__ */ n("div", {
className: f(),
children: /* @__PURE__ */ n("div", {
className: p(),
style: { width: t ? void 0 : `${e}%` }
})
})
});
});
a.displayName = "ProgressBar";
//#endregion
export { a as ProgressBar };