adverich-kun-ui 0.1.475 → 0.1.476
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,11 +1,11 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as
|
|
4
|
-
function N(S,
|
|
5
|
-
const
|
|
1
|
+
import { reactive as M, ref as R, computed as h, unref as f, watch as j } from "vue";
|
|
2
|
+
import { debounce as q } from "../../../../utils/utils.js";
|
|
3
|
+
import { getValue as z, formatValue as B } from "../../../../utils/tableFormatters.js";
|
|
4
|
+
function N(S, w, b, l = !1) {
|
|
5
|
+
const c = M({
|
|
6
6
|
search: "",
|
|
7
7
|
byColumn: {}
|
|
8
|
-
}), { items:
|
|
8
|
+
}), { items: m, customFilter: A, searchableKeys: V, headers: k } = S, E = R(!1), y = (e) => {
|
|
9
9
|
if (e == null) return "";
|
|
10
10
|
if (typeof e == "string") return e;
|
|
11
11
|
if (typeof e == "number" || typeof e == "boolean") return String(e);
|
|
@@ -25,74 +25,79 @@ function N(S, d, b, l = !1) {
|
|
|
25
25
|
return "";
|
|
26
26
|
}
|
|
27
27
|
}, F = (e, r) => {
|
|
28
|
-
const t =
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
const e =
|
|
32
|
-
return Array.isArray(e) && e.length ? e :
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
() => {
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
const t = y(e).toLowerCase(), n = y(r).toLowerCase();
|
|
29
|
+
return n ? t ? t.includes(n) : !1 : !0;
|
|
30
|
+
}, p = h(() => b.value ?? []), C = h(() => {
|
|
31
|
+
const e = f(V);
|
|
32
|
+
return Array.isArray(e) && e.length ? e : p.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
|
|
33
|
+
}), i = R(/* @__PURE__ */ new Map()), g = (e, r) => (e == null ? void 0 : e.id) ?? r, I = (e) => {
|
|
34
|
+
const r = {};
|
|
35
|
+
return C.value.forEach((t) => {
|
|
36
|
+
const n = p.value.find((a) => a.value === t);
|
|
37
|
+
let o, s;
|
|
38
|
+
try {
|
|
39
|
+
o = n ? z(n, e) : e[t];
|
|
40
|
+
} catch (a) {
|
|
41
|
+
o = "", l && console.error("[useFilter] ERROR getValue", { item: e, key: t, err: a });
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
s = n ? B(n, o) : o;
|
|
45
|
+
} catch (a) {
|
|
46
|
+
s = o, l && console.error("[useFilter] ERROR formatValue", { header: n, raw: o, err: a });
|
|
47
|
+
}
|
|
48
|
+
r[t] = y(s).toLowerCase();
|
|
49
|
+
}), r;
|
|
50
|
+
};
|
|
51
|
+
j(
|
|
52
|
+
() => f(m),
|
|
39
53
|
(e) => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
try {
|
|
51
|
-
c = n ? x(n, s) : s;
|
|
52
|
-
} catch (i) {
|
|
53
|
-
c = s, l && console.error("[useFilter] ERROR formatValue", { header: n, raw: s, err: i });
|
|
54
|
-
}
|
|
55
|
-
t[o] = u(c).toLowerCase();
|
|
56
|
-
}), f.value.set(r, t);
|
|
57
|
-
}), l && console.log("[useFilter] Cache reconstruida", f.value));
|
|
54
|
+
if (!Array.isArray(e)) {
|
|
55
|
+
i.value.clear();
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
const r = /* @__PURE__ */ new Map();
|
|
59
|
+
e.forEach((t, n) => {
|
|
60
|
+
const o = g(t, n);
|
|
61
|
+
i.value.has(o) ? r.set(o, i.value.get(o)) : r.set(o, I(t));
|
|
62
|
+
}), i.value = r, l && console.log("[useFilter] Cache actualizado", i.value);
|
|
58
63
|
},
|
|
59
64
|
{ immediate: !0, deep: !1 }
|
|
60
65
|
);
|
|
61
|
-
const
|
|
62
|
-
var
|
|
63
|
-
const t = ((
|
|
64
|
-
return l && console.log("[getDisplayValue]", { item: e, key: r, val:
|
|
65
|
-
},
|
|
66
|
-
const o =
|
|
67
|
-
if (typeof
|
|
68
|
-
const
|
|
66
|
+
const K = (e, r, t = 0) => {
|
|
67
|
+
var s;
|
|
68
|
+
const n = g(e, t), o = ((s = i.value.get(n)) == null ? void 0 : s[r]) ?? "";
|
|
69
|
+
return l && console.log("[getDisplayValue]", { item: e, key: r, val: o }), o;
|
|
70
|
+
}, d = (e, r, t, n = 0) => {
|
|
71
|
+
const o = K(e, r, n), s = f(A);
|
|
72
|
+
if (typeof s == "function") {
|
|
73
|
+
const a = p.value.find((u) => (u == null ? void 0 : u.value) === r);
|
|
69
74
|
try {
|
|
70
|
-
return
|
|
71
|
-
} catch (
|
|
72
|
-
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: t, header:
|
|
75
|
+
return s(e, r, t, a);
|
|
76
|
+
} catch (u) {
|
|
77
|
+
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: t, header: a, err: u }), !1;
|
|
73
78
|
}
|
|
74
79
|
}
|
|
75
|
-
return Array.isArray(t) ? t.some((
|
|
80
|
+
return Array.isArray(t) ? t.some((a) => F(o, a)) : F(o, t);
|
|
76
81
|
}, L = h(() => {
|
|
77
|
-
const e =
|
|
78
|
-
return Array.isArray(e) ? e.filter((r) => {
|
|
79
|
-
const
|
|
80
|
-
if (
|
|
82
|
+
const e = f(m);
|
|
83
|
+
return Array.isArray(e) ? e.filter((r, t) => {
|
|
84
|
+
const n = c.search;
|
|
85
|
+
if (n && !C.value.some((a) => d(r, a, n, t)))
|
|
81
86
|
return !1;
|
|
82
|
-
for (const o in
|
|
83
|
-
const
|
|
84
|
-
if (
|
|
87
|
+
for (const o in c.byColumn) {
|
|
88
|
+
const s = c.byColumn[o];
|
|
89
|
+
if (s != null && s !== "" && !d(r, o, s, t)) return !1;
|
|
85
90
|
}
|
|
86
91
|
return !0;
|
|
87
92
|
}) : [];
|
|
88
|
-
}), O =
|
|
89
|
-
|
|
90
|
-
},
|
|
91
|
-
|
|
93
|
+
}), O = q((e) => {
|
|
94
|
+
c.search = y(e).toLowerCase(), l && console.log("[setSearch]", c.search);
|
|
95
|
+
}, f(w) ?? 150), D = (e, r) => {
|
|
96
|
+
c.byColumn[e] = r, l && console.log("[setColumnFilter]", e, r);
|
|
92
97
|
};
|
|
93
98
|
return {
|
|
94
|
-
modalFilter:
|
|
95
|
-
appliedFilters:
|
|
99
|
+
modalFilter: E,
|
|
100
|
+
appliedFilters: c,
|
|
96
101
|
filteredItems: L,
|
|
97
102
|
setSearch: O,
|
|
98
103
|
applyColumnFilters: (e) => {
|
|
@@ -100,7 +105,7 @@ function N(S, d, b, l = !1) {
|
|
|
100
105
|
l && console.log("[applyColumnFilters]", e);
|
|
101
106
|
},
|
|
102
107
|
clearFilters: () => {
|
|
103
|
-
|
|
108
|
+
c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
|
|
104
109
|
}
|
|
105
110
|
};
|
|
106
111
|
}
|