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