UNPKG

@gits-id/progress-bar

Version:

GITS Progress Bar Component

108 lines (107 loc) 2.81 kB
import { defineComponent as v, toRefs as p, ref as y, watch as u, computed as i, openBlock as h, createElementBlock as S, normalizeClass as s, unref as r, normalizeStyle as g, createElementVNode as n, renderSlot as d, createTextVNode as C, toDisplayString as V } from "vue"; const x = ["aria-valuemin", "aria-valuemax", "aria-valuenow"], $ = /* @__PURE__ */ v({ __name: "VProgressBar", props: { modelValue: { type: [Number, String], default: 0 }, color: { type: String, default: "default" }, min: { type: [Number, String], default: 0 }, max: { type: [Number, String], default: 100 }, height: { type: [Number, String], default: "" }, bgColor: { type: String, default: "" }, fillColor: { type: String, default: "" }, bgClass: { type: String, default: "" }, fillClass: { type: String, default: "" }, label: { type: String, default: "" }, labelClass: { type: String, default: "" }, indeterminate: { type: Boolean, default: !1 } }, emits: ["update:modelValue"], setup(a, { emit: m }) { const e = a, { modelValue: c } = p(e), o = y(e.modelValue); u(c, (l) => { o.value = l; }), u(o, (l) => { m("update:modelValue", l); }); const f = i( () => typeof e.height == "string" ? e.height : `${e.height}px` ), b = i(() => { const l = {}; return e.height && (l["--v-progress-bar-height"] = f.value), e.bgColor && (l["--v-progress-bar-bg-color"] = e.bgColor), e.fillColor && (l["--v-progress-bar-fill-color"] = e.fillColor), l; }), t = i(() => Math.floor(+o.value / +e.max * 100)); return (l, B) => (h(), S("div", { class: s(["v-progress-bar", [ `v-progress-bar-${a.color}`, `v-progress-bar--${r(t)}`, { "v-progress-bar--indeterminate": a.indeterminate } ]]), role: "progressbar", "aria-valuemin": a.min, "aria-valuemax": a.max, "aria-valuenow": r(t), "aria-labelledby": "progress-label", style: g(r(b)) }, [ n("div", { class: s(["v-progress-bar-label", a.labelClass]), id: "progress-label" }, [ d(l.$slots, "label", { value: r(t) }, () => [ C(V(a.label), 1) ]) ], 2), n("div", { class: s(["v-progress-bar-background", a.bgClass]) }, [ n("div", { style: g({ width: a.indeterminate ? "100%" : r(t) + "%" }), class: s(["v-progress-bar-fill", a.fillClass]) }, [ d(l.$slots, "default", { value: r(t) }) ], 6) ], 2) ], 14, x)); } }); export { $ as VProgressBar, $ as default };