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