adverich-kun-ui 0.1.560 → 0.1.562
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
|
};
|
package/dist/utils/_platform.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import { computed as i, ref as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { computed as i, ref as c } from "vue";
|
|
2
|
+
const s = typeof window < "u";
|
|
3
|
+
function f() {
|
|
4
|
+
var t, a, u, r, v;
|
|
5
|
+
if (!s)
|
|
6
|
+
return { os: "Server", osVersion: "Unknown" };
|
|
4
7
|
const l = window.navigator.userAgent;
|
|
5
|
-
let
|
|
6
|
-
return /Mac/.test(l) ? (
|
|
8
|
+
let o = "Unknown OS", d = "Unknown Version";
|
|
9
|
+
return /Mac/.test(l) ? (o = "Mac OS", d = (a = (t = l.match(/Mac OS X (\d+[\._]\d+[\._]\d+)/)) == null ? void 0 : t[1]) == null ? void 0 : a.replace(/_/g, ".")) : /iPhone|iPad|iPod/.test(l) ? (o = "iOS", d = ((u = l.match(/OS (\d+)[._](\d+)[._]?(\d+)?/)) == null ? void 0 : u.slice(1, 4).join(".")) || "Unknown") : /Windows/.test(l) ? (o = "Windows", d = (r = l.match(/Windows NT (\d+\.\d+)/)) == null ? void 0 : r[1]) : /Android/.test(l) ? (o = "Android", d = (v = l.match(/Android (\d+\.\d+)/)) == null ? void 0 : v[1]) : /Linux/.test(l) && (o = "Linux"), { os: o, osVersion: d };
|
|
7
10
|
}
|
|
8
|
-
const e =
|
|
9
|
-
() =>
|
|
11
|
+
const e = c(s ? window.innerWidth : 1024), m = c(s ? window.innerHeight : 768), w = f(), h = i(
|
|
12
|
+
() => w.os === "iOS" || w.os === "Android" || m.value > e.value
|
|
10
13
|
), n = {
|
|
11
14
|
xs: 475,
|
|
12
15
|
sm: 640,
|
|
@@ -33,16 +36,15 @@ i(() => e.value < n.lg);
|
|
|
33
36
|
i(() => e.value < n.xl);
|
|
34
37
|
i(() => e.value < n.xxl);
|
|
35
38
|
i(() => e.value < n.xxl);
|
|
36
|
-
function
|
|
37
|
-
e.value = window.innerWidth,
|
|
39
|
+
function x() {
|
|
40
|
+
s && (e.value = window.innerWidth, m.value = window.innerHeight);
|
|
38
41
|
}
|
|
39
|
-
window.addEventListener("resize",
|
|
40
|
-
window.
|
|
41
|
-
|
|
42
|
-
});
|
|
42
|
+
s && (window.addEventListener("resize", x), window.addEventListener("beforeunload", () => {
|
|
43
|
+
window.removeEventListener("resize", x);
|
|
44
|
+
}));
|
|
43
45
|
export {
|
|
44
46
|
h as isMobile,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
+
w as kunOS,
|
|
48
|
+
m as screenHeight,
|
|
47
49
|
e as screenWidth
|
|
48
50
|
};
|