adverich-kun-ui 0.1.572 → 0.1.573
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,4 +1,4 @@
|
|
|
1
|
-
import { reactive as D, ref as
|
|
1
|
+
import { reactive as D, ref as S, computed as R, unref as u, watch as V } from "vue";
|
|
2
2
|
import { debounce as G } from "../../../../utils/utils.js";
|
|
3
3
|
import { getValue as O, formatValue as H } from "../../../../utils/tableFormatters.js";
|
|
4
4
|
function U(F, E, L, l = !1) {
|
|
@@ -7,7 +7,7 @@ function U(F, E, L, l = !1) {
|
|
|
7
7
|
// Búsqueda global
|
|
8
8
|
byColumn: {}
|
|
9
9
|
// Mapa columna -> valor
|
|
10
|
-
}), { items:
|
|
10
|
+
}), { items: h, customFilter: j, searchableKeys: K, headers: J } = F, x = S(!1), m = (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,20 +26,20 @@ function U(F, E, L, l = !1) {
|
|
|
26
26
|
} catch {
|
|
27
27
|
return "";
|
|
28
28
|
}
|
|
29
|
-
},
|
|
29
|
+
}, g = (e, r) => {
|
|
30
30
|
const n = m(e).toLowerCase(), t = m(r).toLowerCase();
|
|
31
31
|
return t ? n ? n.includes(t) : !1 : !0;
|
|
32
|
-
},
|
|
32
|
+
}, p = R(() => L.value ?? []), A = R(() => {
|
|
33
33
|
const e = u(K);
|
|
34
|
-
return Array.isArray(e) && e.length ? e :
|
|
35
|
-
}),
|
|
34
|
+
return Array.isArray(e) && e.length ? e : p.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
|
|
35
|
+
}), d = S(/* @__PURE__ */ new Map());
|
|
36
36
|
function C() {
|
|
37
|
-
|
|
38
|
-
const e = u(
|
|
37
|
+
d.value.clear();
|
|
38
|
+
const e = u(h);
|
|
39
39
|
Array.isArray(e) && (e.forEach((r) => {
|
|
40
40
|
const n = {};
|
|
41
|
-
|
|
42
|
-
const o =
|
|
41
|
+
A.value.forEach((t) => {
|
|
42
|
+
const o = p.value.find((f) => f.value === t);
|
|
43
43
|
let s, i;
|
|
44
44
|
try {
|
|
45
45
|
s = o ? O(o, r) : r[t];
|
|
@@ -52,38 +52,38 @@ function U(F, E, L, l = !1) {
|
|
|
52
52
|
i = s, l && console.error("[useFilter] ERROR formatValue", { header: o, raw: s, err: f });
|
|
53
53
|
}
|
|
54
54
|
n[t] = m(i).toLowerCase();
|
|
55
|
-
}),
|
|
56
|
-
}), l && console.log("[useFilter] Cache reconstruida",
|
|
55
|
+
}), d.value.set(r, n);
|
|
56
|
+
}), l && console.log("[useFilter] Cache reconstruida", d.value));
|
|
57
57
|
}
|
|
58
|
-
V(() => u(
|
|
58
|
+
V(() => u(h), () => C(), { immediate: !0 }), V(() => {
|
|
59
59
|
var e;
|
|
60
|
-
return (e = u(
|
|
60
|
+
return (e = u(h)) == null ? void 0 : e.length;
|
|
61
61
|
}, () => C());
|
|
62
|
-
const
|
|
62
|
+
const b = (e, r, n) => {
|
|
63
63
|
const t = z(e, r), o = u(j);
|
|
64
64
|
if (typeof o == "function") {
|
|
65
|
-
const a =
|
|
65
|
+
const a = p.value.find((y) => (y == null ? void 0 : y.value) === r);
|
|
66
66
|
try {
|
|
67
67
|
return o(e, r, n, a);
|
|
68
|
-
} catch (
|
|
69
|
-
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: n, header: a, err:
|
|
68
|
+
} catch (y) {
|
|
69
|
+
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: n, header: a, err: y }), !1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const s = u(F.filters) ?? F.filters, i = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, f = (i == null ? void 0 : i["item-value"]) ?? "id",
|
|
73
|
-
return Array.isArray(n) ? n.some((a) =>
|
|
72
|
+
const s = u(F.filters) ?? F.filters, i = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, f = (i == null ? void 0 : i["item-value"]) ?? "id", w = (a) => a != null && typeof a == "object" ? a[f] : a;
|
|
73
|
+
return Array.isArray(n) ? n.some((a) => g(t, w(a))) : g(t, w(n));
|
|
74
74
|
}, I = R(() => {
|
|
75
|
-
const e = u(
|
|
75
|
+
const e = u(h);
|
|
76
76
|
return Array.isArray(e) ? e.filter((r) => {
|
|
77
77
|
const n = c.search;
|
|
78
78
|
if (n) {
|
|
79
|
-
const t =
|
|
79
|
+
const t = d.value.get(r);
|
|
80
80
|
if (t) {
|
|
81
81
|
if (!Object.values(t).some((s) => s.includes(n))) return !1;
|
|
82
|
-
} else if (!
|
|
82
|
+
} else if (!A.value.some((i) => b(r, i, n))) return !1;
|
|
83
83
|
}
|
|
84
84
|
for (const t in c.byColumn) {
|
|
85
|
-
const o = c.byColumn[t];
|
|
86
|
-
if (o != null && o !== "" && !
|
|
85
|
+
const o = c.byColumn[t], s = Array.isArray(o) && o.length === 0;
|
|
86
|
+
if (o != null && o !== "" && !s && !b(r, t, o)) return !1;
|
|
87
87
|
}
|
|
88
88
|
return !0;
|
|
89
89
|
}) : [];
|
|
@@ -98,7 +98,7 @@ function U(F, E, L, l = !1) {
|
|
|
98
98
|
c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
|
|
99
99
|
}, z = (e, r) => {
|
|
100
100
|
if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
|
|
101
|
-
const n =
|
|
101
|
+
const n = p.value.find((t) => (t == null ? void 0 : t.value) === r);
|
|
102
102
|
try {
|
|
103
103
|
return n ? O(n, e) : e[r];
|
|
104
104
|
} catch (t) {
|