adverich-kun-ui 0.1.571 → 0.1.573

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,13 +1,13 @@
1
- import { reactive as G, ref as A, computed as p, unref as u, 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, O, L, l = !1) {
5
- const c = G({
1
+ import { reactive as D, ref as S, computed as R, unref as u, watch as V } from "vue";
2
+ import { debounce as G } from "../../../../utils/utils.js";
3
+ import { getValue as O, formatValue as H } from "../../../../utils/tableFormatters.js";
4
+ function U(F, E, L, l = !1) {
5
+ const c = D({
6
6
  search: "",
7
7
  // Búsqueda global
8
8
  byColumn: {}
9
9
  // Mapa columna -> valor
10
- }), { items: h, customFilter: j, searchableKeys: K, headers: N } = C, x = A(!1), y = (e) => {
10
+ }), { items: h, customFilter: j, searchableKeys: K, headers: J } = F, x = S(!1), m = (e) => {
11
11
  if (e == null) return "";
12
12
  if (typeof e == "string") return e;
13
13
  if (typeof e == "number" || typeof e == "boolean") return String(e);
@@ -27,79 +27,80 @@ function U(C, O, L, l = !1) {
27
27
  return "";
28
28
  }
29
29
  }, g = (e, r) => {
30
- const n = y(e).toLowerCase(), t = y(r).toLowerCase();
30
+ const n = m(e).toLowerCase(), t = m(r).toLowerCase();
31
31
  return t ? n ? n.includes(t) : !1 : !0;
32
- }, d = p(() => L.value ?? []), b = p(() => {
32
+ }, p = R(() => L.value ?? []), A = R(() => {
33
33
  const e = u(K);
34
- return Array.isArray(e) && e.length ? e : d.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
35
- }), F = A(/* @__PURE__ */ new Map());
36
- function R() {
37
- F.value.clear();
34
+ return Array.isArray(e) && e.length ? e : p.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
35
+ }), d = S(/* @__PURE__ */ new Map());
36
+ function C() {
37
+ d.value.clear();
38
38
  const e = u(h);
39
39
  Array.isArray(e) && (e.forEach((r) => {
40
40
  const n = {};
41
- b.value.forEach((t) => {
42
- const o = d.value.find((f) => f.value === t);
41
+ A.value.forEach((t) => {
42
+ const o = p.value.find((f) => f.value === t);
43
43
  let s, i;
44
44
  try {
45
- s = o ? E(o, r) : r[t];
45
+ s = o ? O(o, r) : r[t];
46
46
  } catch (f) {
47
47
  s = "", l && console.error("[useFilter] ERROR getValue", { item: r, key: t, err: f });
48
48
  }
49
49
  try {
50
- i = o ? J(o, s) : s;
50
+ i = o ? H(o, s) : s;
51
51
  } catch (f) {
52
52
  i = s, l && console.error("[useFilter] ERROR formatValue", { header: o, raw: s, err: f });
53
53
  }
54
- n[t] = y(i).toLowerCase();
55
- }), F.value.set(r, n);
56
- }), l && console.log("[useFilter] Cache reconstruida", F.value));
54
+ n[t] = m(i).toLowerCase();
55
+ }), d.value.set(r, n);
56
+ }), l && console.log("[useFilter] Cache reconstruida", d.value));
57
57
  }
58
- V(() => u(h), () => R(), { immediate: !0 }), V(() => {
58
+ V(() => u(h), () => C(), { immediate: !0 }), V(() => {
59
59
  var e;
60
60
  return (e = u(h)) == null ? void 0 : e.length;
61
- }, () => R());
62
- const w = (e, r, n) => {
63
- const t = D(e, r), o = u(j);
61
+ }, () => C());
62
+ const b = (e, r, n) => {
63
+ const t = z(e, r), o = u(j);
64
64
  if (typeof o == "function") {
65
- const a = d.value.find((m) => (m == null ? void 0 : m.value) === r);
65
+ const a = p.value.find((y) => (y == null ? void 0 : y.value) === r);
66
66
  try {
67
67
  return o(e, r, n, a);
68
- } catch (m) {
69
- return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: n, header: a, err: m }), !1;
68
+ } catch (y) {
69
+ return l && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: n, header: a, err: y }), !1;
70
70
  }
71
71
  }
72
- const s = u(C.filters) ?? C.filters, i = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, f = (i == null ? void 0 : i["item-value"]) ?? "id", S = (a) => a != null && typeof a == "object" ? a[f] : a;
73
- return Array.isArray(n) ? n.some((a) => g(t, S(a))) : g(t, S(n));
74
- }, I = p(() => {
72
+ const s = u(F.filters) ?? F.filters, i = Array.isArray(s) ? s.find((a) => a.value === r) : void 0, f = (i == null ? void 0 : i["item-value"]) ?? "id", w = (a) => a != null && typeof a == "object" ? a[f] : a;
73
+ return Array.isArray(n) ? n.some((a) => g(t, w(a))) : g(t, w(n));
74
+ }, I = R(() => {
75
75
  const e = u(h);
76
76
  return Array.isArray(e) ? e.filter((r) => {
77
77
  const n = c.search;
78
78
  if (n) {
79
- const t = F.value.get(r);
79
+ const t = d.value.get(r);
80
80
  if (t) {
81
81
  if (!Object.values(t).some((s) => s.includes(n))) return !1;
82
- } else if (!b.value.some((i) => w(r, i, n))) return !1;
82
+ } else if (!A.value.some((i) => b(r, i, n))) return !1;
83
83
  }
84
84
  for (const t in c.byColumn) {
85
- const o = c.byColumn[t];
86
- if (o != null && o !== "" && !w(r, t, o)) return !1;
85
+ const o = c.byColumn[t], s = Array.isArray(o) && o.length === 0;
86
+ if (o != null && o !== "" && !s && !b(r, t, o)) return !1;
87
87
  }
88
88
  return !0;
89
89
  }) : [];
90
- }), q = H((e) => {
91
- c.search = y(e).toLowerCase(), l && console.log("[setSearch]", c.search);
92
- }, u(O) ?? 150), B = (e, r) => {
90
+ }), q = G((e) => {
91
+ c.search = m(e).toLowerCase(), l && console.log("[setSearch]", c.search);
92
+ }, u(E) ?? 150), B = (e, r) => {
93
93
  c.byColumn[e] = r, l && console.log("[setColumnFilter]", e, r);
94
94
  }, M = (e) => {
95
95
  for (const r in e) B(r, e[r]);
96
96
  l && console.log("[applyColumnFilters]", e);
97
- }, z = () => {
97
+ }, P = () => {
98
98
  c.search = "", c.byColumn = {}, l && console.log("[clearFilters] filtros reseteados");
99
- }, D = (e, r) => {
100
- const n = d.value.find((t) => (t == null ? void 0 : t.value) === r);
99
+ }, z = (e, r) => {
100
+ if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
101
+ const n = p.value.find((t) => (t == null ? void 0 : t.value) === r);
101
102
  try {
102
- return n ? E(n, e) : e[r];
103
+ return n ? O(n, e) : e[r];
103
104
  } catch (t) {
104
105
  return l && console.error("[useFilter] ERROR getRawValue", { item: e, key: r, err: t }), null;
105
106
  }
@@ -110,9 +111,9 @@ function U(C, O, L, l = !1) {
110
111
  filteredItems: I,
111
112
  setSearch: q,
112
113
  applyColumnFilters: M,
113
- clearFilters: z,
114
+ clearFilters: P,
114
115
  // 👇 Exponemos también por si querés refrescar manualmente
115
- refreshCache: R
116
+ refreshCache: C
116
117
  };
117
118
  }
118
119
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.571",
3
+ "version": "0.1.573",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",