adverich-kun-ui 0.1.614 → 0.1.618
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.
package/AGENTS.md
CHANGED
|
@@ -356,17 +356,25 @@ const headers = [
|
|
|
356
356
|
```javascript
|
|
357
357
|
const filters = [
|
|
358
358
|
{
|
|
359
|
-
value: 'rol', // Clave del filtro (debe coincidir con header.value)
|
|
359
|
+
value: 'rol', // Clave del filtro (debe coincidir con header.value / row key)
|
|
360
360
|
label: 'Rol', // Etiqueta visible
|
|
361
361
|
text: 'Rol', // Texto alternativo
|
|
362
362
|
name: 'roles', // Nombre para textos genéricos
|
|
363
363
|
items: [...], // Lista de opciones para el filtro
|
|
364
|
+
'item-value': 'id', // Clave de comparación (default: 'id')
|
|
364
365
|
placeholderText: 'Seleccionar rol',
|
|
365
366
|
textNoItem: 'No hay roles disponibles'
|
|
366
367
|
}
|
|
367
368
|
]
|
|
368
369
|
```
|
|
369
370
|
|
|
371
|
+
**Matching de filtros por columna:**
|
|
372
|
+
|
|
373
|
+
- Selección múltiple dentro de un filtro: **OR** (pasa si coincide alguno de los valores seleccionados).
|
|
374
|
+
- Varios filtros activos: **AND**.
|
|
375
|
+
- Celda escalar: igualdad exacta (case-insensitive) contra `item-value`.
|
|
376
|
+
- Celda array (relaciones M2M, p. ej. `price_lists`): **includes-any** — pasa si algún miembro del array tiene `item-value` (default `id`) entre los seleccionados.
|
|
377
|
+
|
|
370
378
|
**Slots:**
|
|
371
379
|
|
|
372
380
|
| Slot | Props | Descripción |
|
package/dist/AGENTS.md
CHANGED
|
@@ -356,17 +356,25 @@ const headers = [
|
|
|
356
356
|
```javascript
|
|
357
357
|
const filters = [
|
|
358
358
|
{
|
|
359
|
-
value: 'rol', // Clave del filtro (debe coincidir con header.value)
|
|
359
|
+
value: 'rol', // Clave del filtro (debe coincidir con header.value / row key)
|
|
360
360
|
label: 'Rol', // Etiqueta visible
|
|
361
361
|
text: 'Rol', // Texto alternativo
|
|
362
362
|
name: 'roles', // Nombre para textos genéricos
|
|
363
363
|
items: [...], // Lista de opciones para el filtro
|
|
364
|
+
'item-value': 'id', // Clave de comparación (default: 'id')
|
|
364
365
|
placeholderText: 'Seleccionar rol',
|
|
365
366
|
textNoItem: 'No hay roles disponibles'
|
|
366
367
|
}
|
|
367
368
|
]
|
|
368
369
|
```
|
|
369
370
|
|
|
371
|
+
**Matching de filtros por columna:**
|
|
372
|
+
|
|
373
|
+
- Selección múltiple dentro de un filtro: **OR** (pasa si coincide alguno de los valores seleccionados).
|
|
374
|
+
- Varios filtros activos: **AND**.
|
|
375
|
+
- Celda escalar: igualdad exacta (case-insensitive) contra `item-value`.
|
|
376
|
+
- Celda array (relaciones M2M, p. ej. `price_lists`): **includes-any** — pasa si algún miembro del array tiene `item-value` (default `id`) entre los seleccionados.
|
|
377
|
+
|
|
370
378
|
**Slots:**
|
|
371
379
|
|
|
372
380
|
| Slot | Props | Descripción |
|
|
@@ -74,13 +74,13 @@ const E = { class: "w-full" }, I = { class: "flex justify-end px-1" }, K = { cla
|
|
|
74
74
|
"onUpdate:modelValue": (s) => i.value[e.value] = s,
|
|
75
75
|
items: e.items,
|
|
76
76
|
"z-index": "z-250",
|
|
77
|
-
"item-value": "id",
|
|
77
|
+
"item-value": e["item-value"] ?? "id",
|
|
78
78
|
"item-title": e.title ?? e.text,
|
|
79
|
-
"item-text":
|
|
79
|
+
"item-text": e.text,
|
|
80
80
|
label: e.label ?? "",
|
|
81
81
|
"text-no-items": e.textNoItem ?? `No hay ${e.name ?? "elementos"} disponibles`,
|
|
82
82
|
"placeholder-text": e.placeholderText ?? "Seleccionar"
|
|
83
|
-
}, null, 8, ["modelValue", "onUpdate:modelValue", "items", "item-title", "label", "text-no-items", "placeholder-text"])
|
|
83
|
+
}, null, 8, ["modelValue", "onUpdate:modelValue", "items", "item-value", "item-title", "item-text", "label", "text-no-items", "placeholder-text"])
|
|
84
84
|
]),
|
|
85
85
|
_: 2
|
|
86
86
|
}, 1024))), 256))
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as
|
|
4
|
-
function
|
|
5
|
-
const u =
|
|
1
|
+
import { reactive as H, ref as S, computed as V, unref as f, watch as O } from "vue";
|
|
2
|
+
import { debounce as J } from "../../../../utils/utils.js";
|
|
3
|
+
import { getValue as E, formatValue as N } from "../../../../utils/tableFormatters.js";
|
|
4
|
+
function Y(d, L, M, i = !1) {
|
|
5
|
+
const u = H({
|
|
6
6
|
search: "",
|
|
7
7
|
// Búsqueda global
|
|
8
8
|
byColumn: {}
|
|
9
9
|
// Mapa columna -> valor
|
|
10
|
-
}), { items: m, customFilter:
|
|
10
|
+
}), { items: m, customFilter: j, searchableKeys: x, headers: Q } = d, T = S(!1), h = (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);
|
|
@@ -26,90 +26,92 @@ function Q(F, E, L, i = !1) {
|
|
|
26
26
|
} catch {
|
|
27
27
|
return "";
|
|
28
28
|
}
|
|
29
|
-
},
|
|
30
|
-
const
|
|
31
|
-
return t ?
|
|
32
|
-
}, p =
|
|
33
|
-
const e = f(
|
|
29
|
+
}, K = (e, r) => {
|
|
30
|
+
const a = h(e).toLowerCase(), t = h(r).toLowerCase();
|
|
31
|
+
return t ? a === t : !0;
|
|
32
|
+
}, p = V(() => M.value ?? []), g = V(() => {
|
|
33
|
+
const e = f(x);
|
|
34
34
|
return Array.isArray(e) && e.length ? e : p.value.map((r) => r == null ? void 0 : r.value).filter(Boolean);
|
|
35
|
-
}), C =
|
|
36
|
-
function
|
|
35
|
+
}), C = S(/* @__PURE__ */ new Map());
|
|
36
|
+
function A() {
|
|
37
37
|
C.value.clear();
|
|
38
38
|
const e = f(m);
|
|
39
39
|
Array.isArray(e) && (e.forEach((r) => {
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const a = {};
|
|
41
|
+
g.value.forEach((t) => {
|
|
42
42
|
const n = p.value.find((l) => l.value === t);
|
|
43
|
-
let
|
|
43
|
+
let o, c;
|
|
44
44
|
try {
|
|
45
|
-
|
|
45
|
+
o = n ? E(n, r) : r[t];
|
|
46
46
|
} catch (l) {
|
|
47
|
-
|
|
47
|
+
o = "", i && console.error("[useFilter] ERROR getValue", { item: r, key: t, err: l });
|
|
48
48
|
}
|
|
49
49
|
try {
|
|
50
|
-
c = n ?
|
|
50
|
+
c = n ? N(n, o) : o;
|
|
51
51
|
} catch (l) {
|
|
52
|
-
c =
|
|
52
|
+
c = o, i && console.error("[useFilter] ERROR formatValue", { header: n, raw: o, err: l });
|
|
53
53
|
}
|
|
54
|
-
|
|
55
|
-
}), C.value.set(r,
|
|
54
|
+
a[t] = h(c).toLowerCase();
|
|
55
|
+
}), C.value.set(r, a);
|
|
56
56
|
}), i && console.log("[useFilter] Cache reconstruida", C.value));
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
O(() => f(m), () => A(), { immediate: !0 }), O(() => {
|
|
59
59
|
var e;
|
|
60
60
|
return (e = f(m)) == null ? void 0 : e.length;
|
|
61
|
-
}, () =>
|
|
62
|
-
const
|
|
63
|
-
const t =
|
|
61
|
+
}, () => A());
|
|
62
|
+
const I = (e, r, a) => {
|
|
63
|
+
const t = w(e, r), n = f(j);
|
|
64
64
|
if (typeof n == "function") {
|
|
65
|
-
const
|
|
65
|
+
const s = p.value.find((y) => (y == null ? void 0 : y.value) === r);
|
|
66
66
|
try {
|
|
67
|
-
return n(e, r,
|
|
68
|
-
} catch (
|
|
69
|
-
return i && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value:
|
|
67
|
+
return n(e, r, a, s);
|
|
68
|
+
} catch (y) {
|
|
69
|
+
return i && console.error("[matchesFilter] ERROR customFilter", { item: e, key: r, value: a, header: s, err: y }), !1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
|
|
72
|
+
const o = f(d.filters) ?? d.filters, c = Array.isArray(o) ? o.find((s) => s.value === r) : void 0, l = (c == null ? void 0 : c["item-value"]) ?? "id", F = (s) => s != null && typeof s == "object" ? s[l] : s, R = (s) => s != null && typeof s == "object" && !Array.isArray(s) ? s[l] : s, b = (Array.isArray(a) ? a : [a]).map(F), G = Array.isArray(t) ? t.map(R) : [t];
|
|
73
|
+
return b.some(
|
|
74
|
+
(s) => G.some((y) => K(y, s))
|
|
75
|
+
);
|
|
76
|
+
}, q = V(() => {
|
|
75
77
|
const e = f(m);
|
|
76
78
|
return Array.isArray(e) ? e.filter((r) => {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const t =
|
|
79
|
+
const a = u.search;
|
|
80
|
+
if (a) {
|
|
81
|
+
const t = a.split(/\s+/).filter((n) => n.length > 0);
|
|
80
82
|
if (t.length > 0) {
|
|
81
83
|
const n = C.value.get(r);
|
|
82
84
|
if (n) {
|
|
83
85
|
if (!t.every((c) => Object.values(n).some((l) => l.includes(c)))) return !1;
|
|
84
86
|
} else {
|
|
85
|
-
const
|
|
86
|
-
if (!t.every((l) =>
|
|
87
|
-
const
|
|
88
|
-
return
|
|
87
|
+
const o = g.value;
|
|
88
|
+
if (!t.every((l) => o.some((F) => {
|
|
89
|
+
const R = w(r, F);
|
|
90
|
+
return h(R).toLowerCase().includes(l);
|
|
89
91
|
}))) return !1;
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
}
|
|
93
95
|
for (const t in u.byColumn) {
|
|
94
|
-
const n = u.byColumn[t],
|
|
95
|
-
if (n != null && n !== "" && !
|
|
96
|
+
const n = u.byColumn[t], o = Array.isArray(n) && n.length === 0;
|
|
97
|
+
if (n != null && n !== "" && !o && !I(r, t, n)) return !1;
|
|
96
98
|
}
|
|
97
99
|
return !0;
|
|
98
100
|
}) : [];
|
|
99
|
-
}),
|
|
100
|
-
u.search =
|
|
101
|
-
}, f(
|
|
101
|
+
}), B = J((e) => {
|
|
102
|
+
u.search = h(e).toLowerCase(), i && console.log("[setSearch]", u.search);
|
|
103
|
+
}, f(L) ?? 150), P = (e, r) => {
|
|
102
104
|
u.byColumn[e] = r, i && console.log("[setColumnFilter]", e, r);
|
|
103
|
-
},
|
|
104
|
-
for (const r in e)
|
|
105
|
+
}, z = (e) => {
|
|
106
|
+
for (const r in e) P(r, e[r]);
|
|
105
107
|
i && console.log("[applyColumnFilters]", e);
|
|
106
|
-
},
|
|
108
|
+
}, D = () => {
|
|
107
109
|
u.search = "", u.byColumn = {}, i && console.log("[clearFilters] filtros reseteados");
|
|
108
|
-
},
|
|
110
|
+
}, w = (e, r) => {
|
|
109
111
|
if (Object.prototype.hasOwnProperty.call(e, r)) return e[r];
|
|
110
|
-
const
|
|
112
|
+
const a = p.value.find((t) => (t == null ? void 0 : t.value) === r);
|
|
111
113
|
try {
|
|
112
|
-
return
|
|
114
|
+
return a ? E(a, e) : e[r];
|
|
113
115
|
} catch (t) {
|
|
114
116
|
return i && console.error("[useFilter] ERROR getRawValue", { item: e, key: r, err: t }), null;
|
|
115
117
|
}
|
|
@@ -117,14 +119,14 @@ function Q(F, E, L, i = !1) {
|
|
|
117
119
|
return {
|
|
118
120
|
modalFilter: T,
|
|
119
121
|
appliedFilters: u,
|
|
120
|
-
filteredItems:
|
|
121
|
-
setSearch:
|
|
122
|
-
applyColumnFilters:
|
|
123
|
-
clearFilters:
|
|
122
|
+
filteredItems: q,
|
|
123
|
+
setSearch: B,
|
|
124
|
+
applyColumnFilters: z,
|
|
125
|
+
clearFilters: D,
|
|
124
126
|
// 👇 Exponemos también por si querés refrescar manualmente
|
|
125
|
-
refreshCache:
|
|
127
|
+
refreshCache: A
|
|
126
128
|
};
|
|
127
129
|
}
|
|
128
130
|
export {
|
|
129
|
-
|
|
131
|
+
Y as default
|
|
130
132
|
};
|