adverich-kun-ui 0.1.559 → 0.1.561
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,47 +1,63 @@
|
|
|
1
|
-
import { reactive as
|
|
2
|
-
function
|
|
3
|
-
const { page:
|
|
4
|
-
page:
|
|
1
|
+
import { reactive as z, watch as c, computed as p } from "vue";
|
|
2
|
+
function I(B, u, l) {
|
|
3
|
+
const { page: d, itemsPerPage: g, sortBy: b, mutliSort: A } = B, x = (e) => typeof e == "string" ? [{ key: e, order: "asc" }] : Array.isArray(e) ? e.map((t) => typeof t == "string" ? { key: t, order: "asc" } : t) : [], r = z({
|
|
4
|
+
page: d.value,
|
|
5
5
|
itemsPerPage: g.value,
|
|
6
|
-
sortBy: b
|
|
6
|
+
sortBy: x(b.value)
|
|
7
7
|
});
|
|
8
|
-
c(() =>
|
|
9
|
-
const y =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
if (
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
c(() => d.value, (e) => r.page = e), c(() => g.value, (e) => r.itemsPerPage = e), c(() => r.sortBy, (e) => u == null ? void 0 : u("update:sortBy", e)), c(() => r.page, (e) => u == null ? void 0 : u("update:page", e)), c(() => r.itemsPerPage, (e) => u == null ? void 0 : u("update:itemsPerPage", e));
|
|
9
|
+
const y = p(() => (r.page - 1) * r.itemsPerPage), h = p(() => y.value + r.itemsPerPage), P = p(() => {
|
|
10
|
+
if (!Array.isArray(l.value)) return [];
|
|
11
|
+
if (!r.sortBy.length) return l.value;
|
|
12
|
+
const e = (t) => {
|
|
13
|
+
if (typeof t == "number") return t;
|
|
14
|
+
if (typeof t == "string") {
|
|
15
|
+
if (/[a-zA-Z]/.test(t)) return t;
|
|
16
|
+
const s = t.replace(/[^\d.,-]/g, "");
|
|
17
|
+
if (/^-?(\d{1,3}(\.\d{3})*|\d+),\d+$/.test(s))
|
|
18
|
+
return parseFloat(s.replace(/\./g, "").replace(",", "."));
|
|
19
|
+
if (/^-?\d+(\.\d+)?$/.test(s))
|
|
20
|
+
return parseFloat(s);
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
};
|
|
24
|
+
return [...l.value].sort((t, s) => {
|
|
25
|
+
for (const { key: f, order: i } of r.sortBy) {
|
|
26
|
+
const a = t[f], o = s[f];
|
|
27
|
+
if (a == null && o == null) continue;
|
|
28
|
+
if (a == null) return i === "asc" ? -1 : 1;
|
|
29
|
+
if (o == null) return i === "asc" ? 1 : -1;
|
|
30
|
+
if (a instanceof Date && o instanceof Date) {
|
|
31
|
+
const n = a.getTime() - o.getTime();
|
|
32
|
+
if (n !== 0) return i === "asc" ? n : -n;
|
|
18
33
|
continue;
|
|
19
34
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
35
|
+
const v = e(a), m = e(o);
|
|
36
|
+
if (typeof v == "number" && typeof m == "number") {
|
|
37
|
+
const n = v - m;
|
|
38
|
+
if (n !== 0) return i === "asc" ? n : -n;
|
|
23
39
|
continue;
|
|
24
40
|
}
|
|
25
|
-
if (typeof
|
|
26
|
-
const
|
|
27
|
-
if (
|
|
41
|
+
if (typeof a == "string" && typeof o == "string") {
|
|
42
|
+
const n = a.localeCompare(o, void 0, { sensitivity: "base" });
|
|
43
|
+
if (n !== 0) return i === "asc" ? n : -n;
|
|
28
44
|
continue;
|
|
29
45
|
}
|
|
30
|
-
if (
|
|
46
|
+
if (a !== o) return i === "asc" ? a > o ? 1 : -1 : a < o ? 1 : -1;
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
})
|
|
48
|
+
return 0;
|
|
49
|
+
});
|
|
50
|
+
}), k = p(() => P.value.slice(y.value, h.value));
|
|
35
51
|
return {
|
|
36
|
-
options:
|
|
37
|
-
paginatedItems:
|
|
38
|
-
updateSort: ({ key: e, order:
|
|
39
|
-
const
|
|
40
|
-
|
|
52
|
+
options: r,
|
|
53
|
+
paginatedItems: k,
|
|
54
|
+
updateSort: ({ key: e, order: t }) => {
|
|
55
|
+
const s = r.sortBy.find((f) => f.key === e);
|
|
56
|
+
s ? s.order = t : A.value ? r.sortBy.push({ key: e, order: t }) : r.sortBy = [{ key: e, order: t }];
|
|
41
57
|
},
|
|
42
|
-
sortedItems:
|
|
58
|
+
sortedItems: P
|
|
43
59
|
};
|
|
44
60
|
}
|
|
45
61
|
export {
|
|
46
|
-
|
|
62
|
+
I as default
|
|
47
63
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { ref as
|
|
1
|
+
import { ref as i, watch as h } from "vue";
|
|
2
2
|
function V(e, n) {
|
|
3
|
-
const u =
|
|
4
|
-
|
|
3
|
+
const u = i(e.modelValue), a = i(null), t = i(null);
|
|
4
|
+
h(() => e.modelValue, (l) => {
|
|
5
5
|
u.value = l, n("update:modelValue", l);
|
|
6
6
|
});
|
|
7
|
-
function
|
|
8
|
-
|
|
7
|
+
function c() {
|
|
8
|
+
e.disabled || (clearTimeout(t.value), a.value = setTimeout(() => {
|
|
9
9
|
u.value = !0, n("update:modelValue", !0);
|
|
10
10
|
}, +e.openDelay));
|
|
11
11
|
}
|
|
@@ -15,7 +15,7 @@ function V(e, n) {
|
|
|
15
15
|
}, +e.closeDelay);
|
|
16
16
|
}
|
|
17
17
|
function d() {
|
|
18
|
-
u.value ? o() :
|
|
18
|
+
u.value ? o() : c();
|
|
19
19
|
}
|
|
20
20
|
function f() {
|
|
21
21
|
e.disabled || !e.openOnClick || d();
|
|
@@ -23,10 +23,10 @@ function V(e, n) {
|
|
|
23
23
|
function m(l) {
|
|
24
24
|
if (!e.openOnHover || e.disabled) return;
|
|
25
25
|
clearTimeout(a.value), clearTimeout(t.value);
|
|
26
|
-
const
|
|
26
|
+
const T = l === "enter" ? e.openDelay : e.closeDelay;
|
|
27
27
|
setTimeout(() => {
|
|
28
28
|
u.value = l === "enter";
|
|
29
|
-
}, +
|
|
29
|
+
}, +T);
|
|
30
30
|
}
|
|
31
31
|
function v() {
|
|
32
32
|
e.openOnFocus && (u.value = !0);
|
|
@@ -36,7 +36,7 @@ function V(e, n) {
|
|
|
36
36
|
}
|
|
37
37
|
return {
|
|
38
38
|
menuVisible: u,
|
|
39
|
-
showMenu:
|
|
39
|
+
showMenu: c,
|
|
40
40
|
hideMenu: o,
|
|
41
41
|
toggleMenu: d,
|
|
42
42
|
handleActivatorClick: f,
|