adverich-kun-ui 0.1.212 → 0.1.214
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,15 +1,15 @@
|
|
|
1
|
-
import { mergeModels as g, ref as
|
|
2
|
-
const
|
|
1
|
+
import { mergeModels as g, ref as b, useModel as D, provide as w, computed as B, createElementBlock as M, openBlock as S, mergeProps as I, withModifiers as E, renderSlot as L } from "vue";
|
|
2
|
+
const K = ["selectable"], C = {
|
|
3
3
|
__name: "KunList",
|
|
4
4
|
props: /* @__PURE__ */ g({
|
|
5
5
|
nav: Boolean,
|
|
6
6
|
sub: Boolean,
|
|
7
7
|
dense: Boolean,
|
|
8
|
-
selectable: { type: Boolean, default: !
|
|
8
|
+
selectable: { type: Boolean, default: !1 },
|
|
9
9
|
selectionMode: {
|
|
10
10
|
type: String,
|
|
11
11
|
default: "single",
|
|
12
|
-
validator: (
|
|
12
|
+
validator: (l) => ["single", "multiple"].includes(l)
|
|
13
13
|
},
|
|
14
14
|
bgList: {
|
|
15
15
|
type: String,
|
|
@@ -27,9 +27,9 @@ const R = {
|
|
|
27
27
|
selectedModifiers: {}
|
|
28
28
|
}),
|
|
29
29
|
emits: /* @__PURE__ */ g(["keyDown", "click:select", "update:selected"], ["update:selected"]),
|
|
30
|
-
setup(
|
|
31
|
-
const u =
|
|
32
|
-
|
|
30
|
+
setup(l, { expose: y, emit: p }) {
|
|
31
|
+
const u = l, a = p, f = b(null), c = b([]), s = D(l, "selected");
|
|
32
|
+
w("registerListItemRef", (e) => {
|
|
33
33
|
e && !c.value.includes(e) && c.value.push(e);
|
|
34
34
|
});
|
|
35
35
|
const m = B(() => u.selectable && u.selectionMode === "multiple");
|
|
@@ -45,7 +45,7 @@ const R = {
|
|
|
45
45
|
var t, n;
|
|
46
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
47
|
}
|
|
48
|
-
|
|
48
|
+
w("kunListContext", {
|
|
49
49
|
toggleItem: v,
|
|
50
50
|
isSelected: k
|
|
51
51
|
});
|
|
@@ -55,15 +55,15 @@ const R = {
|
|
|
55
55
|
const t = e.key, n = c.value.filter(Boolean);
|
|
56
56
|
if (!(!n.length || !["ArrowUp", "ArrowDown", "Enter"].includes(t))) {
|
|
57
57
|
if (t === "Enter") {
|
|
58
|
-
const
|
|
59
|
-
(
|
|
58
|
+
const o = document.activeElement;
|
|
59
|
+
(o == null ? void 0 : o.getAttribute("role")) === "menuitem" && o.click();
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
if (t === "ArrowUp" || t === "ArrowDown") {
|
|
63
63
|
e.preventDefault();
|
|
64
|
-
const
|
|
64
|
+
const o = n.findIndex((x) => x === document.activeElement);
|
|
65
65
|
let d = -1;
|
|
66
|
-
|
|
66
|
+
o === -1 ? d = t === "ArrowDown" ? 0 : n.length - 1 : t === "ArrowDown" ? d = (o + 1) % n.length : t === "ArrowUp" && (d = (o - 1 + n.length) % n.length);
|
|
67
67
|
const i = n[d];
|
|
68
68
|
(r = i == null ? void 0 : i.focus) == null || r.call(i);
|
|
69
69
|
return;
|
|
@@ -71,13 +71,13 @@ const R = {
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
function h(e = "ArrowDown") {
|
|
74
|
-
var
|
|
74
|
+
var o;
|
|
75
75
|
const t = c.value.filter(Boolean);
|
|
76
76
|
if (!t.length) return;
|
|
77
77
|
const n = e === "ArrowDown" ? 0 : t.length - 1, r = t[n];
|
|
78
|
-
(
|
|
78
|
+
(o = r == null ? void 0 : r.focus) == null || o.call(r);
|
|
79
79
|
}
|
|
80
|
-
return
|
|
80
|
+
return y({ focusWithKey: h, focus: () => {
|
|
81
81
|
var e, t;
|
|
82
82
|
return (t = (e = f.value) == null ? void 0 : e.focus) == null ? void 0 : t.call(e);
|
|
83
83
|
} }), (e, t) => (S(), M("ul", I({
|
|
@@ -85,23 +85,24 @@ const R = {
|
|
|
85
85
|
ref: f,
|
|
86
86
|
role: "list",
|
|
87
87
|
class: ["w-full kun-list", [
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
l.bgList,
|
|
89
|
+
l.borderColor,
|
|
90
90
|
{
|
|
91
|
-
"space-y-1": !
|
|
92
|
-
"space-y-0.5":
|
|
93
|
-
"pl-4 border-l-2":
|
|
94
|
-
"p-2 rounded-md":
|
|
91
|
+
"space-y-1": !l.dense,
|
|
92
|
+
"space-y-0.5": l.dense,
|
|
93
|
+
"pl-4 border-l-2": l.sub,
|
|
94
|
+
"p-2 rounded-md": l.nav
|
|
95
95
|
}
|
|
96
96
|
]],
|
|
97
97
|
tabindex: "-1",
|
|
98
98
|
onKeydown: E(A, ["prevent"]),
|
|
99
|
-
onSelect: t[0] || (t[0] = (n) => a("click:select", n.detail))
|
|
99
|
+
onSelect: t[0] || (t[0] = (n) => a("click:select", n.detail)),
|
|
100
|
+
selectable: l.selectable
|
|
100
101
|
}, e.$attrs), [
|
|
101
102
|
L(e.$slots, "default")
|
|
102
|
-
], 16));
|
|
103
|
+
], 16, K));
|
|
103
104
|
}
|
|
104
105
|
};
|
|
105
106
|
export {
|
|
106
|
-
|
|
107
|
+
C as default
|
|
107
108
|
};
|
|
@@ -39,6 +39,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
39
39
|
type: String,
|
|
40
40
|
default: "bg-blue-100 text-blue-600 dark:bg-blue-900 dark:text-blue-300"
|
|
41
41
|
},
|
|
42
|
+
selectable: { type: Boolean, default: !1 },
|
|
42
43
|
variant: { type: String, default: "text" },
|
|
43
44
|
density: { type: String, default: "default" },
|
|
44
45
|
rounded: { type: [Boolean, String], default: !0 },
|
|
@@ -65,16 +66,16 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
65
66
|
}), F(() => {
|
|
66
67
|
m && m(null);
|
|
67
68
|
});
|
|
68
|
-
const
|
|
69
|
+
const y = (a) => typeof a == "object" || typeof a == "function", B = i(() => !!(t.prependIcon || t.prependAvatar)), A = i(() => !!(t.appendIcon || t.appendAvatar)), w = i(() => {
|
|
69
70
|
var a;
|
|
70
71
|
return ((a = o == null ? void 0 : o.isSelected) == null ? void 0 : a.call(o, t.value)) ?? !1;
|
|
71
72
|
}), I = i(() => t.active), O = i(() => !!t.to);
|
|
72
|
-
function
|
|
73
|
+
function g(a, x = null) {
|
|
73
74
|
var v, p;
|
|
74
75
|
if (t.disabled) return;
|
|
75
76
|
N("click", a);
|
|
76
77
|
const r = ((v = u.value) == null ? void 0 : v.$el) ?? u.value;
|
|
77
|
-
r != null && r.dispatchEvent && r.dispatchEvent(new CustomEvent("select", { detail: t.value, bubbles: !0 })), o && t.value !== null && ((p = o.toggleItem) == null || p.call(o, t.value), r != null && r.dispatchEvent && r.dispatchEvent(new CustomEvent("selected", { detail: t.value, bubbles: !0 }))), x && x(a);
|
|
78
|
+
r != null && r.dispatchEvent && r.dispatchEvent(new CustomEvent("select", { detail: t.value, bubbles: !0 })), o && t.selectable && t.value !== null && ((p = o.toggleItem) == null || p.call(o, t.value), r != null && r.dispatchEvent && r.dispatchEvent(new CustomEvent("selected", { detail: t.value, bubbles: !0 }))), x && x(a);
|
|
78
79
|
}
|
|
79
80
|
const P = i(() => {
|
|
80
81
|
switch (t.variant) {
|
|
@@ -111,7 +112,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
111
112
|
t.itemPosition,
|
|
112
113
|
{
|
|
113
114
|
"cursor-not-allowed opacity-50": t.disabled,
|
|
114
|
-
[`cursor-pointer ${t.hoverBg}`]: !t.disabled,
|
|
115
|
+
[`cursor-pointer ${t.hoverBg}`]: t.selectable && !t.disabled,
|
|
115
116
|
[t.activeClass]: w.value || I.value,
|
|
116
117
|
"px-4": !t.noGutters
|
|
117
118
|
},
|
|
@@ -133,8 +134,8 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
133
134
|
"aria-disabled": e.disabled,
|
|
134
135
|
tabindex: "-1",
|
|
135
136
|
class: $.value,
|
|
136
|
-
onClick: (S) =>
|
|
137
|
-
onKeydown: K(R((S) =>
|
|
137
|
+
onClick: (S) => g(S, v),
|
|
138
|
+
onKeydown: K(R((S) => g(S, v), ["prevent"]), ["enter"])
|
|
138
139
|
}, a.$attrs), {
|
|
139
140
|
default: C(() => [
|
|
140
141
|
b("div", H, [
|
|
@@ -145,7 +146,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
145
146
|
src: e.prependAvatar,
|
|
146
147
|
class: "w-8 h-8 rounded-full"
|
|
147
148
|
}, null, 8, Q)) : s("", !0),
|
|
148
|
-
|
|
149
|
+
y(e.prependIcon) ? (n(), c(f(e.prependIcon), {
|
|
149
150
|
key: 1,
|
|
150
151
|
class: "w-5 h-5"
|
|
151
152
|
})) : e.prependIcon ? (n(), l("i", {
|
|
@@ -171,7 +172,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
171
172
|
src: e.appendAvatar,
|
|
172
173
|
class: "w-8 h-8 rounded-full"
|
|
173
174
|
}, null, 8, Z)) : s("", !0),
|
|
174
|
-
|
|
175
|
+
y(e.appendIcon) ? (n(), c(f(e.appendIcon), {
|
|
175
176
|
key: 1,
|
|
176
177
|
class: "w-5 h-5"
|
|
177
178
|
})) : e.appendIcon ? (n(), l("i", {
|
|
@@ -195,8 +196,8 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
195
196
|
"aria-disabled": e.disabled,
|
|
196
197
|
tabindex: "-1",
|
|
197
198
|
class: $.value,
|
|
198
|
-
onClick:
|
|
199
|
-
onKeydown: K(R(
|
|
199
|
+
onClick: g,
|
|
200
|
+
onKeydown: K(R(g, ["prevent"]), ["enter"])
|
|
200
201
|
}, a.$attrs), {
|
|
201
202
|
default: C(() => [
|
|
202
203
|
b("div", _, [
|
|
@@ -207,7 +208,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
207
208
|
src: e.prependAvatar,
|
|
208
209
|
class: "w-8 h-8 rounded-full"
|
|
209
210
|
}, null, 8, te)) : s("", !0),
|
|
210
|
-
|
|
211
|
+
y(e.prependIcon) ? (n(), c(f(e.prependIcon), {
|
|
211
212
|
key: 1,
|
|
212
213
|
class: "w-5 h-5"
|
|
213
214
|
})) : e.prependIcon ? (n(), l("i", {
|
|
@@ -233,7 +234,7 @@ const H = { class: "flex w-full items-center" }, J = {
|
|
|
233
234
|
src: e.appendAvatar,
|
|
234
235
|
class: "w-8 h-8 rounded-full"
|
|
235
236
|
}, null, 8, re)) : s("", !0),
|
|
236
|
-
|
|
237
|
+
y(e.appendIcon) ? (n(), c(f(e.appendIcon), {
|
|
237
238
|
key: 1,
|
|
238
239
|
class: "w-5 h-5"
|
|
239
240
|
})) : e.appendIcon ? (n(), l("i", {
|