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