UNPKG

adverich-kun-ui

Version:

Una librería de componentes Vue.js con Tailwind CSS

95 lines (94 loc) 2.77 kB
import { kunConfig as c } from "../config/kunConfig.js"; function f(t, n) { var e; if (!t || !t.value) return; if (t.columnType === "relation") { const r = s(n, t.relationPath); return u(r); } if (t.columnType === "function") { const r = (e = t.columnFunction) == null ? void 0 : e.call(t, n, t); return u(r); } const o = n == null ? void 0 : n[t.value]; return u(o); } function d(t, n) { return t.columnType === "toComplete" ? "" : n == null ? "Sin datos" : t.columnType === "dateTime" || t.columnType === "date" ? (i[t.columnType] || i.default)(n) : (i[t.columnFormat] || i.default)(n); } const i = { default: (t) => t, // TEXTS text: (t) => String(t), activeOrInactive: (t) => t ? "Activa" : "Inactiva", composed: (t) => t, // ya está procesado por getComposedValue // NUMBERS - Usa config global directamente number: (t) => { const n = c.locale; return Number(t).toLocaleString(n); }, money: (t) => { const n = c.current, o = n.locale, e = n.precision, r = n.currency; return new Intl.NumberFormat(o, { style: "currency", currency: r.value, minimumFractionDigits: e, maximumFractionDigits: e }).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) => { var r; if (!t || t === "0000-00-00" || !a(t)) return "Nunca"; const n = new Date(t), o = c.current, e = o.locale; return new Intl.DateTimeFormat(e, { weekday: "short", day: "2-digit", month: "short", year: "2-digit", ...(r = o.date) == null ? void 0 : r.dateFormat }).format(n); }, dateTime: (t) => { var r; if (!t || t === "0000-00-00" || !a(t)) return "Nunca"; const n = new Date(t), o = c.current, e = o.locale; return new Intl.DateTimeFormat(e, { weekday: "short", day: "2-digit", month: "short", year: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23", ...(r = o.date) == null ? void 0 : r.dateTimeFormat }).format(n); }, secondsToTime: (t) => l(t ?? 0) }; function s(t, n) { return !t || !n ? t : n.split(".").reduce((o, e) => o == null ? void 0 : o[e], t); } function l(t) { const n = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), e = t % 60; return `${n} horas, ${o} minutos y ${e} segundos`; } function u(t) { if (t != null && !(t === "null" || t === "undefined")) return t; } function a(t) { const n = new Date(t); return !isNaN(n.getTime()); } export { d as formatValue, i as formatters, s as getNestedValue, f as getValue };