adverich-kun-ui 0.1.74 → 0.1.75
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,4 +1,4 @@
|
|
|
1
|
-
import { ref as c, provide as
|
|
1
|
+
import { ref as c, provide as y, createElementBlock as v, openBlock as h, normalizeClass as k, renderSlot as x } from "vue";
|
|
2
2
|
import { useKunList as A } from "../composables/useKunList.js";
|
|
3
3
|
const K = {
|
|
4
4
|
__name: "KunList",
|
|
@@ -9,7 +9,7 @@ const K = {
|
|
|
9
9
|
selectable: {
|
|
10
10
|
type: [Boolean, String],
|
|
11
11
|
default: !1,
|
|
12
|
-
validator: (
|
|
12
|
+
validator: (l) => ["single", "multiple", !0, !1].includes(l)
|
|
13
13
|
},
|
|
14
14
|
selectedClass: {
|
|
15
15
|
type: String,
|
|
@@ -17,58 +17,58 @@ const K = {
|
|
|
17
17
|
},
|
|
18
18
|
bgList: {
|
|
19
19
|
type: String,
|
|
20
|
-
default: "bg-
|
|
20
|
+
default: "bg-transparent"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
emits: ["keyDown"],
|
|
24
|
-
setup(
|
|
25
|
-
const
|
|
26
|
-
A(
|
|
24
|
+
setup(l, { expose: d, emit: g }) {
|
|
25
|
+
const m = l, b = g;
|
|
26
|
+
A(m);
|
|
27
27
|
const u = c(null), o = c([]);
|
|
28
28
|
d({
|
|
29
29
|
focusWithKey: (e) => {
|
|
30
|
-
var n,
|
|
30
|
+
var n, r;
|
|
31
31
|
const t = o.value.filter(Boolean);
|
|
32
|
-
t.length !== 0 && (e === "ArrowDown" ? (n = t[0]) == null || n.focus() : e === "ArrowUp" && ((
|
|
32
|
+
t.length !== 0 && (e === "ArrowDown" ? (n = t[0]) == null || n.focus() : e === "ArrowUp" && ((r = t[t.length - 1]) == null || r.focus()));
|
|
33
33
|
},
|
|
34
34
|
focus: () => {
|
|
35
35
|
var e, t;
|
|
36
36
|
(t = (e = u.value) == null ? void 0 : e.focus) == null || t.call(e);
|
|
37
37
|
}
|
|
38
|
-
}),
|
|
38
|
+
}), y("registerListItemRef", (e) => {
|
|
39
39
|
e ? o.value.includes(e) || o.value.push(e) : o.value = o.value.filter((t) => t !== e);
|
|
40
40
|
});
|
|
41
|
-
function
|
|
42
|
-
var
|
|
41
|
+
function w(e) {
|
|
42
|
+
var i, a, f;
|
|
43
43
|
const t = e.key;
|
|
44
|
-
if (
|
|
44
|
+
if (b("keyDown", e), !["ArrowDown", "ArrowUp"].includes(t)) return;
|
|
45
45
|
e.preventDefault();
|
|
46
46
|
const n = o.value.filter(Boolean);
|
|
47
47
|
if (n.length === 0) return;
|
|
48
|
-
const
|
|
49
|
-
if (
|
|
50
|
-
t === "ArrowDown" ? (
|
|
48
|
+
const r = n.findIndex((p) => p === document.activeElement);
|
|
49
|
+
if (r === -1) {
|
|
50
|
+
t === "ArrowDown" ? (i = n[0]) == null || i.focus() : t === "ArrowUp" && ((a = n[n.length - 1]) == null || a.focus());
|
|
51
51
|
return;
|
|
52
52
|
}
|
|
53
|
-
let s =
|
|
54
|
-
t === "ArrowDown" ? s = (
|
|
53
|
+
let s = r;
|
|
54
|
+
t === "ArrowDown" ? s = (r + 1) % n.length : t === "ArrowUp" && (s = (r - 1 + n.length) % n.length), (f = n[s]) == null || f.focus();
|
|
55
55
|
}
|
|
56
|
-
return (e, t) => (
|
|
56
|
+
return (e, t) => (h(), v("ul", {
|
|
57
57
|
role: "list",
|
|
58
|
-
class:
|
|
58
|
+
class: k(["w-full bg-gray-500", [
|
|
59
59
|
"kun-list",
|
|
60
|
-
|
|
60
|
+
l.bgList,
|
|
61
61
|
{
|
|
62
|
-
"space-y-1": !
|
|
63
|
-
"space-y-0.5":
|
|
64
|
-
"pl-4 border-l-2 border-gray-
|
|
65
|
-
"
|
|
62
|
+
"space-y-1": !l.dense,
|
|
63
|
+
"space-y-0.5": l.dense,
|
|
64
|
+
"pl-4 border-l-2 border-gray-300 dark:border-gray-700": l.sub,
|
|
65
|
+
"p-2 rounded-md": l.nav
|
|
66
66
|
}
|
|
67
67
|
]]),
|
|
68
68
|
ref_key: "ulRef",
|
|
69
69
|
ref: u,
|
|
70
70
|
tabindex: "-1",
|
|
71
|
-
onKeydown:
|
|
71
|
+
onKeydown: w
|
|
72
72
|
}, [
|
|
73
73
|
x(e.$slots, "default")
|
|
74
74
|
], 34));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref as i, inject as o, onMounted as
|
|
1
|
+
import { ref as i, inject as o, onMounted as f, onBeforeUnmount as d, watch as g, computed as v, createElementBlock as b, openBlock as m, normalizeClass as k, renderSlot as y } from "vue";
|
|
2
2
|
const S = {
|
|
3
3
|
__name: "KunListItem",
|
|
4
4
|
props: {
|
|
@@ -15,43 +15,48 @@ const S = {
|
|
|
15
15
|
},
|
|
16
16
|
bgItems: {
|
|
17
17
|
type: String,
|
|
18
|
-
default: "bg-
|
|
18
|
+
default: "bg-transparent"
|
|
19
19
|
},
|
|
20
20
|
hoverBg: {
|
|
21
21
|
type: String,
|
|
22
22
|
default: "hover:bg-gray-100 dark:hover:bg-gray-600"
|
|
23
|
+
},
|
|
24
|
+
noGutters: {
|
|
25
|
+
type: Boolean,
|
|
26
|
+
default: !1
|
|
23
27
|
}
|
|
24
28
|
},
|
|
25
|
-
setup(
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}),
|
|
30
|
-
|
|
29
|
+
setup(e) {
|
|
30
|
+
const l = e, r = i(null), n = o("registerListItemRef", null), t = o("kun-list", null);
|
|
31
|
+
f(() => {
|
|
32
|
+
n && r.value && n(r.value);
|
|
33
|
+
}), d(() => {
|
|
34
|
+
n && n(null);
|
|
31
35
|
});
|
|
32
|
-
const u = i(
|
|
33
|
-
g(() =>
|
|
36
|
+
const u = i(l.active);
|
|
37
|
+
g(() => l.active, (a) => {
|
|
34
38
|
u.value = a;
|
|
35
39
|
});
|
|
36
|
-
const s =
|
|
40
|
+
const s = v(() => {
|
|
37
41
|
var a;
|
|
38
|
-
return ((a =
|
|
42
|
+
return ((a = t == null ? void 0 : t.isSelected) == null ? void 0 : a.call(t, l.value)) ?? !1;
|
|
39
43
|
});
|
|
40
44
|
function c() {
|
|
41
|
-
|
|
45
|
+
l.disabled || t && l.value !== null && t.toggleItem(l.value);
|
|
42
46
|
}
|
|
43
|
-
return (a, B) => (m(),
|
|
47
|
+
return (a, B) => (m(), b("li", {
|
|
44
48
|
ref_key: "liRef",
|
|
45
|
-
ref:
|
|
49
|
+
ref: r,
|
|
46
50
|
role: "listitem",
|
|
47
51
|
tabindex: "-1",
|
|
48
52
|
class: k(["w-full flex flex-col items-start", [
|
|
49
53
|
"kun-list-item",
|
|
50
|
-
|
|
54
|
+
e.bgItems,
|
|
51
55
|
{
|
|
52
|
-
"cursor-not-allowed":
|
|
53
|
-
[`
|
|
54
|
-
[
|
|
56
|
+
"cursor-not-allowed": e.disabled,
|
|
57
|
+
[`cursor-pointer ${e.hoverBg}`]: !e.disabled,
|
|
58
|
+
[e.activeClass]: s.value || u.value,
|
|
59
|
+
"px-4 py-2": !e.noGutters
|
|
55
60
|
}
|
|
56
61
|
]]),
|
|
57
62
|
onClick: c
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createElementBlock as
|
|
2
|
-
const
|
|
1
|
+
import { createElementBlock as l, openBlock as r, normalizeClass as a, renderSlot as o, createTextVNode as s, toDisplayString as i } from "vue";
|
|
2
|
+
const u = {
|
|
3
3
|
__name: "KunListItemTitle",
|
|
4
4
|
props: {
|
|
5
5
|
title: {
|
|
@@ -16,12 +16,12 @@ const p = {
|
|
|
16
16
|
},
|
|
17
17
|
class: {
|
|
18
18
|
type: [String, Object, Array],
|
|
19
|
-
default:
|
|
19
|
+
default: "font-semibold uppercase"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
setup(e) {
|
|
23
23
|
const t = e;
|
|
24
|
-
return (
|
|
24
|
+
return (n, p) => (r(), l("span", {
|
|
25
25
|
class: a([
|
|
26
26
|
"truncate",
|
|
27
27
|
t.fontSize,
|
|
@@ -29,12 +29,12 @@ const p = {
|
|
|
29
29
|
t.class
|
|
30
30
|
])
|
|
31
31
|
}, [
|
|
32
|
-
o(
|
|
32
|
+
o(n.$slots, "default", {}, () => [
|
|
33
33
|
s(i(t.title), 1)
|
|
34
34
|
])
|
|
35
35
|
], 2));
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
export {
|
|
39
|
-
|
|
39
|
+
u as default
|
|
40
40
|
};
|