adverich-kun-ui
Version:
Una librería de componentes Vue.js con Tailwind CSS
87 lines (86 loc) • 2.47 kB
JavaScript
function a(t, n) {
var r, c;
if (!t || !t.value) return;
if (t.columnType === "relation") {
const i = f(n, t.relationPath);
return u(i);
}
if (t.columnType === "function") {
const i = (r = t.columnFunction) == null ? void 0 : r.call(t, n, t);
return u(i);
}
if (t.columnFormat === "function") {
const i = (c = t.columnFunction) == null ? void 0 : c.call(t, n, t);
return u(i);
}
const o = n == null ? void 0 : n[t.value];
return u(o);
}
function l(t, n) {
return t.columnType === "toComplete" ? "" : n == null ? "Sin datos" : t.columnType === "dateTime" || t.columnType === "date" ? (e[t.columnType] || e.default)(n) : (e[t.columnFormat] || e.default)(n);
}
const e = {
default: (t) => t,
// TEXTS
text: (t) => String(t),
activeOrInactive: (t) => t ? "Activa" : "Inactiva",
composed: (t) => t,
// ya está procesado por getComposedValue
// NUMBERS
number: (t) => Number(t).toLocaleString("es-AR"),
money: (t) => new Intl.NumberFormat("es-CL", {
style: "currency",
currency: "CLP",
minimumFractionDigits: 2
}).format(t ?? 0),
noDecimal: (t) => parseFloat(t ?? 0).toFixed(0),
withDecimals: (t, n = 2) => parseFloat(t ?? 0).toFixed(n),
noCeros: (t) => parseFloat(t ?? 0),
percentage: (t) => `${parseFloat(t ?? 0)}%`,
date: (t) => {
if (!t || t === "0000-00-00" || !s(t)) return "Nunca";
const n = new Date(t);
return new Intl.DateTimeFormat("es-MX", {
weekday: "short",
day: "2-digit",
month: "short",
year: "2-digit"
}).format(n);
},
dateTime: (t) => {
if (!t || t === "0000-00-00" || !s(t)) return "Nunca";
const n = new Date(t);
return new Intl.DateTimeFormat("es-AR", {
weekday: "short",
day: "2-digit",
month: "short",
year: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit",
hourCycle: "h24"
}).format(n);
},
secondsToTime: (t) => m(t ?? 0)
};
function f(t, n) {
return !t || !n ? t : n.split(".").reduce((o, r) => o == null ? void 0 : o[r], t);
}
function m(t) {
const n = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), r = t % 60;
return `${n} horas, ${o} minutos y ${r} segundos`;
}
function u(t) {
if (t != null && !(t === "null" || t === "undefined"))
return t;
}
function s(t) {
const n = new Date(t);
return !isNaN(n.getTime());
}
export {
l as formatValue,
e as formatters,
f as getNestedValue,
a as getValue
};