adverich-kun-ui 0.1.188 → 0.1.190
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.
|
@@ -48,7 +48,7 @@ const H = "fixed inset-0 z-250 flex", U = /* @__PURE__ */ x({
|
|
|
48
48
|
c();
|
|
49
49
|
});
|
|
50
50
|
function d(o) {
|
|
51
|
-
|
|
51
|
+
o.stopPropagation(), o.key === "Escape" && (t.persistent || s("update:modelValue", !1));
|
|
52
52
|
}
|
|
53
53
|
return f(() => {
|
|
54
54
|
window.addEventListener("keydown", d);
|
|
@@ -1,191 +1,194 @@
|
|
|
1
|
-
import { toRefs as re, ref as ne, watch as
|
|
2
|
-
import { isMobile as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import { toRefs as re, ref as ne, watch as j, computed as z, createElementBlock as c, openBlock as l, mergeProps as E, createCommentVNode as i, createElementVNode as D, renderSlot as a, createBlock as b, unref as s, normalizeClass as L, withDirectives as ie, vModelText as de, normalizeProps as d, guardReactiveProps as u, Fragment as pe, createVNode as M, createSlots as R, renderList as U, withCtx as I, isRef as ce } from "vue";
|
|
2
|
+
import { isMobile as v } from "../../../../utils/_platform.js";
|
|
3
|
+
import me from "./KunTableHeaders.vue.js";
|
|
4
|
+
import ue from "./KunTableFooter.vue.js";
|
|
5
5
|
import he from "./KunTableRows.vue.js";
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
6
|
+
import ge from "./KunTableIterators.vue.js";
|
|
7
|
+
import fe from "../../../KunBtn/src/components/KunBtn.vue.js";
|
|
8
|
+
import be from "./KunTableFilter.vue.js";
|
|
9
|
+
import ye from "../../../KunCard/src/components/KunCard.vue.js";
|
|
10
|
+
import we from "../composables/useExpand.js";
|
|
11
|
+
import ve from "../composables/useOptions.js";
|
|
12
12
|
import Se from "../composables/useSelect.js";
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
const
|
|
13
|
+
import Ce from "../composables/useFilter.js";
|
|
14
|
+
import $e from "../composables/KunTableProps.js";
|
|
15
|
+
const ke = ["placeholder"], Pe = { key: 0 }, Te = { key: 5 }, Fe = { class: "h-full" }, Ae = {
|
|
16
16
|
key: 1,
|
|
17
17
|
class: "sticky bottom-0 z-10"
|
|
18
|
-
},
|
|
18
|
+
}, Ee = "overflow-auto h-full w-full flex flex-col border border-slate-200 dark:border-slate-800 rounded", Be = "table-auto w-full h-fit text-sm text-left", He = {
|
|
19
19
|
__name: "KunTable",
|
|
20
|
-
props:
|
|
21
|
-
emits: ["update:page", "update:itemsPerPage", "update:sortBy", "update:selectedItems"],
|
|
22
|
-
setup(
|
|
23
|
-
const
|
|
24
|
-
headers:
|
|
25
|
-
showExpand:
|
|
26
|
-
showSelect:
|
|
27
|
-
rowClass:
|
|
28
|
-
hideDefaultFooter:
|
|
29
|
-
hideDefaultHeader:
|
|
30
|
-
tableClass:
|
|
31
|
-
wrapperClass:
|
|
32
|
-
pageOptions:
|
|
33
|
-
items:
|
|
34
|
-
searchable:
|
|
35
|
-
debounceTime:
|
|
36
|
-
} =
|
|
37
|
-
|
|
38
|
-
|
|
20
|
+
props: $e(),
|
|
21
|
+
emits: ["update:page", "update:itemsPerPage", "update:sortBy", "update:selectedItems", "update:search"],
|
|
22
|
+
setup(N, { emit: K }) {
|
|
23
|
+
const S = K, r = N, y = re(r), {
|
|
24
|
+
headers: w,
|
|
25
|
+
showExpand: C,
|
|
26
|
+
showSelect: $,
|
|
27
|
+
rowClass: B,
|
|
28
|
+
hideDefaultFooter: O,
|
|
29
|
+
hideDefaultHeader: W,
|
|
30
|
+
tableClass: x,
|
|
31
|
+
wrapperClass: H,
|
|
32
|
+
pageOptions: Q,
|
|
33
|
+
items: q,
|
|
34
|
+
searchable: V,
|
|
35
|
+
debounceTime: G
|
|
36
|
+
} = y, h = ne(r.search);
|
|
37
|
+
j(() => r.search, (e) => {
|
|
38
|
+
e !== h.value && (h.value = e);
|
|
39
39
|
});
|
|
40
|
-
const {
|
|
40
|
+
const { filteredItems: J, setSearch: X, modalFilter: g, applyColumnFilters: Y, clearFilters: Z, appliedFilters: _ } = Ce(y, G);
|
|
41
|
+
j(h, (e) => {
|
|
42
|
+
S("update:search", e), X(e);
|
|
43
|
+
});
|
|
44
|
+
const { options: n, paginatedItems: p, updateSort: ee } = ve(y, S, J), { isSelected: k, toggleSelect: P, toggleSelectAll: se, allSelected: te, someSelected: le } = Se(y, S, p), { isExpanded: T, toggleExpand: F } = we(), m = z(() => ({
|
|
41
45
|
items: p.value,
|
|
42
|
-
headers:
|
|
43
|
-
page:
|
|
44
|
-
itemsPerPage:
|
|
45
|
-
toggleSelect:
|
|
46
|
-
isSelected:
|
|
47
|
-
toggleExpand:
|
|
48
|
-
isExpanded:
|
|
49
|
-
sortBy:
|
|
50
|
-
hasActions:
|
|
51
|
-
})),
|
|
46
|
+
headers: w.value,
|
|
47
|
+
page: n.page,
|
|
48
|
+
itemsPerPage: n.itemsPerPage,
|
|
49
|
+
toggleSelect: P,
|
|
50
|
+
isSelected: k,
|
|
51
|
+
toggleExpand: F,
|
|
52
|
+
isExpanded: T,
|
|
53
|
+
sortBy: n.sortBy,
|
|
54
|
+
hasActions: r.hasActions
|
|
55
|
+
})), oe = [Ee, H.value], ae = [Be, x.value];
|
|
56
|
+
return z(() => {
|
|
52
57
|
var t;
|
|
53
|
-
let
|
|
54
|
-
return
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
e(z) || s.filterable || s.$slots.prependSearch || s.$slots.appendSearch ? (l(), n("div", {
|
|
58
|
+
let e = ((t = r.headers) == null ? void 0 : t.length) || 0;
|
|
59
|
+
return r.showSelect && (e += 1), r.showExpand && (e += 1), r.hasActions && (e += 1), e;
|
|
60
|
+
}), (e, t) => (l(), c("div", E({ class: oe }, e.$attrs, { style: { "user-select": "text" } }), [
|
|
61
|
+
s(V) || e.filterable || e.$slots.prependSearch || e.$slots.appendSearch ? (l(), c("div", {
|
|
58
62
|
key: 0,
|
|
59
|
-
class:
|
|
60
|
-
"justify-start flex":
|
|
61
|
-
"justify-center flex":
|
|
62
|
-
"justify-end flex":
|
|
63
|
+
class: L(["p-2 bg-slate-200 dark:bg-slate-800", {
|
|
64
|
+
"justify-start flex": e.searchPosition === "start",
|
|
65
|
+
"justify-center flex": e.searchPosition === "center",
|
|
66
|
+
"justify-end flex": e.searchPosition === "end"
|
|
63
67
|
}])
|
|
64
68
|
}, [
|
|
65
|
-
a(
|
|
66
|
-
|
|
69
|
+
a(e.$slots, "prependSearch"),
|
|
70
|
+
e.filterable ? (l(), b(fe, {
|
|
67
71
|
key: 0,
|
|
68
72
|
onClick: t[0] || (t[0] = (o) => g.value = !0),
|
|
69
73
|
text: "Filtrar",
|
|
70
74
|
bgColor: "bg-slate-300 dark:bg-slate-700"
|
|
71
|
-
})) :
|
|
72
|
-
|
|
75
|
+
})) : i("", !0),
|
|
76
|
+
s(V) ? ie((l(), c("input", {
|
|
73
77
|
key: 1,
|
|
74
|
-
"onUpdate:modelValue": t[1] || (t[1] = (o) =>
|
|
78
|
+
"onUpdate:modelValue": t[1] || (t[1] = (o) => h.value = o),
|
|
75
79
|
type: "text",
|
|
76
|
-
placeholder:
|
|
80
|
+
placeholder: e.searchPlaceholder,
|
|
77
81
|
class: "border mx-2 px-3 py-1 rounded w-full max-w-sm text-sm"
|
|
78
|
-
}, null, 8,
|
|
79
|
-
[
|
|
80
|
-
]) :
|
|
81
|
-
a(
|
|
82
|
-
], 2)) :
|
|
83
|
-
|
|
84
|
-
class:
|
|
82
|
+
}, null, 8, ke)), [
|
|
83
|
+
[de, h.value]
|
|
84
|
+
]) : i("", !0),
|
|
85
|
+
a(e.$slots, "appendSearch")
|
|
86
|
+
], 2)) : i("", !0),
|
|
87
|
+
D("table", {
|
|
88
|
+
class: L(ae)
|
|
85
89
|
}, [
|
|
86
|
-
|
|
87
|
-
a(
|
|
88
|
-
])) :
|
|
89
|
-
!
|
|
90
|
+
e.$slots.colgroup && !s(v) ? (l(), c("colgroup", Pe, [
|
|
91
|
+
a(e.$slots, "colgroup", d(u(m.value)))
|
|
92
|
+
])) : i("", !0),
|
|
93
|
+
!s(W) && !s(v) ? (l(), b(me, {
|
|
90
94
|
key: 1,
|
|
91
|
-
headers:
|
|
92
|
-
"sort-by":
|
|
93
|
-
"show-select":
|
|
94
|
-
"show-expand":
|
|
95
|
-
"all-selected":
|
|
96
|
-
"some-selected":
|
|
97
|
-
"thead-class":
|
|
98
|
-
"tr-class":
|
|
99
|
-
"th-class":
|
|
100
|
-
"has-actions":
|
|
101
|
-
"action-label":
|
|
102
|
-
onSort:
|
|
103
|
-
onToggleSelectAll:
|
|
104
|
-
}, 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"])) : a(
|
|
105
|
-
|
|
106
|
-
a(
|
|
107
|
-
|
|
108
|
-
items:
|
|
109
|
-
headers:
|
|
110
|
-
"tbody-class":
|
|
111
|
-
"row-class":
|
|
112
|
-
"tr-class":
|
|
113
|
-
"td-class":
|
|
114
|
-
"selected-class":
|
|
115
|
-
"striped-class":
|
|
116
|
-
"is-selected":
|
|
117
|
-
"is-expanded":
|
|
118
|
-
"show-select":
|
|
119
|
-
"show-expand":
|
|
120
|
-
"has-actions":
|
|
121
|
-
"action-loading-map":
|
|
122
|
-
onToggleExpand:
|
|
123
|
-
onToggleSelect:
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
name:
|
|
127
|
-
fn:
|
|
128
|
-
a(
|
|
95
|
+
headers: s(w),
|
|
96
|
+
"sort-by": s(n).sortBy,
|
|
97
|
+
"show-select": s($),
|
|
98
|
+
"show-expand": s(C),
|
|
99
|
+
"all-selected": s(te),
|
|
100
|
+
"some-selected": s(le),
|
|
101
|
+
"thead-class": e.theadClass,
|
|
102
|
+
"tr-class": e.trClass,
|
|
103
|
+
"th-class": e.thClass,
|
|
104
|
+
"has-actions": e.hasActions,
|
|
105
|
+
"action-label": e.actionLabel,
|
|
106
|
+
onSort: s(ee),
|
|
107
|
+
onToggleSelectAll: s(se)
|
|
108
|
+
}, 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"])) : a(e.$slots, "thead", d(E({ key: 2 }, m.value))),
|
|
109
|
+
s(p).length && !s(v) ? (l(), c(pe, { key: 3 }, [
|
|
110
|
+
a(e.$slots, "body.prepend", d(u(m.value))),
|
|
111
|
+
M(he, {
|
|
112
|
+
items: s(p),
|
|
113
|
+
headers: s(w),
|
|
114
|
+
"tbody-class": e.tbodyClass,
|
|
115
|
+
"row-class": s(B),
|
|
116
|
+
"tr-class": e.trClass,
|
|
117
|
+
"td-class": e.tdClass,
|
|
118
|
+
"selected-class": e.selectedClass,
|
|
119
|
+
"striped-class": e.stripedClass,
|
|
120
|
+
"is-selected": s(k),
|
|
121
|
+
"is-expanded": s(T),
|
|
122
|
+
"show-select": s($),
|
|
123
|
+
"show-expand": s(C),
|
|
124
|
+
"has-actions": e.hasActions,
|
|
125
|
+
"action-loading-map": e.actionLoadingMap,
|
|
126
|
+
onToggleExpand: s(F),
|
|
127
|
+
onToggleSelect: s(P)
|
|
128
|
+
}, R({ _: 2 }, [
|
|
129
|
+
U(e.$slots, (o, f) => ({
|
|
130
|
+
name: f,
|
|
131
|
+
fn: I((A) => [
|
|
132
|
+
a(e.$slots, f, d(u(A)))
|
|
129
133
|
])
|
|
130
134
|
}))
|
|
131
135
|
]), 1032, ["items", "headers", "tbody-class", "row-class", "tr-class", "td-class", "selected-class", "striped-class", "is-selected", "is-expanded", "show-select", "show-expand", "has-actions", "action-loading-map", "onToggleExpand", "onToggleSelect"]),
|
|
132
|
-
a(
|
|
133
|
-
], 64)) :
|
|
136
|
+
a(e.$slots, "body.append", d(u(m.value)))
|
|
137
|
+
], 64)) : s(p).length && s(v) ? (l(), b(ge, {
|
|
134
138
|
key: 4,
|
|
135
|
-
items:
|
|
136
|
-
headers:
|
|
137
|
-
"row-class":
|
|
138
|
-
"is-selected":
|
|
139
|
-
"is-expanded":
|
|
140
|
-
"show-select":
|
|
141
|
-
"show-expand":
|
|
142
|
-
"has-actions":
|
|
143
|
-
"action-loading-map":
|
|
144
|
-
onToggleExpand:
|
|
145
|
-
onToggleSelect:
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
name:
|
|
149
|
-
fn:
|
|
150
|
-
a(
|
|
139
|
+
items: s(p),
|
|
140
|
+
headers: s(w),
|
|
141
|
+
"row-class": s(B),
|
|
142
|
+
"is-selected": s(k),
|
|
143
|
+
"is-expanded": s(T),
|
|
144
|
+
"show-select": s($),
|
|
145
|
+
"show-expand": s(C),
|
|
146
|
+
"has-actions": e.hasActions,
|
|
147
|
+
"action-loading-map": e.actionLoadingMap,
|
|
148
|
+
onToggleExpand: s(F),
|
|
149
|
+
onToggleSelect: s(P)
|
|
150
|
+
}, R({ _: 2 }, [
|
|
151
|
+
U(e.$slots, (o, f) => ({
|
|
152
|
+
name: f,
|
|
153
|
+
fn: I((A) => [
|
|
154
|
+
a(e.$slots, f, d(u(A)))
|
|
151
155
|
])
|
|
152
156
|
}))
|
|
153
|
-
]), 1032, ["items", "headers", "row-class", "is-selected", "is-expanded", "show-select", "show-expand", "has-actions", "action-loading-map", "onToggleExpand", "onToggleSelect"])) : (
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
]), 1032, ["items", "headers", "row-class", "is-selected", "is-expanded", "show-select", "show-expand", "has-actions", "action-loading-map", "onToggleExpand", "onToggleSelect"])) : i("", !0),
|
|
158
|
+
e.$slots.tfoot ? (l(), c("tfoot", Te, [
|
|
159
|
+
a(e.$slots, "tfoot", d(u(m.value)))
|
|
160
|
+
])) : i("", !0)
|
|
161
|
+
]),
|
|
162
|
+
D("div", Fe, [
|
|
163
|
+
s(p).length ? i("", !0) : (l(), b(ye, {
|
|
164
|
+
key: 0,
|
|
165
|
+
class: "h-full flex justify-center items-center",
|
|
166
|
+
title: e.noDataText,
|
|
167
|
+
titleSize: "text-4xl"
|
|
168
|
+
}, null, 8, ["title"]))
|
|
165
169
|
]),
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
"items-
|
|
170
|
-
"
|
|
171
|
-
"
|
|
172
|
-
"
|
|
173
|
-
"onUpdate:
|
|
174
|
-
"onUpdate:page": t[3] || (t[3] = (o) => e(r).page = o)
|
|
170
|
+
s(O) ? a(e.$slots, "footer", d(E({ key: 2 }, m.value))) : (l(), c("div", Ae, [
|
|
171
|
+
M(ue, {
|
|
172
|
+
"items-length": s(q).length,
|
|
173
|
+
"items-per-page": s(n).itemsPerPage,
|
|
174
|
+
"current-page": s(n).page,
|
|
175
|
+
"page-options": s(Q),
|
|
176
|
+
"onUpdate:itemsPerPage": t[2] || (t[2] = (o) => s(n).itemsPerPage = o),
|
|
177
|
+
"onUpdate:page": t[3] || (t[3] = (o) => s(n).page = o)
|
|
175
178
|
}, null, 8, ["items-length", "items-per-page", "current-page", "page-options"])
|
|
176
179
|
])),
|
|
177
|
-
|
|
180
|
+
e.filterable && s(g) ? (l(), b(be, {
|
|
178
181
|
key: 3,
|
|
179
|
-
filters:
|
|
180
|
-
modelValue:
|
|
181
|
-
"onUpdate:modelValue": t[4] || (t[4] = (o) =>
|
|
182
|
-
onApplyFilters:
|
|
183
|
-
onClearFilters:
|
|
184
|
-
activeFilters:
|
|
185
|
-
}, null, 8, ["filters", "modelValue", "onApplyFilters", "onClearFilters", "activeFilters"])) :
|
|
182
|
+
filters: e.filters,
|
|
183
|
+
modelValue: s(g),
|
|
184
|
+
"onUpdate:modelValue": t[4] || (t[4] = (o) => ce(g) ? g.value = o : null),
|
|
185
|
+
onApplyFilters: s(Y),
|
|
186
|
+
onClearFilters: s(Z),
|
|
187
|
+
activeFilters: s(_).byColumn
|
|
188
|
+
}, null, 8, ["filters", "modelValue", "onApplyFilters", "onClearFilters", "activeFilters"])) : i("", !0)
|
|
186
189
|
], 16));
|
|
187
190
|
}
|
|
188
191
|
};
|
|
189
192
|
export {
|
|
190
|
-
|
|
193
|
+
He as default
|
|
191
194
|
};
|
|
@@ -18,6 +18,10 @@ const t = () => ({
|
|
|
18
18
|
mutliSort: Boolean,
|
|
19
19
|
pageOptions: { type: Array, default: () => [5, 10, 25, 50, 100] },
|
|
20
20
|
searchable: { type: Boolean, default: !1 },
|
|
21
|
+
search: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: ""
|
|
24
|
+
},
|
|
21
25
|
searchableKeys: { type: Array, default: null },
|
|
22
26
|
searchPosition: {
|
|
23
27
|
type: String,
|
|
@@ -46,8 +50,8 @@ const t = () => ({
|
|
|
46
50
|
tfootClass: { type: String, default: "" },
|
|
47
51
|
rowClass: { type: String, default: "" },
|
|
48
52
|
// Misc
|
|
49
|
-
noDataText: { type: String, default: "No
|
|
50
|
-
loadingText: { type: String, default: "
|
|
53
|
+
noDataText: { type: String, default: "No hay elementos disponibles" },
|
|
54
|
+
loadingText: { type: String, default: "Cargando..." },
|
|
51
55
|
// Slots control
|
|
52
56
|
showTopSlot: { type: Boolean, default: !1 },
|
|
53
57
|
showBottomSlot: { type: Boolean, default: !1 }
|