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 O, ref as E, computed as g, unref as i, watch as N } from "vue";
2
- import { debounce as v } from "../../../../utils/utils.js";
3
- import { getValue as K, formatValue as T } from "../../../../utils/tableFormatters.js";
4
- function B(p, h, F) {
5
- const c = O({
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: m, customFilter: b, searchableKeys: V, headers: k } = p, R = E(!1), u = (e) => {
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
- }, d = (e, t) => {
28
- const r = u(e).toLowerCase(), l = u(t).toLowerCase();
29
- return l ? r ? r.includes(l) : !1 : !0;
30
- }, f = g(() => F.value ?? []), I = g(() => {
31
- const e = i(V);
32
- return Array.isArray(e) && e.length ? e : f.value.map((t) => t == null ? void 0 : t.value).filter(Boolean);
33
- }), S = (e, t) => {
34
- console.log("[getDisplayValue] START → key:", t, "item:", e);
35
- const r = f.value.find((o) => (o == null ? void 0 : o.value) === t);
36
- if (console.log("[getDisplayValue] header encontrado:", r), !r) {
37
- const o = e == null ? void 0 : e[t];
38
- return console.log("[getDisplayValue] SIN header, devuelvo item[key]:", o), o;
39
- }
40
- let l, a;
41
- try {
42
- l = K(r, e), console.log("[getDisplayValue] raw value de getValue:", l);
43
- } catch (o) {
44
- console.error("[getDisplayValue] ERROR en getValue", { header: r, item: e, err: o });
45
- }
46
- try {
47
- a = T(r, l), console.log("[getDisplayValue] shown value de formatValue:", a);
48
- } catch (o) {
49
- console.error("[getDisplayValue] ERROR en formatValue", { header: r, raw: l, err: o });
50
- }
51
- const s = u(a);
52
- return console.log("[getDisplayValue] FINAL stringified:", s), s;
53
- }, y = (e, t, r) => {
54
- console.log("[matchesFilter] item:", e, "key:", t, "filter value:", r);
55
- const l = S(e, t);
56
- console.log("[matchesFilter] itemValue obtenido:", l);
57
- const a = i(b);
58
- if (typeof a == "function") {
59
- console.log("[matchesFilter] customFilter detectado, llamando...");
60
- const o = f.value.find((n) => (n == null ? void 0 : n.value) === t);
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
- const n = a(e, t, r, o);
63
- return console.log("[matchesFilter] customFilter result:", n), n;
64
- } catch (n) {
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
- if (Array.isArray(r)) {
69
- console.log("[matchesFilter] value es array, evaluando...");
70
- const o = r.some((n) => d(l, n));
71
- return console.log("[matchesFilter] array filter result:", o), o;
72
- }
73
- const s = d(l, r);
74
- return console.log("[matchesFilter] default filter result:", s), s;
75
- }, A = g(() => {
76
- const e = i(m);
77
- if (console.log("[filteredItems] recompute items length:", Array.isArray(e) ? e.length : "NO ARRAY"), !Array.isArray(e)) return [];
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 console.log("[filteredItems] item pasó todos los filtros ✅"), !0;
95
- });
96
- return console.log("[filteredItems] RESULT FINAL →", t), t;
97
- }), C = v((e) => {
98
- console.log("[setSearch] nuevo valor:", e), c.search = u(e).toLowerCase();
99
- }, i(h) ?? 150), w = (e, t) => {
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
- function D(e) {
103
- console.log("[applyColumnFilters] aplicando:", e);
104
- for (const t in e)
105
- w(t, e[t]);
106
- }
107
- const L = () => {
108
- console.log("[clearFilters] reseteando filtros"), c.search = "", c.byColumn = {};
109
- };
110
- return N(() => i(m), (e, t) => {
111
- console.log("[watch items] old:", t, "new:", e);
112
- }, { deep: !0 }), {
113
- modalFilter: R,
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
- B as default
105
+ N as default
123
106
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.466",
3
+ "version": "0.1.467",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",