b3389cb126c32041bde3ffd2480fca126edb52ced6068e04395fe55e045a7297476b074fd5cfba24314423cd8b9dc5f9f9da2f4fd46a618d742fed8622d811 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { defineComponent, computed, openBlock, createElementBlock, normalizeClass, unref, renderSlot, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, normalizeStyle } from 'vue';
  2. import { statisticProps } from './statistic.mjs';
  3. import _export_sfc from '../../../_virtual/plugin-vue_export-helper.mjs';
  4. import { useNamespace } from '../../../hooks/use-namespace/index.mjs';
  5. import { isFunction } from '@vue/shared';
  6. import { isNumber } from '../../../utils/types.mjs';
  7. const __default__ = defineComponent({
  8. name: "ElStatistic"
  9. });
  10. const _sfc_main = /* @__PURE__ */ defineComponent({
  11. ...__default__,
  12. props: statisticProps,
  13. setup(__props, { expose }) {
  14. const props = __props;
  15. const ns = useNamespace("statistic");
  16. const displayValue = computed(() => {
  17. const { value, formatter, precision, decimalSeparator, groupSeparator } = props;
  18. if (isFunction(formatter))
  19. return formatter(value);
  20. if (!isNumber(value) || Number.isNaN(value))
  21. return value;
  22. let [integer, decimal = ""] = String(value).split(".");
  23. decimal = decimal.padEnd(precision, "0").slice(0, precision > 0 ? precision : 0);
  24. integer = integer.replace(/\B(?=(\d{3})+(?!\d))/g, groupSeparator);
  25. return [integer, decimal].join(decimal ? decimalSeparator : "");
  26. });
  27. expose({
  28. displayValue
  29. });
  30. return (_ctx, _cache) => {
  31. return openBlock(), createElementBlock("div", {
  32. class: normalizeClass(unref(ns).b())
  33. }, [
  34. _ctx.$slots.title || _ctx.title ? (openBlock(), createElementBlock("div", {
  35. key: 0,
  36. class: normalizeClass(unref(ns).e("head"))
  37. }, [
  38. renderSlot(_ctx.$slots, "title", {}, () => [
  39. createTextVNode(toDisplayString(_ctx.title), 1)
  40. ])
  41. ], 2)) : createCommentVNode("v-if", true),
  42. createElementVNode("div", {
  43. class: normalizeClass(unref(ns).e("content"))
  44. }, [
  45. _ctx.$slots.prefix || _ctx.prefix ? (openBlock(), createElementBlock("div", {
  46. key: 0,
  47. class: normalizeClass(unref(ns).e("prefix"))
  48. }, [
  49. renderSlot(_ctx.$slots, "prefix", {}, () => [
  50. createElementVNode("span", null, toDisplayString(_ctx.prefix), 1)
  51. ])
  52. ], 2)) : createCommentVNode("v-if", true),
  53. createElementVNode("span", {
  54. class: normalizeClass(unref(ns).e("number")),
  55. style: normalizeStyle(_ctx.valueStyle)
  56. }, toDisplayString(unref(displayValue)), 7),
  57. _ctx.$slots.suffix || _ctx.suffix ? (openBlock(), createElementBlock("div", {
  58. key: 1,
  59. class: normalizeClass(unref(ns).e("suffix"))
  60. }, [
  61. renderSlot(_ctx.$slots, "suffix", {}, () => [
  62. createElementVNode("span", null, toDisplayString(_ctx.suffix), 1)
  63. ])
  64. ], 2)) : createCommentVNode("v-if", true)
  65. ], 2)
  66. ], 2);
  67. };
  68. }
  69. });
  70. var Statistic = /* @__PURE__ */ _export_sfc(_sfc_main, [["__file", "statistic.vue"]]);
  71. export { Statistic as default };
  72. //# sourceMappingURL=statistic2.mjs.map