adverich-kun-ui 0.1.582 → 0.1.584
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.
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as O, formatValue as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
1
|
+
import { reactive as P, ref as b, computed as g, unref as f, watch as S } from "vue";
|
|
2
|
+
import { debounce as z } from "../../../../utils/utils.js";
|
|
3
|
+
import { getValue as O, formatValue as D } from "../../../../utils/tableFormatters.js";
|
|
4
|
+
function Q(F, E, L, i = !1) {
|
|
5
|
+
const u = P({
|
|
6
6
|
search: "",
|
|
7
7
|
// Búsqueda global
|
|
8
8
|
byColumn: {}
|
|
9
9
|
// Mapa columna -> valor
|
|
10
|
-
}), { items:
|
|
10
|
+
}), { items: m, customFilter: M, searchableKeys: j, headers: G } = F, T = b(!1), y = (e) => {
|
|
11
11
|
if (e == null) return "";
|
|
12
12
|
if (typeof e == "string") return e;
|
|
13
13
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
@@ -26,96 +26,105 @@ function U(F, E, L, l = !1) {
|
|
|
26
26
|
} catch {
|
|
27
27
|
return "";
|
|
28
28
|
}
|
|
29
|
-
},
|
|
30
|
-
const
|
|
31
|
-
return t ?
|
|
32
|
-
}, p =
|
|
33
|
-
const e =
|
|
29
|
+
}, w = (e, r) => {
|
|
30
|
+
const o = y(e).toLowerCase(), t = y(r).toLowerCase();
|
|
31
|
+
return t ? o === t : !0;
|
|
32
|
+
}, p = g(() => L.value ?? []), A = g(() => {
|
|
33
|
+
const e = f(j);
|
|
34
34
|
return Array.isArray(e) && e.length ? e : p.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
|
|
35
|
-
}), C =
|
|
36
|
-
function
|
|
35
|
+
}), C = b(/* @__PURE__ */ new Map());
|
|
36
|
+
function R() {
|
|
37
37
|
C.value.clear();
|
|
38
|
-
const e =
|
|
38
|
+
const e = f(m);
|
|
39
39
|
Array.isArray(e) && (e.forEach((r) => {
|
|
40
|
-
const
|
|
40
|
+
const o = {};
|
|
41
41
|
A.value.forEach((t) => {
|
|
42
|
-
const
|
|
43
|
-
let
|
|
42
|
+
const n = p.value.find((l) => l.value === t);
|
|
43
|
+
let s, c;
|
|
44
44
|
try {
|
|
45
|
-
|
|
46
|
-
} catch (
|
|
47
|
-
|
|
45
|
+
s = n ? O(n, r) : r[t];
|
|
46
|
+
} catch (l) {
|
|
47
|
+
s = "", i && console.error("[useFilter] ERROR getValue", { item: r, key: t, err: l });
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
|
|
51
|
-
} catch (
|
|
52
|
-
|
|
50
|
+
c = n ? D(n, s) : s;
|
|
51
|
+
} catch (l) {
|
|
52
|
+
c = s, i && console.error("[useFilter] ERROR formatValue", { header: n, raw: s, err: l });
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
}), C.value.set(r,
|
|
56
|
-
}),
|
|
54
|
+
o[t] = y(c).toLowerCase();
|
|
55
|
+
}), C.value.set(r, o);
|
|
56
|
+
}), i && console.log("[useFilter] Cache reconstruida", C.value));
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
S(() => f(m), () => R(), { immediate: !0 }), S(() => {
|
|
59
59
|
var e;
|
|
60
|
-
return (e =
|
|
61
|
-
}, () =>
|
|
62
|
-
const
|
|
63
|
-
const t =
|
|
64
|
-
if (typeof
|
|
65
|
-
const
|
|
60
|
+
return (e = f(m)) == null ? void 0 : e.length;
|
|
61
|
+
}, () => R());
|
|
62
|
+
const x = (e, r, o) => {
|
|
63
|
+
const t = V(e, r), n = f(M);
|
|
64
|
+
if (typeof n == "function") {
|
|
65
|
+
const a = p.value.find((h) => (h == null ? void 0 : h.value) === r);
|
|
66
66
|
try {
|
|
67
|
-
return
|
|
68
|
-
} catch (
|
|
69
|
-
return
|
|
67
|
+
return n(e, r, o, a);
|
|
68
|
+
} catch (h) {
|
|
69
|
+
return i && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: o, header: a, err: h }), !1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
return Array.isArray(
|
|
74
|
-
},
|
|
75
|
-
const e =
|
|
72
|
+
const s = f(F.filters) ?? F.filters, c = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, l = (c == null ? void 0 : c["item-value"]) ?? "id", d = (a) => a != null && typeof a == "object" ? a[l] : a;
|
|
73
|
+
return Array.isArray(o) ? o.some((a) => w(t, d(a))) : w(t, d(o));
|
|
74
|
+
}, K = g(() => {
|
|
75
|
+
const e = f(m);
|
|
76
76
|
return Array.isArray(e) ? e.filter((r) => {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const t =
|
|
80
|
-
if (t) {
|
|
81
|
-
|
|
82
|
-
|
|
77
|
+
const o = u.search;
|
|
78
|
+
if (o) {
|
|
79
|
+
const t = o.split(/\s+/).filter((n) => n.length > 0);
|
|
80
|
+
if (t.length > 0) {
|
|
81
|
+
const n = C.value.get(r);
|
|
82
|
+
if (n) {
|
|
83
|
+
if (!t.every((c) => Object.values(n).some((l) => l.includes(c)))) return !1;
|
|
84
|
+
} else {
|
|
85
|
+
const s = A.value;
|
|
86
|
+
if (!t.every((l) => s.some((d) => {
|
|
87
|
+
const a = V(r, d);
|
|
88
|
+
return y(a).toLowerCase().includes(l);
|
|
89
|
+
}))) return !1;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
83
92
|
}
|
|
84
|
-
for (const t in
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
93
|
+
for (const t in u.byColumn) {
|
|
94
|
+
const n = u.byColumn[t], s = Array.isArray(n) && n.length === 0;
|
|
95
|
+
if (n != null && n !== "" && !s && !x(r, t, n)) return !1;
|
|
87
96
|
}
|
|
88
97
|
return !0;
|
|
89
98
|
}) : [];
|
|
90
|
-
}),
|
|
91
|
-
|
|
92
|
-
},
|
|
93
|
-
|
|
94
|
-
},
|
|
99
|
+
}), I = z((e) => {
|
|
100
|
+
u.search = y(e).toLowerCase(), i && console.log("[setSearch]", u.search);
|
|
101
|
+
}, f(E) ?? 150), q = (e, r) => {
|
|
102
|
+
u.byColumn[e] = r, i && console.log("[setColumnFilter]", e, r);
|
|
103
|
+
}, v = (e) => {
|
|
95
104
|
for (const r in e) q(r, e[r]);
|
|
96
|
-
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
},
|
|
105
|
+
i && console.log("[applyColumnFilters]", e);
|
|
106
|
+
}, B = () => {
|
|
107
|
+
u.search = "", u.byColumn = {}, i && console.log("[clearFilters] filtros reseteados");
|
|
108
|
+
}, V = (e, r) => {
|
|
100
109
|
if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
|
|
101
|
-
const
|
|
110
|
+
const o = p.value.find((t) => (t == null ? void 0 : t.value) === r);
|
|
102
111
|
try {
|
|
103
|
-
return
|
|
112
|
+
return o ? O(o, e) : e[r];
|
|
104
113
|
} catch (t) {
|
|
105
|
-
return
|
|
114
|
+
return i && console.error("[useFilter] ERROR getRawValue", { item: e, key: r, err: t }), null;
|
|
106
115
|
}
|
|
107
116
|
};
|
|
108
117
|
return {
|
|
109
|
-
modalFilter:
|
|
110
|
-
appliedFilters:
|
|
111
|
-
filteredItems:
|
|
112
|
-
setSearch:
|
|
113
|
-
applyColumnFilters:
|
|
114
|
-
clearFilters:
|
|
118
|
+
modalFilter: T,
|
|
119
|
+
appliedFilters: u,
|
|
120
|
+
filteredItems: K,
|
|
121
|
+
setSearch: I,
|
|
122
|
+
applyColumnFilters: v,
|
|
123
|
+
clearFilters: B,
|
|
115
124
|
// 👇 Exponemos también por si querés refrescar manualmente
|
|
116
|
-
refreshCache:
|
|
125
|
+
refreshCache: R
|
|
117
126
|
};
|
|
118
127
|
}
|
|
119
128
|
export {
|
|
120
|
-
|
|
129
|
+
Q as default
|
|
121
130
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { kunConfig as c } from "../config/kunConfig.js";
|
|
2
|
-
function
|
|
2
|
+
function p(t, n) {
|
|
3
3
|
var e;
|
|
4
4
|
if (!t || !t.value) return;
|
|
5
5
|
if (t.columnType === "relation") {
|
|
6
|
-
const r =
|
|
6
|
+
const r = f(n, t.relationPath);
|
|
7
7
|
return u(r);
|
|
8
8
|
}
|
|
9
9
|
if (t.columnType === "function") {
|
|
@@ -13,7 +13,7 @@ function f(t, n) {
|
|
|
13
13
|
const o = n == null ? void 0 : n[t.value];
|
|
14
14
|
return u(o);
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function g(t, n) {
|
|
17
17
|
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);
|
|
18
18
|
}
|
|
19
19
|
const i = {
|
|
@@ -42,20 +42,20 @@ const i = {
|
|
|
42
42
|
noCeros: (t) => parseFloat(t ?? 0),
|
|
43
43
|
percentage: (t) => `${parseFloat(t ?? 0)}%`,
|
|
44
44
|
date: (t) => {
|
|
45
|
-
var
|
|
46
|
-
if (!t || t === "0000-00-00" || !
|
|
47
|
-
const n = new Date(
|
|
48
|
-
return new Intl.DateTimeFormat(
|
|
45
|
+
var s;
|
|
46
|
+
if (!t || t === "0000-00-00" || !m(t)) return "Nunca";
|
|
47
|
+
const [n, o, e] = t.split("-").map(Number), r = new Date(n, o - 1, e, 12, 0, 0), a = c.current, l = a.locale;
|
|
48
|
+
return new Intl.DateTimeFormat(l, {
|
|
49
49
|
weekday: "short",
|
|
50
50
|
day: "2-digit",
|
|
51
51
|
month: "short",
|
|
52
52
|
year: "2-digit",
|
|
53
|
-
...(
|
|
54
|
-
}).format(
|
|
53
|
+
...(s = a.date) == null ? void 0 : s.dateFormat
|
|
54
|
+
}).format(r);
|
|
55
55
|
},
|
|
56
56
|
dateTime: (t) => {
|
|
57
57
|
var r;
|
|
58
|
-
if (!t || t === "0000-00-00" || !
|
|
58
|
+
if (!t || t === "0000-00-00" || !m(t)) return "Nunca";
|
|
59
59
|
const n = new Date(t), o = c.current, e = o.locale;
|
|
60
60
|
return new Intl.DateTimeFormat(e, {
|
|
61
61
|
weekday: "short",
|
|
@@ -69,12 +69,12 @@ const i = {
|
|
|
69
69
|
...(r = o.date) == null ? void 0 : r.dateTimeFormat
|
|
70
70
|
}).format(n);
|
|
71
71
|
},
|
|
72
|
-
secondsToTime: (t) =>
|
|
72
|
+
secondsToTime: (t) => d(t ?? 0)
|
|
73
73
|
};
|
|
74
|
-
function
|
|
74
|
+
function f(t, n) {
|
|
75
75
|
return !t || !n ? t : n.split(".").reduce((o, e) => o == null ? void 0 : o[e], t);
|
|
76
76
|
}
|
|
77
|
-
function
|
|
77
|
+
function d(t) {
|
|
78
78
|
const n = Math.floor(t / 3600), o = Math.floor(t % 3600 / 60), e = t % 60;
|
|
79
79
|
return `${n} horas, ${o} minutos y ${e} segundos`;
|
|
80
80
|
}
|
|
@@ -82,13 +82,13 @@ function u(t) {
|
|
|
82
82
|
if (t != null && !(t === "null" || t === "undefined"))
|
|
83
83
|
return t;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
85
|
+
function m(t) {
|
|
86
86
|
const n = new Date(t);
|
|
87
87
|
return !isNaN(n.getTime());
|
|
88
88
|
}
|
|
89
89
|
export {
|
|
90
|
-
|
|
90
|
+
g as formatValue,
|
|
91
91
|
i as formatters,
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
f as getNestedValue,
|
|
93
|
+
p as getValue
|
|
94
94
|
};
|