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