@aplus-frontend/ui
Version:
48 lines (47 loc) • 1.38 kB
JavaScript
import { defineComponent as f, toRef as r, computed as a, createElementBlock as d, openBlock as g, normalizeClass as v, unref as n, toDisplayString as _ } from "vue";
import y from "dayjs";
import "../config-provider/index.mjs";
import D from "./style/index.mjs";
import h from "./useTimeAgo.mjs";
import { getTimeAgoStr as B } from "./utils.mjs";
import { useLocale as S } from "../config-provider/hooks/use-locale.mjs";
import { useNamespace as T } from "../config-provider/hooks/use-namespace.mjs";
const Y = ["title"], M = /* @__PURE__ */ f({
name: "TimeAgo",
__name: "index",
props: {
value: {
default: Date.now()
},
title: {
type: [String, Object, Boolean],
default: !0
},
interval: {
type: [Boolean, Number],
default: 1e4
}
},
setup(m) {
const t = m, {
locale: s
} = S(), {
b: l
} = T("time-ago"), i = D("time-ago"), u = h(r(t, "value"), Date.now(), r(t, "interval")), c = a(() => B(u.value, s.value)), p = a(() => {
const e = t.title;
if (e === !1)
return;
if (typeof e == "string")
return e;
const o = e === !0 ? "YYYY-MM-DD HH:mm:ss" : e.format;
return y(t.value).format(o);
});
return (e, o) => (g(), d("span", {
title: p.value,
class: v([n(l)(), n(i)])
}, _(c.value), 11, Y));
}
});
export {
M as default
};