adverich-kun-ui 0.1.465 → 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,4 +1,4 @@
|
|
|
1
|
-
import { mergeModels as W, toRefs as be, useModel as Ce, ref as v, watch as Q, computed as q, onMounted as Te, createElementBlock as r, openBlock as l, mergeProps as
|
|
1
|
+
import { mergeModels as W, toRefs as be, useModel as Ce, ref as v, watch as Q, computed as q, onMounted as Te, createElementBlock as r, openBlock as l, mergeProps as O, createCommentVNode as u, createElementVNode as j, renderSlot as a, createBlock as b, unref as s, normalizeClass as C, withCtx as x, createVNode as T, withDirectives as G, vModelText as Fe, vShow as J, normalizeProps as d, guardReactiveProps as g, Fragment as $e, createSlots as X, renderList as Y, toDisplayString as ke, isRef as Pe, nextTick as Me } from "vue";
|
|
2
2
|
import { isMobile as m } from "../../../../utils/_platform.js";
|
|
3
3
|
import Z from "../../../KunIcon/src/components/KunIcon.vue.js";
|
|
4
4
|
import Ae from "../../../../icons/IconFilter.vue.js";
|
|
@@ -27,40 +27,25 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
27
27
|
selectedItemsModifiers: {}
|
|
28
28
|
}),
|
|
29
29
|
emits: /* @__PURE__ */ W(["update:page", "update:itemsPerPage", "update:sortBy", "update:search", "focusOnSearch"], ["update:selectedItems"]),
|
|
30
|
-
setup(
|
|
31
|
-
const S = _, p =
|
|
32
|
-
headers:
|
|
30
|
+
setup(z, { emit: _ }) {
|
|
31
|
+
const S = _, p = z, F = be(p), ee = Ce(z, "selectedItems"), {
|
|
32
|
+
headers: D,
|
|
33
33
|
showExpand: $,
|
|
34
34
|
showSelect: k,
|
|
35
|
-
rowClass:
|
|
35
|
+
rowClass: H,
|
|
36
36
|
hideDefaultFooter: se,
|
|
37
37
|
hideDefaultHeader: oe,
|
|
38
38
|
tableClass: te,
|
|
39
39
|
wrapperClass: le,
|
|
40
40
|
pageOptions: ae,
|
|
41
41
|
items: ne,
|
|
42
|
-
searchable:
|
|
42
|
+
searchable: N,
|
|
43
43
|
debounceTime: re
|
|
44
44
|
} = F, w = v(p.search);
|
|
45
45
|
Q(() => p.search, (e) => {
|
|
46
46
|
e !== w.value && (w.value = e);
|
|
47
47
|
});
|
|
48
|
-
const
|
|
49
|
-
Q(w, (e) => {
|
|
50
|
-
S("update:search", e), ce(e);
|
|
51
|
-
});
|
|
52
|
-
const { options: i, paginatedItems: f, updateSort: me } = ze(F, S, ie), { isSelected: P, toggleSelect: M, toggleSelectAll: fe, allSelected: he, someSelected: ge } = De(f, ee), { isExpanded: A, toggleExpand: I } = xe(), h = q(() => ({
|
|
53
|
-
items: f.value,
|
|
54
|
-
headers: z.value,
|
|
55
|
-
page: i.page,
|
|
56
|
-
itemsPerPage: i.itemsPerPage,
|
|
57
|
-
toggleSelect: M,
|
|
58
|
-
isSelected: P,
|
|
59
|
-
toggleExpand: I,
|
|
60
|
-
isExpanded: A,
|
|
61
|
-
sortBy: i.sortBy,
|
|
62
|
-
hasActions: p.hasActions
|
|
63
|
-
})), we = [Je, le.value], ye = [Xe, te.value], N = q(() => p.headers.map((e) => {
|
|
48
|
+
const P = q(() => p.headers.map((e) => {
|
|
64
49
|
var t, c;
|
|
65
50
|
const o = { ...e };
|
|
66
51
|
if ((e.columnType === "function" || e.columnType == "objectFunction" || e.columnType == "simpleFunction") && typeof e.columnFunction == "string") {
|
|
@@ -76,9 +61,24 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
76
61
|
), o.columnRowText = () => "");
|
|
77
62
|
}
|
|
78
63
|
return o;
|
|
79
|
-
}));
|
|
64
|
+
})), { filteredItems: ie, setSearch: ce, modalFilter: y, applyColumnFilters: ue, clearFilters: de, appliedFilters: pe } = He(F, re, P);
|
|
65
|
+
Q(w, (e) => {
|
|
66
|
+
S("update:search", e), ce(e);
|
|
67
|
+
});
|
|
68
|
+
const { options: i, paginatedItems: f, updateSort: me } = ze(F, S, ie), { isSelected: M, toggleSelect: A, toggleSelectAll: fe, allSelected: he, someSelected: ge } = De(f, ee), { isExpanded: I, toggleExpand: R } = xe(), h = q(() => ({
|
|
69
|
+
items: f.value,
|
|
70
|
+
headers: D.value,
|
|
71
|
+
page: i.page,
|
|
72
|
+
itemsPerPage: i.itemsPerPage,
|
|
73
|
+
toggleSelect: A,
|
|
74
|
+
isSelected: M,
|
|
75
|
+
toggleExpand: R,
|
|
76
|
+
isExpanded: I,
|
|
77
|
+
sortBy: i.sortBy,
|
|
78
|
+
hasActions: p.hasActions
|
|
79
|
+
})), we = [Je, le.value], ye = [Xe, te.value];
|
|
80
80
|
Te(() => L());
|
|
81
|
-
const K = v(null),
|
|
81
|
+
const K = v(null), E = v(!0), B = v(!1);
|
|
82
82
|
function ve() {
|
|
83
83
|
Se();
|
|
84
84
|
}
|
|
@@ -88,14 +88,14 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
88
88
|
}));
|
|
89
89
|
}
|
|
90
90
|
function L() {
|
|
91
|
-
m.value && (
|
|
91
|
+
m.value && (V.value = "w-fit", E.value = !1, B.value = !0, S("focusOnSearch", !1));
|
|
92
92
|
}
|
|
93
93
|
function U() {
|
|
94
|
-
m.value && (
|
|
94
|
+
m.value && (V.value = "w-full border", B.value = !1, E.value = !0, S("focusOnSearch", !0));
|
|
95
95
|
}
|
|
96
|
-
const
|
|
97
|
-
return (e, o) => (l(), r("div",
|
|
98
|
-
s(
|
|
96
|
+
const V = v("w-full border max-w-sm");
|
|
97
|
+
return (e, o) => (l(), r("div", O({ class: we }, e.$attrs, { style: { "user-select": "text" } }), [
|
|
98
|
+
s(N) || e.filterable || e.$slots.prependSearch || e.$slots.appendSearch ? (l(), r("div", {
|
|
99
99
|
key: 0,
|
|
100
100
|
class: C(["p-2 bg-surface print:hidden", {
|
|
101
101
|
"justify-start flex": e.searchPosition === "start",
|
|
@@ -112,7 +112,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
112
112
|
size: "xs",
|
|
113
113
|
bgColor: "bg-green-200 dark:bg-green-800"
|
|
114
114
|
}, {
|
|
115
|
-
default:
|
|
115
|
+
default: x(() => [
|
|
116
116
|
T(Z, {
|
|
117
117
|
class: "h-fit",
|
|
118
118
|
icon: Ae,
|
|
@@ -121,11 +121,11 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
121
121
|
]),
|
|
122
122
|
_: 1
|
|
123
123
|
})) : u("", !0),
|
|
124
|
-
s(
|
|
124
|
+
s(N) ? (l(), r("div", {
|
|
125
125
|
key: 1,
|
|
126
|
-
class: C(["rounded flex mx-2", [
|
|
126
|
+
class: C(["rounded flex mx-2", [V.value]])
|
|
127
127
|
}, [
|
|
128
|
-
G(
|
|
128
|
+
G(j("input", {
|
|
129
129
|
"onUpdate:modelValue": o[1] || (o[1] = (t) => w.value = t),
|
|
130
130
|
type: "text",
|
|
131
131
|
placeholder: e.searchPlaceholder,
|
|
@@ -136,18 +136,18 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
136
136
|
onBlur: L
|
|
137
137
|
}, null, 42, Ke), [
|
|
138
138
|
[Fe, w.value],
|
|
139
|
-
[J,
|
|
139
|
+
[J, E.value]
|
|
140
140
|
]),
|
|
141
141
|
G(T(Z, {
|
|
142
142
|
icon: Ie,
|
|
143
143
|
onClick: ve
|
|
144
144
|
}, null, 512), [
|
|
145
|
-
[J,
|
|
145
|
+
[J, B.value]
|
|
146
146
|
])
|
|
147
147
|
], 2)) : u("", !0),
|
|
148
148
|
a(e.$slots, "appendSearch")
|
|
149
149
|
], 2)) : u("", !0),
|
|
150
|
-
|
|
150
|
+
j("div", Le, [
|
|
151
151
|
s(f).length ? (l(), r("table", {
|
|
152
152
|
key: 0,
|
|
153
153
|
class: C(ye)
|
|
@@ -157,7 +157,7 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
157
157
|
])) : u("", !0),
|
|
158
158
|
!s(oe) && !s(m) ? (l(), b(Re, {
|
|
159
159
|
key: 1,
|
|
160
|
-
headers: s(
|
|
160
|
+
headers: s(D),
|
|
161
161
|
"sort-by": s(i).sortBy,
|
|
162
162
|
"show-select": s(k),
|
|
163
163
|
"show-expand": s($),
|
|
@@ -171,26 +171,26 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
171
171
|
onSort: s(me),
|
|
172
172
|
onToggleSelectAll: s(fe),
|
|
173
173
|
customHeaders: e.customSlots
|
|
174
|
-
}, null, 8, ["headers", "sort-by", "show-select", "show-expand", "all-selected", "some-selected", "thead-class", "tr-class", "th-class", "has-actions", "action-label", "onSort", "onToggleSelectAll", "customHeaders"])) : a(e.$slots, "thead", d(
|
|
174
|
+
}, null, 8, ["headers", "sort-by", "show-select", "show-expand", "all-selected", "some-selected", "thead-class", "tr-class", "th-class", "has-actions", "action-label", "onSort", "onToggleSelectAll", "customHeaders"])) : a(e.$slots, "thead", d(O({ key: 2 }, h.value))),
|
|
175
175
|
s(m) ? (l(), b(Ve, {
|
|
176
176
|
key: 4,
|
|
177
177
|
items: s(f),
|
|
178
|
-
headers:
|
|
179
|
-
"row-class": s(
|
|
178
|
+
headers: P.value,
|
|
179
|
+
"row-class": s(H),
|
|
180
180
|
"row-class-condition": e.rowClassCondition,
|
|
181
|
-
"is-selected": s(
|
|
182
|
-
"is-expanded": s(
|
|
181
|
+
"is-selected": s(M),
|
|
182
|
+
"is-expanded": s(I),
|
|
183
183
|
"show-select": s(k),
|
|
184
184
|
"show-expand": s($),
|
|
185
185
|
"has-actions": e.hasActions,
|
|
186
186
|
"action-loading-map": e.actionLoadingMap,
|
|
187
|
-
onToggleExpand: s(
|
|
188
|
-
onToggleSelect: s(
|
|
187
|
+
onToggleExpand: s(R),
|
|
188
|
+
onToggleSelect: s(A),
|
|
189
189
|
customSlots: e.customSlots
|
|
190
190
|
}, X({ _: 2 }, [
|
|
191
191
|
Y(e.$slots, (t, c) => ({
|
|
192
192
|
name: c,
|
|
193
|
-
fn:
|
|
193
|
+
fn: x((n) => [
|
|
194
194
|
a(e.$slots, c, d(g(n)))
|
|
195
195
|
])
|
|
196
196
|
}))
|
|
@@ -198,27 +198,27 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
198
198
|
a(e.$slots, "body.prepend", d(g(h.value))),
|
|
199
199
|
T(Be, {
|
|
200
200
|
items: s(f),
|
|
201
|
-
headers:
|
|
201
|
+
headers: P.value,
|
|
202
202
|
"tbody-class": e.tbodyClass,
|
|
203
|
-
"row-class": s(
|
|
203
|
+
"row-class": s(H),
|
|
204
204
|
"row-class-condition": e.rowClassCondition,
|
|
205
205
|
"tr-class": e.trClass,
|
|
206
206
|
"td-class": e.tdClass,
|
|
207
207
|
"selected-class": e.selectedClass,
|
|
208
208
|
"striped-class": e.stripedClass,
|
|
209
|
-
"is-selected": s(
|
|
210
|
-
"is-expanded": s(
|
|
209
|
+
"is-selected": s(M),
|
|
210
|
+
"is-expanded": s(I),
|
|
211
211
|
"show-select": s(k),
|
|
212
212
|
"show-expand": s($),
|
|
213
213
|
"has-actions": e.hasActions,
|
|
214
214
|
"action-loading-map": e.actionLoadingMap,
|
|
215
|
-
onToggleExpand: s(
|
|
216
|
-
onToggleSelect: s(
|
|
215
|
+
onToggleExpand: s(R),
|
|
216
|
+
onToggleSelect: s(A),
|
|
217
217
|
customSlots: e.customSlots
|
|
218
218
|
}, X({ _: 2 }, [
|
|
219
219
|
Y(e.$slots, (t, c) => ({
|
|
220
220
|
name: c,
|
|
221
|
-
fn:
|
|
221
|
+
fn: x((n) => [
|
|
222
222
|
a(e.$slots, c, d(g(n)))
|
|
223
223
|
])
|
|
224
224
|
}))
|
|
@@ -230,10 +230,10 @@ const Ke = ["placeholder"], Le = { class: "flex-1 overflow-auto bg-surface" }, U
|
|
|
230
230
|
])) : u("", !0)
|
|
231
231
|
])) : u("", !0),
|
|
232
232
|
s(f).length ? u("", !0) : (l(), r("div", Qe, [
|
|
233
|
-
|
|
233
|
+
j("div", qe, ke(e.noDataText), 1)
|
|
234
234
|
]))
|
|
235
235
|
]),
|
|
236
|
-
s(se) ? a(e.$slots, "footer", d(
|
|
236
|
+
s(se) ? a(e.$slots, "footer", d(O({ key: 2 }, h.value))) : (l(), r("div", Ge, [
|
|
237
237
|
T(Ee, {
|
|
238
238
|
"items-length": s(ne).length,
|
|
239
239
|
"items-per-page": s(i).itemsPerPage,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
import { debounce as
|
|
3
|
-
import { getValue as
|
|
4
|
-
function
|
|
5
|
-
const
|
|
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:
|
|
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 q(p, h) {
|
|
|
24
24
|
} catch {
|
|
25
25
|
return "";
|
|
26
26
|
}
|
|
27
|
-
},
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
},
|
|
31
|
-
const e =
|
|
32
|
-
return Array.isArray(e) && e.length ? e :
|
|
33
|
-
}),
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
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
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
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
|
-
|
|
105
|
+
N as default
|
|
123
106
|
};
|