| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275 |
- import { g as j, m as M, d as p, r as O, u as A, _ as y, i as N, bn as U, dS as $, f as B, bm as P, bp as _, o as L } from "./index2.js";
- import { createVNode as m, defineComponent as R, ref as D, onMounted as V, onUpdated as X, onBeforeUnmount as Y } from "vue";
- import { S as q } from "./index18.js";
- const z = (t) => {
- const {
- value: n,
- formatter: e,
- precision: a,
- decimalSeparator: s,
- groupSeparator: u = "",
- prefixCls: r
- } = t;
- let c;
- if (typeof e == "function")
- c = e({
- value: n
- });
- else {
- const i = String(n), f = i.match(/^(-?)(\d*)(\.(\d+))?$/);
- if (!f)
- c = i;
- else {
- const d = f[1];
- let o = f[2] || "0", l = f[4] || "";
- o = o.replace(/\B(?=(\d{3})+(?!\d))/g, u), typeof a == "number" && (l = l.padEnd(a, "0").slice(0, a > 0 ? a : 0)), l && (l = `${s}${l}`), c = [m("span", {
- key: "int",
- class: `${r}-content-value-int`
- }, [d, o]), l && m("span", {
- key: "decimal",
- class: `${r}-content-value-decimal`
- }, [l])];
- }
- }
- return m("span", {
- class: `${r}-content-value`
- }, [c]);
- };
- z.displayName = "StatisticNumber";
- const G = (t) => {
- const {
- componentCls: n,
- marginXXS: e,
- padding: a,
- colorTextDescription: s,
- statisticTitleFontSize: u,
- colorTextHeading: r,
- statisticContentFontSize: c,
- statisticFontFamily: i
- } = t;
- return {
- [`${n}`]: p(p({}, O(t)), {
- [`${n}-title`]: {
- marginBottom: e,
- color: s,
- fontSize: u
- },
- [`${n}-skeleton`]: {
- paddingTop: a
- },
- [`${n}-content`]: {
- color: r,
- fontSize: c,
- fontFamily: i,
- [`${n}-content-value`]: {
- display: "inline-block",
- direction: "ltr"
- },
- [`${n}-content-prefix, ${n}-content-suffix`]: {
- display: "inline-block"
- },
- [`${n}-content-prefix`]: {
- marginInlineEnd: e
- },
- [`${n}-content-suffix`]: {
- marginInlineStart: e
- }
- }
- })
- };
- }, J = j("Statistic", (t) => {
- const {
- fontSizeHeading3: n,
- fontSize: e,
- fontFamily: a
- } = t, s = M(t, {
- statisticTitleFontSize: e,
- statisticContentFontSize: n,
- statisticFontFamily: a
- });
- return [G(s)];
- }), E = () => ({
- prefixCls: String,
- decimalSeparator: String,
- groupSeparator: String,
- format: String,
- value: _([Number, String, Object]),
- valueStyle: {
- type: Object,
- default: void 0
- },
- valueRender: P(),
- formatter: B(),
- precision: Number,
- prefix: $(),
- suffix: $(),
- title: $(),
- loading: U()
- }), v = R({
- compatConfig: {
- MODE: 3
- },
- name: "AStatistic",
- inheritAttrs: !1,
- props: N(E(), {
- decimalSeparator: ".",
- groupSeparator: ",",
- loading: !1
- }),
- slots: Object,
- setup(t, n) {
- let {
- slots: e,
- attrs: a
- } = n;
- const {
- prefixCls: s,
- direction: u
- } = A("statistic", t), [r, c] = J(s);
- return () => {
- var i, f, d, o, l, S, g;
- const {
- value: H = 0,
- valueStyle: I,
- valueRender: T
- } = t, x = s.value, b = (i = t.title) !== null && i !== void 0 ? i : (f = e.title) === null || f === void 0 ? void 0 : f.call(e), h = (d = t.prefix) !== null && d !== void 0 ? d : (o = e.prefix) === null || o === void 0 ? void 0 : o.call(e), F = (l = t.suffix) !== null && l !== void 0 ? l : (S = e.suffix) === null || S === void 0 ? void 0 : S.call(e), k = (g = t.formatter) !== null && g !== void 0 ? g : e.formatter;
- let C = m(z, y({
- "data-for-update": Date.now()
- }, p(p({}, t), {
- prefixCls: x,
- value: H,
- formatter: k
- })), null);
- return T && (C = T(C)), r(m("div", y(y({}, a), {}, {
- class: [x, {
- [`${x}-rtl`]: u.value === "rtl"
- }, a.class, c.value]
- }), [b && m("div", {
- class: `${x}-title`
- }, [b]), m(q, {
- paragraph: !1,
- loading: t.loading
- }, {
- default: () => [m("div", {
- style: I,
- class: `${x}-content`
- }, [h && m("span", {
- class: `${x}-content-prefix`
- }, [h]), C, F && m("span", {
- class: `${x}-content-suffix`
- }, [F])])]
- })]));
- };
- }
- }), K = [
- ["Y", 1e3 * 60 * 60 * 24 * 365],
- ["M", 1e3 * 60 * 60 * 24 * 30],
- ["D", 1e3 * 60 * 60 * 24],
- ["H", 1e3 * 60 * 60],
- ["m", 1e3 * 60],
- ["s", 1e3],
- ["S", 1]
- // million seconds
- ];
- function Q(t, n) {
- let e = t;
- const a = /\[[^\]]*]/g, s = (n.match(a) || []).map((i) => i.slice(1, -1)), u = n.replace(a, "[]"), r = K.reduce((i, f) => {
- let [d, o] = f;
- if (i.includes(d)) {
- const l = Math.floor(e / o);
- return e -= l * o, i.replace(new RegExp(`${d}+`, "g"), (S) => {
- const g = S.length;
- return l.toString().padStart(g, "0");
- });
- }
- return i;
- }, u);
- let c = 0;
- return r.replace(a, () => {
- const i = s[c];
- return c += 1, i;
- });
- }
- function W(t, n) {
- const {
- format: e = ""
- } = n, a = new Date(t).getTime(), s = Date.now(), u = Math.max(a - s, 0);
- return Q(u, e);
- }
- const Z = 1e3 / 30;
- function w(t) {
- return new Date(t).getTime();
- }
- const tt = () => p(p({}, E()), {
- value: _([Number, String, Object]),
- format: String,
- onFinish: Function,
- onChange: Function
- }), et = R({
- compatConfig: {
- MODE: 3
- },
- name: "AStatisticCountdown",
- props: N(tt(), {
- format: "HH:mm:ss"
- }),
- // emits: ['finish', 'change'],
- setup(t, n) {
- let {
- emit: e,
- slots: a
- } = n;
- const s = D(), u = D(), r = () => {
- const {
- value: o
- } = t;
- w(o) >= Date.now() ? c() : i();
- }, c = () => {
- if (s.value) return;
- const o = w(t.value);
- s.value = setInterval(() => {
- u.value.$forceUpdate(), o > Date.now() && e("change", o - Date.now()), r();
- }, Z);
- }, i = () => {
- const {
- value: o
- } = t;
- s.value && (clearInterval(s.value), s.value = void 0, w(o) < Date.now() && e("finish"));
- }, f = (o) => {
- let {
- value: l,
- config: S
- } = o;
- const {
- format: g
- } = t;
- return W(l, p(p({}, S), {
- format: g
- }));
- }, d = (o) => o;
- return V(() => {
- r();
- }), X(() => {
- r();
- }), Y(() => {
- i();
- }), () => {
- const o = t.value;
- return m(v, y({
- ref: u
- }, p(p({}, L(t, ["onFinish", "onChange"])), {
- value: o,
- valueRender: d,
- formatter: f
- })), a);
- };
- }
- });
- v.Countdown = et;
- v.install = function(t) {
- return t.component(v.name, v), t.component(v.Countdown.name, v.Countdown), t;
- };
- const it = v.Countdown;
- export {
- it as S
- };
|