adverich-kun-ui 0.1.167 → 0.1.168
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 { createElementBlock as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { createElementBlock as n, openBlock as o, normalizeClass as a, createElementVNode as y, createCommentVNode as d, renderSlot as g, Fragment as b, renderList as S, normalizeStyle as A, toDisplayString as m, createBlock as w, resolveDynamicComponent as v } from "vue";
|
|
2
|
+
import E from "../../../../icons/IconArrowUp.vue.js";
|
|
3
|
+
import T from "../../../../icons/IconArrowDown.vue.js";
|
|
4
|
+
import $ from "../../../../icons/IconArrowDownUp.vue.js";
|
|
5
|
+
const D = { key: 0 }, z = { key: 1 }, L = ["checked"], O = ["onClick"], I = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "inline-flex items-center gap-1 ml-1"
|
|
8
|
-
},
|
|
8
|
+
}, N = "bg-slate-200 dark:bg-slate-800 sticky top-0 z-5", U = "", V = "px-3 py-2 text-xs font-medium text-slate-700 dark:text-slate-300 uppercase tracking-wider", q = {
|
|
9
9
|
__name: "KunTableHeaders",
|
|
10
10
|
props: {
|
|
11
11
|
headers: Array,
|
|
@@ -22,74 +22,78 @@ const z = { key: 0 }, L = { key: 1 }, O = ["checked"], I = ["onClick"], N = {
|
|
|
22
22
|
actionLabel: String
|
|
23
23
|
},
|
|
24
24
|
emits: ["toggle-select-all", "sort", "expandAll", "collapseAll"],
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
27
|
-
function
|
|
28
|
-
|
|
25
|
+
setup(r, { emit: k }) {
|
|
26
|
+
const l = r, c = k;
|
|
27
|
+
function f() {
|
|
28
|
+
c("toggle-select-all");
|
|
29
29
|
}
|
|
30
|
-
function p(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
function p(t) {
|
|
31
|
+
if (!t.sortable) return;
|
|
32
|
+
let s = null;
|
|
33
|
+
Array.isArray(l.sortBy) ? s = l.sortBy.find((u) => u.key === t.value) : typeof l.sortBy == "string" && (s = l.sortBy === t.value ? { key: t.value, order: "asc" } : null);
|
|
34
|
+
const e = (s == null ? void 0 : s.order) === "asc" ? "desc" : "asc";
|
|
35
|
+
c("sort", { key: t.value, order: e });
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
-
var
|
|
38
|
-
|
|
37
|
+
function h(t) {
|
|
38
|
+
var s;
|
|
39
|
+
if (Array.isArray(l.sortBy))
|
|
40
|
+
return (s = l.sortBy.find((e) => e.key === t.value)) == null ? void 0 : s.order;
|
|
41
|
+
if (typeof l.sortBy == "string" && l.sortBy === t.value)
|
|
42
|
+
return "asc";
|
|
39
43
|
}
|
|
40
|
-
const
|
|
41
|
-
const
|
|
42
|
-
return
|
|
43
|
-
},
|
|
44
|
-
return (
|
|
45
|
-
class: a(
|
|
44
|
+
const x = (t) => {
|
|
45
|
+
const s = h(t);
|
|
46
|
+
return s ? s === "asc" ? E : T : $;
|
|
47
|
+
}, C = [N, l.theadClass], B = [U, l.trClass], i = [V, l.thClass];
|
|
48
|
+
return (t, s) => (o(), n("thead", {
|
|
49
|
+
class: a(C)
|
|
46
50
|
}, [
|
|
47
|
-
|
|
48
|
-
class: a(
|
|
51
|
+
y("tr", {
|
|
52
|
+
class: a(B)
|
|
49
53
|
}, [
|
|
50
|
-
|
|
54
|
+
r.showExpand ? (o(), n("th", {
|
|
51
55
|
key: 0,
|
|
52
|
-
class: a([
|
|
56
|
+
class: a([i])
|
|
53
57
|
}, [
|
|
54
|
-
|
|
58
|
+
t.$slots.expandIcon ? g(t.$slots, "expand-icon", { key: 0 }) : (o(), n("button", {
|
|
55
59
|
key: 1,
|
|
56
|
-
onClick:
|
|
60
|
+
onClick: s[0] || (s[0] = (e) => r.isExpanded ? c("expandAll") : c("collapseAll"))
|
|
57
61
|
}, [
|
|
58
|
-
|
|
62
|
+
r.isExpanded ? (o(), n("span", D, "−")) : (o(), n("span", z, "+"))
|
|
59
63
|
]))
|
|
60
|
-
], 2)) :
|
|
61
|
-
|
|
64
|
+
], 2)) : d("", !0),
|
|
65
|
+
r.showSelect ? (o(), n("th", {
|
|
62
66
|
key: 1,
|
|
63
|
-
class: a(
|
|
67
|
+
class: a(i)
|
|
64
68
|
}, [
|
|
65
|
-
|
|
69
|
+
y("input", {
|
|
66
70
|
type: "checkbox",
|
|
67
|
-
checked:
|
|
68
|
-
onChange:
|
|
71
|
+
checked: r.allSelected,
|
|
72
|
+
onChange: f,
|
|
69
73
|
class: "form-checkbox"
|
|
70
|
-
}, null, 40,
|
|
71
|
-
])) :
|
|
72
|
-
(
|
|
74
|
+
}, null, 40, L)
|
|
75
|
+
])) : d("", !0),
|
|
76
|
+
(o(!0), n(b, null, S(r.headers, (e) => (o(), n("th", {
|
|
73
77
|
key: e.key,
|
|
74
|
-
class: a([
|
|
75
|
-
onClick: (
|
|
78
|
+
class: a([i, e.headerAlign === "right" ? "text-right" : e.headerAlign === "center" ? "text-center" : "text-left"]),
|
|
79
|
+
onClick: (u) => p(e),
|
|
76
80
|
style: A({ cursor: e.sortable ? "pointer" : "default" })
|
|
77
81
|
}, [
|
|
78
|
-
g(
|
|
79
|
-
|
|
80
|
-
e.sortable ? (
|
|
81
|
-
(
|
|
82
|
-
])) :
|
|
82
|
+
g(t.$slots, `header.${e.key}`, { header: e }, () => [
|
|
83
|
+
y("span", null, m(e.label ?? e.text), 1),
|
|
84
|
+
e.sortable ? (o(), n("span", I, [
|
|
85
|
+
(o(), w(v(x(e)), { class: "w-4 h-4 text-gray-500" }))
|
|
86
|
+
])) : d("", !0)
|
|
83
87
|
])
|
|
84
|
-
], 14,
|
|
85
|
-
|
|
88
|
+
], 14, O))), 128)),
|
|
89
|
+
r.hasActions ? (o(), n("th", {
|
|
86
90
|
key: 2,
|
|
87
|
-
class: a([[
|
|
88
|
-
},
|
|
91
|
+
class: a([[i], "text-center"])
|
|
92
|
+
}, m(r.actionLabel), 3)) : d("", !0)
|
|
89
93
|
])
|
|
90
94
|
]));
|
|
91
95
|
}
|
|
92
96
|
};
|
|
93
97
|
export {
|
|
94
|
-
|
|
98
|
+
q as default
|
|
95
99
|
};
|
|
@@ -11,7 +11,10 @@ const t = () => ({
|
|
|
11
11
|
// Features
|
|
12
12
|
itemsPerPage: { type: Number, default: 10 },
|
|
13
13
|
page: { type: Number, default: 1 },
|
|
14
|
-
sortBy: {
|
|
14
|
+
sortBy: {
|
|
15
|
+
type: [Array, String],
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
15
18
|
mutliSort: Boolean,
|
|
16
19
|
pageOptions: { type: Array, default: () => [5, 10, 25, 50, 100] },
|
|
17
20
|
searchable: { type: Boolean, default: !1 },
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
function
|
|
3
|
-
const { page: p, itemsPerPage: g, sortBy: P, mutliSort:
|
|
1
|
+
import { reactive as A, watch as c, computed as f } from "vue";
|
|
2
|
+
function D(v, o, l) {
|
|
3
|
+
const { page: p, itemsPerPage: g, sortBy: P, mutliSort: B } = v, b = (e) => typeof e == "string" ? [{ key: e, order: "asc" }] : Array.isArray(e) ? e.map((u) => typeof u == "string" ? { key: u, order: "asc" } : u) : [], t = A({
|
|
4
4
|
page: p.value,
|
|
5
5
|
itemsPerPage: g.value,
|
|
6
|
-
sortBy:
|
|
6
|
+
sortBy: b(P.value)
|
|
7
7
|
});
|
|
8
|
-
c(() => p.value, (
|
|
9
|
-
const
|
|
10
|
-
for (const { key: i, order:
|
|
11
|
-
const
|
|
12
|
-
if (!(
|
|
13
|
-
if (
|
|
14
|
-
if (
|
|
15
|
-
if (
|
|
16
|
-
const a =
|
|
17
|
-
if (a !== 0) return
|
|
8
|
+
c(() => p.value, (e) => t.page = e), c(() => g.value, (e) => t.itemsPerPage = e), c(() => t.sortBy, (e) => o == null ? void 0 : o("update:sortBy", e)), c(() => t.page, (e) => o == null ? void 0 : o("update:page", e)), c(() => t.itemsPerPage, (e) => o == null ? void 0 : o("update:itemsPerPage", e));
|
|
9
|
+
const y = f(() => (t.page - 1) * t.itemsPerPage), m = f(() => y.value + t.itemsPerPage), d = f(() => Array.isArray(l.value) ? t.sortBy.length ? [...l.value].sort((e, u) => {
|
|
10
|
+
for (const { key: i, order: s } of t.sortBy) {
|
|
11
|
+
const r = e[i], n = u[i];
|
|
12
|
+
if (!(r == null && n == null)) {
|
|
13
|
+
if (r == null) return s === "asc" ? -1 : 1;
|
|
14
|
+
if (n == null) return s === "asc" ? 1 : -1;
|
|
15
|
+
if (r instanceof Date && n instanceof Date) {
|
|
16
|
+
const a = r.getTime() - n.getTime();
|
|
17
|
+
if (a !== 0) return s === "asc" ? a : -a;
|
|
18
18
|
continue;
|
|
19
19
|
}
|
|
20
|
-
if (typeof
|
|
21
|
-
const a =
|
|
22
|
-
if (a !== 0) return
|
|
20
|
+
if (typeof r == "number" && typeof n == "number") {
|
|
21
|
+
const a = r - n;
|
|
22
|
+
if (a !== 0) return s === "asc" ? a : -a;
|
|
23
23
|
continue;
|
|
24
24
|
}
|
|
25
|
-
if (typeof
|
|
26
|
-
const a =
|
|
27
|
-
if (a !== 0) return
|
|
25
|
+
if (typeof r == "string" && typeof n == "string") {
|
|
26
|
+
const a = r.localeCompare(n, void 0, { sensitivity: "base" });
|
|
27
|
+
if (a !== 0) return s === "asc" ? a : -a;
|
|
28
28
|
continue;
|
|
29
29
|
}
|
|
30
|
-
if (
|
|
30
|
+
if (r !== n) return s === "asc" ? r > n ? 1 : -1 : r < n ? 1 : -1;
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
return 0;
|
|
34
|
-
}) : l.value : []),
|
|
34
|
+
}) : l.value : []), x = f(() => d.value.slice(y.value, m.value));
|
|
35
35
|
return {
|
|
36
|
-
options:
|
|
37
|
-
paginatedItems:
|
|
38
|
-
updateSort: ({ key:
|
|
39
|
-
const i =
|
|
40
|
-
i ? i.order =
|
|
36
|
+
options: t,
|
|
37
|
+
paginatedItems: x,
|
|
38
|
+
updateSort: ({ key: e, order: u }) => {
|
|
39
|
+
const i = t.sortBy.find((s) => s.key === e);
|
|
40
|
+
i ? i.order = u : B.value ? t.sortBy.push({ key: e, order: u }) : t.sortBy = [{ key: e, order: u }];
|
|
41
41
|
},
|
|
42
|
-
sortedItems:
|
|
42
|
+
sortedItems: d
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
export {
|
|
46
|
-
|
|
46
|
+
D as default
|
|
47
47
|
};
|