adverich-kun-ui 0.1.197 → 0.1.198
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,6 +1,6 @@
|
|
|
1
|
-
import { ref as m, provide as
|
|
2
|
-
import { useKunList as
|
|
3
|
-
const
|
|
1
|
+
import { ref as m, watch as w, provide as k, createElementBlock as v, openBlock as B, mergeProps as D, withModifiers as h, renderSlot as x } from "vue";
|
|
2
|
+
import { useKunList as S } from "../composables/useKunList.js";
|
|
3
|
+
const L = {
|
|
4
4
|
__name: "KunList",
|
|
5
5
|
props: {
|
|
6
6
|
nav: Boolean,
|
|
@@ -25,15 +25,15 @@ const K = {
|
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
emits: ["keyDown", "click:select", "update:selected"],
|
|
28
|
-
setup(l, { expose:
|
|
29
|
-
const u = l, i =
|
|
30
|
-
|
|
28
|
+
setup(l, { expose: p, emit: g }) {
|
|
29
|
+
const u = l, i = g, d = m(null), c = m([]), { selectedValues: f } = S(u);
|
|
30
|
+
w(
|
|
31
31
|
() => u.selected,
|
|
32
32
|
(e) => {
|
|
33
33
|
f.value = u.selectable === "multiple" ? Array.isArray(e) ? [...e] : [] : e != null ? [e] : [];
|
|
34
34
|
},
|
|
35
35
|
{ immediate: !0 }
|
|
36
|
-
),
|
|
36
|
+
), w(
|
|
37
37
|
f,
|
|
38
38
|
(e) => {
|
|
39
39
|
i(
|
|
@@ -41,10 +41,10 @@ const K = {
|
|
|
41
41
|
u.selectable === "multiple" ? [...e] : e[0] ?? null
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
|
-
),
|
|
44
|
+
), k("registerListItemRef", (e) => {
|
|
45
45
|
e && !c.value.includes(e) && c.value.push(e);
|
|
46
46
|
});
|
|
47
|
-
function
|
|
47
|
+
function y(e) {
|
|
48
48
|
var o;
|
|
49
49
|
i("keyDown", e);
|
|
50
50
|
const t = e.key, n = c.value.filter(Boolean);
|
|
@@ -56,7 +56,7 @@ const K = {
|
|
|
56
56
|
}
|
|
57
57
|
if (t === "ArrowUp" || t === "ArrowDown") {
|
|
58
58
|
e.preventDefault();
|
|
59
|
-
const r = n.findIndex((
|
|
59
|
+
const r = n.findIndex((A) => A === document.activeElement);
|
|
60
60
|
let a = -1;
|
|
61
61
|
r === -1 ? a = t === "ArrowDown" ? 0 : n.length - 1 : t === "ArrowDown" ? a = (r + 1) % n.length : t === "ArrowUp" && (a = (r - 1 + n.length) % n.length);
|
|
62
62
|
const s = n[a];
|
|
@@ -65,17 +65,17 @@ const K = {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function b(e = "ArrowDown") {
|
|
69
69
|
var r;
|
|
70
70
|
const t = c.value.filter(Boolean);
|
|
71
71
|
if (!t.length) return;
|
|
72
72
|
const n = e === "ArrowDown" ? 0 : t.length - 1, o = t[n];
|
|
73
73
|
(r = o == null ? void 0 : o.focus) == null || r.call(o);
|
|
74
74
|
}
|
|
75
|
-
return
|
|
75
|
+
return p({ focusWithKey: b, focus: () => {
|
|
76
76
|
var e, t;
|
|
77
77
|
return (t = (e = d.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
|
|
78
|
-
} }), (e, t) => (
|
|
78
|
+
} }), (e, t) => (B(), v("ul", D({
|
|
79
79
|
ref_key: "ulRef",
|
|
80
80
|
ref: d,
|
|
81
81
|
role: "list",
|
|
@@ -90,14 +90,14 @@ const K = {
|
|
|
90
90
|
}
|
|
91
91
|
]],
|
|
92
92
|
tabindex: "-1",
|
|
93
|
-
onKeydown:
|
|
93
|
+
onKeydown: h(y, ["prevent"]),
|
|
94
94
|
onSelect: t[0] || (t[0] = (n) => i("click:select", n.detail)),
|
|
95
95
|
onSelected: t[1] || (t[1] = (n) => i("update:selected", n.detail))
|
|
96
96
|
}, e.$attrs), [
|
|
97
|
-
|
|
97
|
+
x(e.$slots, "default")
|
|
98
98
|
], 16));
|
|
99
99
|
}
|
|
100
100
|
};
|
|
101
101
|
export {
|
|
102
|
-
|
|
102
|
+
L as default
|
|
103
103
|
};
|