adverich-kun-ui 0.1.476 → 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 M, ref as R, computed as h, unref as f, watch as j } from "vue";
1
+ import { reactive as j, ref as S, computed as C, unref as i, watch as d } from "vue";
2
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({
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: m, customFilter: A, searchableKeys: V, headers: k } = S, E = R(!1), y = (e) => {
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,90 +25,86 @@ function N(S, w, b, l = !1) {
25
25
  return "";
26
26
  }
27
27
  }, F = (e, r) => {
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;
28
+ const t = m(e).toLowerCase(), o = m(r).toLowerCase();
29
+ return o ? t ? t.includes(o) : !1 : !0;
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) => {
61
+ var o;
62
+ const t = ((o = y.value.get(e)) == null ? void 0 : o[r]) ?? "";
63
+ return l && console.log("[getDisplayValue]", { item: e, key: r, val: t }), t;
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);
38
68
  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),
53
- (e) => {
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);
63
- },
64
- { immediate: !0, deep: !1 }
65
- );
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);
74
- try {
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;
69
+ return n(e, r, t, s);
70
+ } catch (c) {
71
+ return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: t, header: s, err: c }), !1;
78
72
  }
79
73
  }
80
- return Array.isArray(t) ? t.some((a) => F(o, a)) : F(o, t);
81
- }, L = h(() => {
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)))
74
+ return Array.isArray(t) ? t.some((s) => F(o, s)) : F(o, t);
75
+ }, D = C(() => {
76
+ const e = i(f);
77
+ return Array.isArray(e) ? e.filter((r) => {
78
+ const t = a.search;
79
+ if (t && !g.value.some((s) => R(r, s, t)))
86
80
  return !1;
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;
81
+ for (const o in a.byColumn) {
82
+ const n = a.byColumn[o];
83
+ if (n != null && n !== "" && !R(r, o, n)) return !1;
90
84
  }
91
85
  return !0;
92
86
  }) : [];
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);
87
+ }), I = q((e) => {
88
+ a.search = m(e).toLowerCase(), l && console.log("[setSearch]", a.search);
89
+ }, i(w) ?? 150), K = (e, r) => {
90
+ a.byColumn[e] = r, l && console.log("[setColumnFilter]", e, r);
97
91
  };
98
92
  return {
99
- modalFilter: E,
100
- appliedFilters: c,
101
- filteredItems: L,
102
- setSearch: O,
93
+ modalFilter: L,
94
+ appliedFilters: a,
95
+ filteredItems: D,
96
+ setSearch: I,
103
97
  applyColumnFilters: (e) => {
104
- for (const r in e) D(r, e[r]);
98
+ for (const r in e) K(r, e[r]);
105
99
  l && console.log("[applyColumnFilters]", e);
106
100
  },
107
101
  clearFilters: () => {
108
- c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
109
- }
102
+ a.search = "", a.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
103
+ },
104
+ // 👇 Exponemos también por si querés refrescar manualmente
105
+ refreshCache: p
110
106
  };
111
107
  }
112
108
  export {
113
- N as default
109
+ P as default
114
110
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.476",
3
+ "version": "0.1.477",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",