adverich-kun-ui 0.1.588 → 0.1.589
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/utils/tableFormatters.js +61 -58
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { kunConfig as
|
|
2
|
-
import { kunDocumentConfig as
|
|
1
|
+
import { kunConfig as d } from "../config/kunConfig.js";
|
|
2
|
+
import { kunDocumentConfig as m } from "../config/kunDocumentConfig.js";
|
|
3
3
|
const S = {
|
|
4
4
|
doc_ar: {
|
|
5
5
|
cuit: { mask: [2, 8, 1] },
|
|
@@ -69,75 +69,78 @@ const S = {
|
|
|
69
69
|
passaporte: { mask: [1, 8] }
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
-
function
|
|
72
|
+
function h(t) {
|
|
73
73
|
return String(t || "").toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
74
74
|
}
|
|
75
|
-
function
|
|
75
|
+
function T(t, n) {
|
|
76
76
|
let r = "";
|
|
77
77
|
for (let o = 0; o < t.length; o++)
|
|
78
78
|
o > 0 && (t.length - o) % 3 === 0 && (r += n), r += t[o];
|
|
79
79
|
return r;
|
|
80
80
|
}
|
|
81
|
-
function
|
|
81
|
+
function b(t, n, r) {
|
|
82
82
|
let o = "", e = 0;
|
|
83
|
-
for (let
|
|
84
|
-
o += t.substring(e, e + n[
|
|
83
|
+
for (let c = 0; c < n.length && e < t.length; c++)
|
|
84
|
+
o += t.substring(e, e + n[c]), e += n[c], c < n.length - 1 && e < t.length && (o += r ? r[c] ?? "-" : "-");
|
|
85
85
|
return o;
|
|
86
86
|
}
|
|
87
|
-
function
|
|
88
|
-
var
|
|
89
|
-
const o =
|
|
87
|
+
function w(t, n, r) {
|
|
88
|
+
var c;
|
|
89
|
+
const o = h(String(t ?? ""));
|
|
90
90
|
if (!o) return t ?? "";
|
|
91
|
-
const e = (
|
|
92
|
-
return e ? e.rutFormat ? o.length < 2 ? o :
|
|
91
|
+
const e = (c = S[n]) == null ? void 0 : c[r];
|
|
92
|
+
return e ? e.rutFormat ? o.length < 2 ? o : T(o.slice(0, -1), e.thousandsSep || ".") + "-" + o.slice(-1) : e.thousandsSep ? T(o, e.thousandsSep) : e.mask ? b(o, e.mask, e.separators ?? null) : o : o;
|
|
93
93
|
}
|
|
94
|
-
function
|
|
94
|
+
function L(t, n) {
|
|
95
95
|
var o;
|
|
96
96
|
if (!t || !t.value) return;
|
|
97
97
|
if (t.columnType === "relation") {
|
|
98
|
-
const e =
|
|
99
|
-
return
|
|
98
|
+
const e = N(n, t.relationPath);
|
|
99
|
+
return p(e);
|
|
100
100
|
}
|
|
101
101
|
if (t.columnType === "function") {
|
|
102
102
|
const e = (o = t.columnFunction) == null ? void 0 : o.call(t, n, t);
|
|
103
|
-
return
|
|
103
|
+
return p(e);
|
|
104
104
|
}
|
|
105
105
|
const r = n == null ? void 0 : n[t.value];
|
|
106
|
-
return
|
|
106
|
+
return p(r);
|
|
107
107
|
}
|
|
108
|
-
function
|
|
109
|
-
var
|
|
110
|
-
const e =
|
|
111
|
-
if (!e
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
function C(t, n, r, o) {
|
|
109
|
+
var g, y, k, _;
|
|
110
|
+
const e = h(String(t ?? ""));
|
|
111
|
+
if (!e) return e;
|
|
112
|
+
if (!n || !(r != null && r.length))
|
|
113
|
+
return console.warn("[KunTable][doc] sin documentTypeId o documentTypes vacío:", { documentTypeId: n, documentTypesLen: r == null ? void 0 : r.length }), e;
|
|
114
|
+
const c = r.find((a) => a.id == n);
|
|
115
|
+
if (!c)
|
|
116
|
+
return console.warn("[KunTable][doc] no se encontró docType con id:", n, "| disponibles:", r.map((a) => a.id)), e;
|
|
117
|
+
const i = c.country_id ?? ((g = c.country) == null ? void 0 : g.id);
|
|
118
|
+
let s = null;
|
|
119
|
+
if (i && (o != null && o.length)) {
|
|
120
|
+
const a = o.find((D) => D.id == i), f = (a == null ? void 0 : a.iso2) || (a == null ? void 0 : a.iso_code) || (a == null ? void 0 : a.code);
|
|
121
|
+
console.log("[KunTable][doc] country_id:", i, "| country:", a, "| iso2:", f), f && (s = `doc_${f.toLowerCase()}`);
|
|
122
|
+
} else
|
|
123
|
+
console.warn("[KunTable][doc] sin countryId o countries vacío:", { countryId: i, countriesLen: o == null ? void 0 : o.length });
|
|
124
|
+
if (!s) {
|
|
125
|
+
const a = c.country_iso2 || ((y = c.country) == null ? void 0 : y.iso2);
|
|
126
|
+
a && (s = `doc_${a.toLowerCase()}`);
|
|
119
127
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
c && (i = `doc_${c.toLowerCase()}`);
|
|
123
|
-
}
|
|
124
|
-
if (!i) return e;
|
|
125
|
-
const f = ((g = s.short_name) == null ? void 0 : g.toLowerCase()) || ((k = s.name) == null ? void 0 : k.toLowerCase());
|
|
126
|
-
return f ? h(t, i, f) : e;
|
|
128
|
+
const u = ((k = c.short_name) == null ? void 0 : k.toLowerCase()) || ((_ = c.name) == null ? void 0 : _.toLowerCase());
|
|
129
|
+
return console.log("[KunTable][doc] docType:", JSON.stringify(c), "| docCode:", s, "| docFormat:", u, "| value:", t), !s || !u ? e : w(t, s, u);
|
|
127
130
|
}
|
|
128
|
-
function
|
|
129
|
-
var e, s;
|
|
131
|
+
function K(t, n, r = null) {
|
|
132
|
+
var e, c, i, s;
|
|
130
133
|
if (t.columnType === "toComplete") return "";
|
|
131
134
|
if (n == null) return "Sin datos";
|
|
132
135
|
if (t.columnType === "dateTime" || t.columnType === "date")
|
|
133
|
-
return (
|
|
136
|
+
return (l[t.columnType] || l.default)(n);
|
|
134
137
|
if (t.columnType === "document") {
|
|
135
|
-
const
|
|
136
|
-
return
|
|
138
|
+
const u = (r == null ? void 0 : r.document_type_id) ?? ((e = r == null ? void 0 : r.entity) == null ? void 0 : e.document_type_id) ?? null;
|
|
139
|
+
return console.log("[KunTable][doc] formatValue — header.value:", t.value, "| docTypeId:", u, "| value:", n, "| documentTypes len:", (c = m.documentTypes) == null ? void 0 : c.length, "| countries len:", (i = m.countries) == null ? void 0 : i.length), C(n, u, m.documentTypes, m.countries);
|
|
137
140
|
}
|
|
138
|
-
return (s = t.columnType) != null && s.startsWith("doc_") ?
|
|
141
|
+
return (s = t.columnType) != null && s.startsWith("doc_") ? w(n, t.columnType, t.columnFormat) : (l[t.columnFormat] || l.default)(n);
|
|
139
142
|
}
|
|
140
|
-
const
|
|
143
|
+
const l = {
|
|
141
144
|
default: (t) => t,
|
|
142
145
|
// TEXTS
|
|
143
146
|
text: (t) => String(t),
|
|
@@ -146,11 +149,11 @@ const u = {
|
|
|
146
149
|
// ya está procesado por getComposedValue
|
|
147
150
|
// NUMBERS - Usa config global directamente
|
|
148
151
|
number: (t) => {
|
|
149
|
-
const n =
|
|
152
|
+
const n = d.locale;
|
|
150
153
|
return Number(t).toLocaleString(n);
|
|
151
154
|
},
|
|
152
155
|
money: (t) => {
|
|
153
|
-
const n =
|
|
156
|
+
const n = d.current, r = n.locale, o = n.precision, e = n.currency;
|
|
154
157
|
return new Intl.NumberFormat(r, {
|
|
155
158
|
style: "currency",
|
|
156
159
|
currency: e.value,
|
|
@@ -163,21 +166,21 @@ const u = {
|
|
|
163
166
|
noCeros: (t) => parseFloat(t ?? 0),
|
|
164
167
|
percentage: (t) => `${parseFloat(t ?? 0)}%`,
|
|
165
168
|
date: (t) => {
|
|
166
|
-
var
|
|
167
|
-
if (!t || t === "0000-00-00" || !
|
|
168
|
-
const [n, r, o] = t.split("-").map(Number), e = new Date(n, r - 1, o, 12, 0, 0),
|
|
169
|
-
return new Intl.DateTimeFormat(
|
|
169
|
+
var s;
|
|
170
|
+
if (!t || t === "0000-00-00" || !F(t)) return "Nunca";
|
|
171
|
+
const [n, r, o] = t.split("-").map(Number), e = new Date(n, r - 1, o, 12, 0, 0), c = d.current, i = c.locale;
|
|
172
|
+
return new Intl.DateTimeFormat(i, {
|
|
170
173
|
weekday: "short",
|
|
171
174
|
day: "2-digit",
|
|
172
175
|
month: "short",
|
|
173
176
|
year: "2-digit",
|
|
174
|
-
...(
|
|
177
|
+
...(s = c.date) == null ? void 0 : s.dateFormat
|
|
175
178
|
}).format(e);
|
|
176
179
|
},
|
|
177
180
|
dateTime: (t) => {
|
|
178
181
|
var e;
|
|
179
|
-
if (!t || t === "0000-00-00" || !
|
|
180
|
-
const n = new Date(t), r =
|
|
182
|
+
if (!t || t === "0000-00-00" || !F(t)) return "Nunca";
|
|
183
|
+
const n = new Date(t), r = d.current, o = r.locale;
|
|
181
184
|
return new Intl.DateTimeFormat(o, {
|
|
182
185
|
weekday: "short",
|
|
183
186
|
day: "2-digit",
|
|
@@ -192,24 +195,24 @@ const u = {
|
|
|
192
195
|
},
|
|
193
196
|
secondsToTime: (t) => I(t ?? 0)
|
|
194
197
|
};
|
|
195
|
-
function
|
|
198
|
+
function N(t, n) {
|
|
196
199
|
return !t || !n ? t : n.split(".").reduce((r, o) => r == null ? void 0 : r[o], t);
|
|
197
200
|
}
|
|
198
201
|
function I(t) {
|
|
199
202
|
const n = Math.floor(t / 3600), r = Math.floor(t % 3600 / 60), o = t % 60;
|
|
200
203
|
return `${n} horas, ${r} minutos y ${o} segundos`;
|
|
201
204
|
}
|
|
202
|
-
function
|
|
205
|
+
function p(t) {
|
|
203
206
|
if (t != null && !(t === "null" || t === "undefined"))
|
|
204
207
|
return t;
|
|
205
208
|
}
|
|
206
|
-
function
|
|
209
|
+
function F(t) {
|
|
207
210
|
const n = new Date(t);
|
|
208
211
|
return !isNaN(n.getTime());
|
|
209
212
|
}
|
|
210
213
|
export {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
214
|
+
K as formatValue,
|
|
215
|
+
l as formatters,
|
|
216
|
+
N as getNestedValue,
|
|
217
|
+
L as getValue
|
|
215
218
|
};
|