adverich-kun-ui 0.1.198 → 0.1.199
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,19 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const L = {
|
|
1
|
+
import { mergeModels as g, ref as w, useModel as B, provide as p, computed as S, createElementBlock as h, openBlock as M, mergeProps as I, withModifiers as E, renderSlot as L } from "vue";
|
|
2
|
+
const R = {
|
|
4
3
|
__name: "KunList",
|
|
5
|
-
props: {
|
|
4
|
+
props: /* @__PURE__ */ g({
|
|
6
5
|
nav: Boolean,
|
|
7
6
|
sub: Boolean,
|
|
8
7
|
dense: Boolean,
|
|
9
|
-
selectable: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
selected: {
|
|
15
|
-
type: [Array, String, Number, Boolean, Object, null],
|
|
16
|
-
default: null
|
|
8
|
+
selectable: { type: Boolean, default: !0 },
|
|
9
|
+
selectionMode: {
|
|
10
|
+
type: String,
|
|
11
|
+
default: "single",
|
|
12
|
+
validator: (o) => ["single", "multiple"].includes(o)
|
|
17
13
|
},
|
|
18
14
|
bgList: {
|
|
19
15
|
type: String,
|
|
@@ -23,81 +19,90 @@ const L = {
|
|
|
23
19
|
type: String,
|
|
24
20
|
default: "border-gray-300 dark:border-gray-700"
|
|
25
21
|
}
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
f,
|
|
38
|
-
(e) => {
|
|
39
|
-
i(
|
|
40
|
-
"update:selected",
|
|
41
|
-
u.selectable === "multiple" ? [...e] : e[0] ?? null
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
), k("registerListItemRef", (e) => {
|
|
22
|
+
}, {
|
|
23
|
+
selected: {
|
|
24
|
+
type: [Array, String, Number, Object, null],
|
|
25
|
+
default: () => []
|
|
26
|
+
},
|
|
27
|
+
selectedModifiers: {}
|
|
28
|
+
}),
|
|
29
|
+
emits: /* @__PURE__ */ g(["keyDown", "click:select", "update:selected"], ["update:selected"]),
|
|
30
|
+
setup(o, { expose: b, emit: y }) {
|
|
31
|
+
const u = o, a = y, f = w(null), c = w([]), s = B(o, "selected");
|
|
32
|
+
p("registerListItemRef", (e) => {
|
|
45
33
|
e && !c.value.includes(e) && c.value.push(e);
|
|
46
34
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
35
|
+
const m = S(() => u.selectable && u.selectionMode === "multiple");
|
|
36
|
+
function v(e) {
|
|
37
|
+
if (!(!u.selectable || e == null))
|
|
38
|
+
if (m.value) {
|
|
39
|
+
const t = s.value.includes(e);
|
|
40
|
+
s.value = t ? s.value.filter((n) => n !== e) : [...s.value, e];
|
|
41
|
+
} else
|
|
42
|
+
s.value = e;
|
|
43
|
+
}
|
|
44
|
+
function k(e) {
|
|
45
|
+
var t, n;
|
|
46
|
+
return !u.selectable || e == null ? !1 : m.value ? (n = (t = s.value) == null ? void 0 : t.includes) == null ? void 0 : n.call(t, e) : s.value === e;
|
|
47
|
+
}
|
|
48
|
+
p("kunListContext", {
|
|
49
|
+
toggleItem: v,
|
|
50
|
+
isSelected: k
|
|
51
|
+
});
|
|
52
|
+
function A(e) {
|
|
53
|
+
var r;
|
|
54
|
+
a("keyDown", e);
|
|
50
55
|
const t = e.key, n = c.value.filter(Boolean);
|
|
51
56
|
if (!(!n.length || !["ArrowUp", "ArrowDown", "Enter"].includes(t))) {
|
|
52
57
|
if (t === "Enter") {
|
|
53
|
-
const
|
|
54
|
-
(
|
|
58
|
+
const l = document.activeElement;
|
|
59
|
+
(l == null ? void 0 : l.getAttribute("role")) === "menuitem" && l.click();
|
|
55
60
|
return;
|
|
56
61
|
}
|
|
57
62
|
if (t === "ArrowUp" || t === "ArrowDown") {
|
|
58
63
|
e.preventDefault();
|
|
59
|
-
const
|
|
60
|
-
let
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
(
|
|
64
|
+
const l = n.findIndex((D) => D === document.activeElement);
|
|
65
|
+
let d = -1;
|
|
66
|
+
l === -1 ? d = t === "ArrowDown" ? 0 : n.length - 1 : t === "ArrowDown" ? d = (l + 1) % n.length : t === "ArrowUp" && (d = (l - 1 + n.length) % n.length);
|
|
67
|
+
const i = n[d];
|
|
68
|
+
(r = i == null ? void 0 : i.focus) == null || r.call(i);
|
|
64
69
|
return;
|
|
65
70
|
}
|
|
66
71
|
}
|
|
67
72
|
}
|
|
68
|
-
function
|
|
69
|
-
var
|
|
73
|
+
function x(e = "ArrowDown") {
|
|
74
|
+
var l;
|
|
70
75
|
const t = c.value.filter(Boolean);
|
|
71
76
|
if (!t.length) return;
|
|
72
|
-
const n = e === "ArrowDown" ? 0 : t.length - 1,
|
|
73
|
-
(
|
|
77
|
+
const n = e === "ArrowDown" ? 0 : t.length - 1, r = t[n];
|
|
78
|
+
(l = r == null ? void 0 : r.focus) == null || l.call(r);
|
|
74
79
|
}
|
|
75
|
-
return
|
|
80
|
+
return b({ focusWithKey: x, focus: () => {
|
|
76
81
|
var e, t;
|
|
77
|
-
return (t = (e =
|
|
78
|
-
} }), (e, t) => (
|
|
82
|
+
return (t = (e = f.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
|
|
83
|
+
} }), (e, t) => (M(), h("ul", I({
|
|
79
84
|
ref_key: "ulRef",
|
|
80
|
-
ref:
|
|
85
|
+
ref: f,
|
|
81
86
|
role: "list",
|
|
82
87
|
class: ["w-full kun-list", [
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
o.bgList,
|
|
89
|
+
o.borderColor,
|
|
85
90
|
{
|
|
86
|
-
"space-y-1": !
|
|
87
|
-
"space-y-0.5":
|
|
88
|
-
"pl-4 border-l-2":
|
|
89
|
-
"p-2 rounded-md":
|
|
91
|
+
"space-y-1": !o.dense,
|
|
92
|
+
"space-y-0.5": o.dense,
|
|
93
|
+
"pl-4 border-l-2": o.sub,
|
|
94
|
+
"p-2 rounded-md": o.nav
|
|
90
95
|
}
|
|
91
96
|
]],
|
|
92
97
|
tabindex: "-1",
|
|
93
|
-
onKeydown:
|
|
94
|
-
onSelect: t[0] || (t[0] = (n) =>
|
|
95
|
-
onSelected: t[1] || (t[1] = (n) =>
|
|
98
|
+
onKeydown: E(A, ["prevent"]),
|
|
99
|
+
onSelect: t[0] || (t[0] = (n) => a("click:select", n.detail)),
|
|
100
|
+
onSelected: t[1] || (t[1] = (n) => a("update:selected", n.detail))
|
|
96
101
|
}, e.$attrs), [
|
|
97
|
-
|
|
102
|
+
L(e.$slots, "default")
|
|
98
103
|
], 16));
|
|
99
104
|
}
|
|
100
105
|
};
|
|
101
106
|
export {
|
|
102
|
-
|
|
107
|
+
R as default
|
|
103
108
|
};
|
package/package.json
CHANGED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ref as c, provide as f } from "vue";
|
|
2
|
-
const a = Symbol("kun-list");
|
|
3
|
-
function g(i) {
|
|
4
|
-
const e = c([]);
|
|
5
|
-
function t(l) {
|
|
6
|
-
if (!i.selectable || i.disabled || l == null) return;
|
|
7
|
-
const s = i.selectable === "multiple";
|
|
8
|
-
i.selectable === "single" ? e.value[0] !== l && (e.value = [l]) : s && (e.value.indexOf(l) === -1 ? e.value = [...e.value, l] : e.value = e.value.filter((u) => u !== l));
|
|
9
|
-
}
|
|
10
|
-
function n(l) {
|
|
11
|
-
return e.value.includes(l);
|
|
12
|
-
}
|
|
13
|
-
return f(a, {
|
|
14
|
-
toggleItem: t,
|
|
15
|
-
isSelected: n,
|
|
16
|
-
isMultiple: () => i.selectable === "multiple",
|
|
17
|
-
isSingle: () => i.selectable === "single"
|
|
18
|
-
}), {
|
|
19
|
-
selectedValues: e,
|
|
20
|
-
toggleItem: t,
|
|
21
|
-
isSelected: n
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
g as useKunList
|
|
26
|
-
};
|