UNPKG

ant-design-x-vue-next

Version:

Ant Design X for Vue — community continuation aligned with @ant-design/x

34 lines (33 loc) 967 B
import { ref as u, watchEffect as c, onWatcherCleanup as d } from "vue"; const p = 200, r = [ [30, 0.05], [70, 0.03], [96, 0.01] ]; function h(a, t) { const o = u(0), i = typeof a == "boolean" ? u(a) : a, e = typeof t == "object" && t !== null && "value" in t ? t : u(t); c(() => { if ((e.value === "auto" || e.value === void 0) && i.value) { o.value = 0; const m = setInterval(() => { o.value = (() => { const l = o.value, A = 100 - l; for (let v = 0; v < r.length; v += 1) { const [P, T] = r[v]; if (l <= P) return l + A * T; } return l; })(); }, p); d(() => clearInterval(m)); } }); const n = u(), s = u("0%"); return c(() => { e.value === "auto" || e.value === void 0 ? (n.value = o.value, s.value = `${o.value.toFixed(0)}%`) : (n.value = e.value, s.value = `${e.value}%`); }), [n, s]; } export { h as default };