UNPKG

@aplus-frontend/ui

Version:

44 lines (43 loc) 1.55 kB
import { isVNode as c, h as e } from "vue"; import { locales as o } from "./interface.mjs"; const y = (r) => r == null || typeof r == "string" && r.trim() === "", d = (r, t = {}) => typeof r == "string" || typeof r == "number" ? String(r) + JSON.stringify(t) : "complex-value", p = (r, t = { rawValue: !0, precision: 2, thousand: !0, thousandSeparator: ",", currency: "CNY", percent: !1 }) => { if (Object.prototype.toString.call(r) === "[object Null]" || Object.prototype.toString.call(r) === "[object Undefined]" || Object.prototype.toString.call(r) === "[object Object]" || Object.prototype.toString.call(r) === "[object Function]" || r === "") return "--"; if (t.rawValue) return r; if (typeof r == "number") { if (t.percent) return `${r.toFixed(t.precision)}%`; if (t.currency) return r.toLocaleString( o[t.currency ? t.currency : "CNY"], { style: "currency", currency: t.currency ? t.currency : "CNY" } ); if (t.thousand) { const [n, i] = r.toFixed(t.precision ? t.precision : 2).split("."); return `${n.replace( /(\d)(?=(\d{3})+(?!\d))/g, `$1${t.thousandSeparator ? t.thousandSeparator : ","}` )}.${i}`; } return r.toFixed(t.precision ? t.precision : 2); } return r; }, s = (r) => c(r) || typeof r == "function", a = (r) => c(r) ? e(r) : typeof r == "function" ? e(r()) : null; export { p as convertValue, d as createMemoizeKey, y as isNull, s as isVNodeOrFunction, a as renderValue };