adverich-kun-ui 0.1.483 → 0.1.484
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 { computed as k, ref as
|
|
1
|
+
import { computed as k, ref as b, onMounted as g, createBlock as x, createCommentVNode as C, openBlock as d, withCtx as l, createElementVNode as c, createVNode as o, createElementBlock as $, Fragment as N, renderList as h, createTextVNode as V } from "vue";
|
|
2
2
|
import z from "../../../KunDialog/src/components/KunDialog.vue.js";
|
|
3
3
|
import B from "../../../KunRow/src/components/KunRow.vue.js";
|
|
4
4
|
import j from "../../../KunCol/src/components/KunCol.vue.js";
|
|
@@ -18,8 +18,8 @@ const A = { class: "w-full" }, D = { class: "flex justify-end px-1" }, E = { cla
|
|
|
18
18
|
const n = f, i = v, m = k({
|
|
19
19
|
get: () => n.modelValue,
|
|
20
20
|
set: (a) => i("update:modelValue", a)
|
|
21
|
-
}), s =
|
|
22
|
-
|
|
21
|
+
}), s = b({});
|
|
22
|
+
g(() => {
|
|
23
23
|
s.value = { ...n.filters.reduce((a, t) => {
|
|
24
24
|
var _;
|
|
25
25
|
const e = t.key, r = (_ = n.activeFilters) == null ? void 0 : _[e];
|
|
@@ -63,7 +63,7 @@ const A = { class: "w-full" }, D = { class: "flex justify-end px-1" }, E = { cla
|
|
|
63
63
|
]),
|
|
64
64
|
o(B, null, {
|
|
65
65
|
default: l(() => [
|
|
66
|
-
(d(!0), N
|
|
66
|
+
(d(!0), $(N, null, h(f.filters, (e) => (d(), x(j, {
|
|
67
67
|
cols: "4",
|
|
68
68
|
class: "px-2"
|
|
69
69
|
}, {
|
|
@@ -77,9 +77,10 @@ const A = { class: "w-full" }, D = { class: "flex justify-end px-1" }, E = { cla
|
|
|
77
77
|
"item-value": "id",
|
|
78
78
|
"item-title": e.title ?? e.text,
|
|
79
79
|
"item-text": "filter.text",
|
|
80
|
+
label: e.label ?? "",
|
|
80
81
|
"text-no-items": e.textNoItem ?? `No hay ${e.name ?? "elementos"} disponibles`,
|
|
81
82
|
"placeholder-text": e.placeholderText ?? "Seleccionar"
|
|
82
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "items", "item-title", "text-no-items", "placeholder-text"])
|
|
83
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "items", "item-title", "label", "text-no-items", "placeholder-text"])
|
|
83
84
|
]),
|
|
84
85
|
_: 2
|
|
85
86
|
}, 1024))), 256))
|
|
@@ -105,7 +106,7 @@ const A = { class: "w-full" }, D = { class: "flex justify-end px-1" }, E = { cla
|
|
|
105
106
|
])
|
|
106
107
|
]),
|
|
107
108
|
_: 1
|
|
108
|
-
}, 8, ["modelValue"])) :
|
|
109
|
+
}, 8, ["modelValue"])) : C("", !0);
|
|
109
110
|
}
|
|
110
111
|
};
|
|
111
112
|
export {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
1
|
+
import { reactive as G, ref as A, computed as p, unref as i, watch as V } from "vue";
|
|
2
|
+
import { debounce as H } from "../../../../utils/utils.js";
|
|
3
|
+
import { getValue as E, formatValue as J } from "../../../../utils/tableFormatters.js";
|
|
4
|
+
function U(C, L, O, l = !1) {
|
|
5
|
+
const c = G({
|
|
6
6
|
search: "",
|
|
7
7
|
byColumn: {}
|
|
8
|
-
}), { items:
|
|
8
|
+
}), { items: m, customFilter: K, searchableKeys: j, headers: N } = C, x = A(!1), h = (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,87 +24,91 @@ function P(b, w, A, l = !1) {
|
|
|
24
24
|
} catch {
|
|
25
25
|
return "";
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
const e = i(
|
|
32
|
-
return Array.isArray(e) && e.length ? e :
|
|
33
|
-
}),
|
|
34
|
-
function
|
|
35
|
-
|
|
36
|
-
const e = i(
|
|
27
|
+
}, g = (e, r) => {
|
|
28
|
+
const n = h(e).toLowerCase(), t = h(r).toLowerCase();
|
|
29
|
+
return t ? n ? n.includes(t) : !1 : !0;
|
|
30
|
+
}, F = p(() => O.value ?? []), w = p(() => {
|
|
31
|
+
const e = i(j);
|
|
32
|
+
return Array.isArray(e) && e.length ? e : F.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
|
|
33
|
+
}), d = A(/* @__PURE__ */ new Map());
|
|
34
|
+
function R() {
|
|
35
|
+
d.value.clear();
|
|
36
|
+
const e = i(m);
|
|
37
37
|
Array.isArray(e) && (e.forEach((r) => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
let s,
|
|
38
|
+
const n = {};
|
|
39
|
+
w.value.forEach((t) => {
|
|
40
|
+
const o = F.value.find((f) => f.value === t);
|
|
41
|
+
let s, u;
|
|
42
42
|
try {
|
|
43
|
-
s =
|
|
44
|
-
} catch (
|
|
45
|
-
s = "", l && console.error("[useFilter] ERROR getValue", { item: r, key:
|
|
43
|
+
s = o ? E(o, r) : r[t];
|
|
44
|
+
} catch (f) {
|
|
45
|
+
s = "", l && console.error("[useFilter] ERROR getValue", { item: r, key: t, err: f });
|
|
46
46
|
}
|
|
47
47
|
try {
|
|
48
|
-
|
|
49
|
-
} catch (
|
|
50
|
-
|
|
48
|
+
u = o ? J(o, s) : s;
|
|
49
|
+
} catch (f) {
|
|
50
|
+
u = s, l && console.error("[useFilter] ERROR formatValue", { header: o, raw: s, err: f });
|
|
51
51
|
}
|
|
52
|
-
t
|
|
53
|
-
}),
|
|
54
|
-
}), l && console.log("[useFilter] Cache reconstruida",
|
|
52
|
+
n[t] = h(u).toLowerCase();
|
|
53
|
+
}), d.value.set(r, n);
|
|
54
|
+
}), l && console.log("[useFilter] Cache reconstruida", d.value));
|
|
55
55
|
}
|
|
56
|
-
|
|
56
|
+
V(() => i(m), () => R(), { immediate: !0 }), V(() => {
|
|
57
57
|
var e;
|
|
58
|
-
return (e = i(
|
|
59
|
-
}, () =>
|
|
60
|
-
const
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}, R = (e, r, t) => {
|
|
65
|
-
const o = O(e, r), n = i(V);
|
|
66
|
-
if (typeof n == "function") {
|
|
67
|
-
const s = h.value.find((c) => (c == null ? void 0 : c.value) === r);
|
|
58
|
+
return (e = i(m)) == null ? void 0 : e.length;
|
|
59
|
+
}, () => R());
|
|
60
|
+
const S = (e, r, n) => {
|
|
61
|
+
const t = D(e, r), o = i(K);
|
|
62
|
+
if (typeof o == "function") {
|
|
63
|
+
const a = F.value.find((y) => (y == null ? void 0 : y.value) === r);
|
|
68
64
|
try {
|
|
69
|
-
return
|
|
70
|
-
} catch (
|
|
71
|
-
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value:
|
|
65
|
+
return o(e, r, n, a);
|
|
66
|
+
} catch (y) {
|
|
67
|
+
return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: n, header: a, err: y }), !1;
|
|
72
68
|
}
|
|
73
69
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
const s = i(C.filters) ?? C.filters, u = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, f = (u == null ? void 0 : u["item-value"]) ?? "id", b = (a) => a != null && typeof a == "object" ? a[f] : a;
|
|
71
|
+
return Array.isArray(n) ? n.some((a) => g(t, b(a))) : g(t, b(n));
|
|
72
|
+
}, I = p(() => {
|
|
73
|
+
const e = i(m);
|
|
77
74
|
return Array.isArray(e) ? e.filter((r) => {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
75
|
+
const n = c.search;
|
|
76
|
+
if (n && !w.value.some((s) => S(r, s, n)))
|
|
80
77
|
return !1;
|
|
81
|
-
for (const
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
78
|
+
for (const t in c.byColumn) {
|
|
79
|
+
const o = c.byColumn[t];
|
|
80
|
+
if (o != null && o !== "" && !S(r, t, o)) return !1;
|
|
84
81
|
}
|
|
85
82
|
return !0;
|
|
86
83
|
}) : [];
|
|
87
|
-
}),
|
|
88
|
-
|
|
89
|
-
}, i(
|
|
90
|
-
|
|
84
|
+
}), q = H((e) => {
|
|
85
|
+
c.search = h(e).toLowerCase(), l && console.log("[setSearch]", c.search);
|
|
86
|
+
}, i(L) ?? 150), B = (e, r) => {
|
|
87
|
+
c.byColumn[e] = r, l && console.log("[setColumnFilter]", e, r);
|
|
88
|
+
}, M = (e) => {
|
|
89
|
+
for (const r in e) B(r, e[r]);
|
|
90
|
+
l && console.log("[applyColumnFilters]", e);
|
|
91
|
+
}, z = () => {
|
|
92
|
+
c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
|
|
93
|
+
}, D = (e, r) => {
|
|
94
|
+
const n = F.value.find((t) => (t == null ? void 0 : t.value) === r);
|
|
95
|
+
try {
|
|
96
|
+
return n ? E(n, e) : e[r];
|
|
97
|
+
} catch (t) {
|
|
98
|
+
return l && console.error("[useFilter] ERROR getRawValue", { item: e, key: r, err: t }), null;
|
|
99
|
+
}
|
|
91
100
|
};
|
|
92
101
|
return {
|
|
93
|
-
modalFilter:
|
|
94
|
-
appliedFilters:
|
|
95
|
-
filteredItems:
|
|
96
|
-
setSearch:
|
|
97
|
-
applyColumnFilters:
|
|
98
|
-
|
|
99
|
-
l && console.log("[applyColumnFilters]", e);
|
|
100
|
-
},
|
|
101
|
-
clearFilters: () => {
|
|
102
|
-
a.search = "", a.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
|
|
103
|
-
},
|
|
102
|
+
modalFilter: x,
|
|
103
|
+
appliedFilters: c,
|
|
104
|
+
filteredItems: I,
|
|
105
|
+
setSearch: q,
|
|
106
|
+
applyColumnFilters: M,
|
|
107
|
+
clearFilters: z,
|
|
104
108
|
// 👇 Exponemos también por si querés refrescar manualmente
|
|
105
|
-
refreshCache:
|
|
109
|
+
refreshCache: R
|
|
106
110
|
};
|
|
107
111
|
}
|
|
108
112
|
export {
|
|
109
|
-
|
|
113
|
+
U as default
|
|
110
114
|
};
|