adverich-kun-ui 0.1.571 → 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,13 +1,13 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as
|
|
4
|
-
function U(
|
|
5
|
-
const c =
|
|
1
|
+
import { reactive as D, ref as S, computed as R, unref as u, watch as V } from "vue";
|
|
2
|
+
import { debounce as G } from "../../../../utils/utils.js";
|
|
3
|
+
import { getValue as O, formatValue as H } from "../../../../utils/tableFormatters.js";
|
|
4
|
+
function U(F, E, L, l = !1) {
|
|
5
|
+
const c = D({
|
|
6
6
|
search: "",
|
|
7
7
|
// Búsqueda global
|
|
8
8
|
byColumn: {}
|
|
9
9
|
// Mapa columna -> valor
|
|
10
|
-
}), { items: h, customFilter: j, searchableKeys: K, headers:
|
|
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);
|
|
@@ -27,79 +27,80 @@ function U(C, O, L, l = !1) {
|
|
|
27
27
|
return "";
|
|
28
28
|
}
|
|
29
29
|
}, g = (e, r) => {
|
|
30
|
-
const n =
|
|
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
|
-
}),
|
|
36
|
-
function
|
|
37
|
-
|
|
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
|
+
function C() {
|
|
37
|
+
d.value.clear();
|
|
38
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
|
-
s = o ?
|
|
45
|
+
s = o ? O(o, r) : r[t];
|
|
46
46
|
} catch (f) {
|
|
47
47
|
s = "", l && console.error("[useFilter] ERROR getValue", { item: r, key: t, err: f });
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
i = o ?
|
|
50
|
+
i = o ? H(o, s) : s;
|
|
51
51
|
} catch (f) {
|
|
52
52
|
i = s, l && console.error("[useFilter] ERROR formatValue", { header: o, raw: s, err: f });
|
|
53
53
|
}
|
|
54
|
-
n[t] =
|
|
55
|
-
}),
|
|
56
|
-
}), l && console.log("[useFilter] Cache reconstruida",
|
|
54
|
+
n[t] = m(i).toLowerCase();
|
|
55
|
+
}), d.value.set(r, n);
|
|
56
|
+
}), l && console.log("[useFilter] Cache reconstruida", d.value));
|
|
57
57
|
}
|
|
58
|
-
V(() => u(h), () =>
|
|
58
|
+
V(() => u(h), () => C(), { immediate: !0 }), V(() => {
|
|
59
59
|
var e;
|
|
60
60
|
return (e = u(h)) == null ? void 0 : e.length;
|
|
61
|
-
}, () =>
|
|
62
|
-
const
|
|
63
|
-
const t =
|
|
61
|
+
}, () => C());
|
|
62
|
+
const b = (e, r, n) => {
|
|
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(
|
|
73
|
-
return Array.isArray(n) ? n.some((a) => g(t,
|
|
74
|
-
}, I =
|
|
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
|
+
}, I = R(() => {
|
|
75
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
|
}) : [];
|
|
90
|
-
}), q =
|
|
91
|
-
c.search =
|
|
92
|
-
}, u(
|
|
90
|
+
}), q = G((e) => {
|
|
91
|
+
c.search = m(e).toLowerCase(), l && console.log("[setSearch]", c.search);
|
|
92
|
+
}, u(E) ?? 150), B = (e, r) => {
|
|
93
93
|
c.byColumn[e] = r, l && console.log("[setColumnFilter]", e, r);
|
|
94
94
|
}, M = (e) => {
|
|
95
95
|
for (const r in e) B(r, e[r]);
|
|
96
96
|
l && console.log("[applyColumnFilters]", e);
|
|
97
|
-
},
|
|
97
|
+
}, P = () => {
|
|
98
98
|
c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
|
|
99
|
-
},
|
|
100
|
-
|
|
99
|
+
}, z = (e, r) => {
|
|
100
|
+
if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
|
|
101
|
+
const n = p.value.find((t) => (t == null ? void 0 : t.value) === r);
|
|
101
102
|
try {
|
|
102
|
-
return n ?
|
|
103
|
+
return n ? O(n, e) : e[r];
|
|
103
104
|
} catch (t) {
|
|
104
105
|
return l && console.error("[useFilter] ERROR getRawValue", { item: e, key: r, err: t }), null;
|
|
105
106
|
}
|
|
@@ -110,9 +111,9 @@ function U(C, O, L, l = !1) {
|
|
|
110
111
|
filteredItems: I,
|
|
111
112
|
setSearch: q,
|
|
112
113
|
applyColumnFilters: M,
|
|
113
|
-
clearFilters:
|
|
114
|
+
clearFilters: P,
|
|
114
115
|
// 👇 Exponemos también por si querés refrescar manualmente
|
|
115
|
-
refreshCache:
|
|
116
|
+
refreshCache: C
|
|
116
117
|
};
|
|
117
118
|
}
|
|
118
119
|
export {
|