vue-composable-ui 1.0.1 → 1.0.2
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.
- package/dist/combobox.vue_vue_type_script_setup_true_lang-BhVMcx67.js +140 -0
- package/dist/comboboxHiddenInput.vue_vue_type_script_setup_true_lang-Ba-UPd-M.js +29 -0
- package/dist/comboboxInput.vue_vue_type_script_setup_true_lang-DzRfJ5ke.js +33 -0
- package/dist/comboboxOption.vue_vue_type_script_setup_true_lang-OyJxB4Jk.js +42 -0
- package/dist/comboboxOptions.vue_vue_type_script_setup_true_lang-Doy6MfEQ.js +20 -0
- package/dist/composable-ui.js +47 -1112
- package/dist/composable-ui10.js +4 -0
- package/dist/composable-ui11.js +4 -0
- package/dist/composable-ui12.js +4 -0
- package/dist/composable-ui13.js +4 -0
- package/dist/composable-ui14.js +4 -0
- package/dist/composable-ui15.js +4 -0
- package/dist/composable-ui16.js +4 -0
- package/dist/composable-ui17.js +31 -0
- package/dist/composable-ui18.js +4 -0
- package/dist/composable-ui19.js +4 -0
- package/dist/composable-ui2.js +55 -0
- package/dist/composable-ui20.js +4 -0
- package/dist/composable-ui21.js +100 -0
- package/dist/composable-ui22.js +144 -0
- package/dist/composable-ui23.js +7 -0
- package/dist/composable-ui24.js +7 -0
- package/dist/composable-ui3.js +4 -0
- package/dist/composable-ui4.js +4 -0
- package/dist/composable-ui5.js +4 -0
- package/dist/composable-ui6.js +4 -0
- package/dist/composable-ui7.js +4 -0
- package/dist/composable-ui8.js +4 -0
- package/dist/composable-ui9.js +4 -0
- package/dist/listbox.vue_vue_type_script_setup_true_lang-Bj1ZXiBX.js +69 -0
- package/dist/listboxOption.vue_vue_type_script_setup_true_lang-B_yRptJm.js +37 -0
- package/dist/menu.vue_vue_type_script_setup_true_lang-Ci7q2rOg.js +82 -0
- package/dist/menuItem.vue_vue_type_script_setup_true_lang-mXtMa4gO.js +63 -0
- package/dist/menuItems.vue_vue_type_script_setup_true_lang-p9vftREy.js +49 -0
- package/dist/popover.vue_vue_type_script_setup_true_lang-DhKF7_nY.js +50 -0
- package/dist/popoverDialog.vue_vue_type_script_setup_true_lang-CDXUO7wZ.js +33 -0
- package/dist/tab.vue_vue_type_script_setup_true_lang-Y5OFGqMB.js +29 -0
- package/dist/tabContainer.vue_vue_type_script_setup_true_lang-fPpLno2Z.js +40 -0
- package/dist/tabList.vue_vue_type_script_setup_true_lang-CZyqGCuj.js +48 -0
- package/dist/tabPanel.vue_vue_type_script_setup_true_lang-CGhP6SHR.js +31 -0
- package/dist/tooltip.vue_vue_type_script_setup_true_lang-DVKYJyfL.js +85 -0
- package/dist/types/components/combobox/combobox.vue.d.ts +45 -0
- package/dist/types/components/combobox/comboboxHiddenInput.vue.d.ts +3 -5
- package/dist/types/components/combobox/comboboxInput.vue.d.ts +3 -3
- package/dist/types/components/combobox/comboboxOption.vue.d.ts +12 -14
- package/dist/types/components/combobox/comboboxOptions.vue.d.ts +6 -5
- package/dist/types/components/listbox/listbox.vue.d.ts +11 -11
- package/dist/types/components/listbox/listboxOption.vue.d.ts +12 -14
- package/dist/types/components/menu/menu.vue.d.ts +42 -0
- package/dist/types/components/menu/menuItem.vue.d.ts +13 -15
- package/dist/types/components/menu/menuItems.vue.d.ts +6 -5
- package/dist/types/components/popover/popover.vue.d.ts +40 -0
- package/dist/types/components/popover/popoverDialog.vue.d.ts +6 -5
- package/dist/types/components/tabs/tab.vue.d.ts +9 -11
- package/dist/types/components/tabs/tabContainer.vue.d.ts +8 -7
- package/dist/types/components/tabs/tabList.vue.d.ts +9 -9
- package/dist/types/components/tabs/tabPanel.vue.d.ts +9 -9
- package/dist/types/components/tooltip.vue.d.ts +23 -25
- package/dist/types/composables/list.d.ts +5 -1
- package/dist/types/composables/listOption.d.ts +4 -0
- package/dist/types/main.d.ts +21 -23
- package/dist/types/utils/element.d.ts +2 -2
- package/package.json +11 -8
- package/dist/composable-ui.umd.cjs +0 -1
- package/dist/types/utils/id.d.ts +0 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { inject as l, ref as d, computed as n, onMounted as f, onUnmounted as p, unref as I } from "vue";
|
|
2
|
+
import { injectList as j } from "./composable-ui22.js";
|
|
3
|
+
function S(c, o, i) {
|
|
4
|
+
const e = l(j);
|
|
5
|
+
if (!e)
|
|
6
|
+
throw new Error("List injectable context is not provided");
|
|
7
|
+
const t = d(-1), r = n(() => e.isSelected(t.value)), u = n(() => e.isActive(t.value));
|
|
8
|
+
function s() {
|
|
9
|
+
e.selectItem(t.value);
|
|
10
|
+
}
|
|
11
|
+
function a({ focus: m = !0 } = {}) {
|
|
12
|
+
I(i) || e.activateItem(t.value, { focus: m });
|
|
13
|
+
}
|
|
14
|
+
function v() {
|
|
15
|
+
e.deactivateItem();
|
|
16
|
+
}
|
|
17
|
+
return f(() => {
|
|
18
|
+
t.value = e.addItem(c, o, i);
|
|
19
|
+
}), p(() => {
|
|
20
|
+
e.removeItem(t.value);
|
|
21
|
+
}), {
|
|
22
|
+
isSelected: r,
|
|
23
|
+
isActive: u,
|
|
24
|
+
select: s,
|
|
25
|
+
activate: a,
|
|
26
|
+
deactivate: v
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export {
|
|
30
|
+
S as useListOption
|
|
31
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ref as t, onMounted as V, onBeforeUnmount as M, readonly as m, unref as g } from "vue";
|
|
2
|
+
import { useHTMLElement as b } from "./composable-ui23.js";
|
|
3
|
+
function k(y, h = [], w = !0) {
|
|
4
|
+
const a = t(!1), n = t(!0), l = t(), r = t("");
|
|
5
|
+
let e, u;
|
|
6
|
+
function s() {
|
|
7
|
+
e?.focus();
|
|
8
|
+
}
|
|
9
|
+
function d() {
|
|
10
|
+
n.value = e.validity.valid, l.value = e.validity, r.value = e.validationMessage;
|
|
11
|
+
}
|
|
12
|
+
function f() {
|
|
13
|
+
if (!e) throw new Error("Form element is undefined");
|
|
14
|
+
const o = e.value;
|
|
15
|
+
for (const p of g(h)) {
|
|
16
|
+
const c = p(o);
|
|
17
|
+
if (c !== !0) {
|
|
18
|
+
e.setCustomValidity(c);
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function v() {
|
|
24
|
+
if (!e) throw new Error("Form element is undefined");
|
|
25
|
+
return e.setCustomValidity(""), e.validity.valid && f(), d(), n.value;
|
|
26
|
+
}
|
|
27
|
+
function C(o) {
|
|
28
|
+
d(), g(w) || o.preventDefault();
|
|
29
|
+
}
|
|
30
|
+
function E() {
|
|
31
|
+
v(), a.value = u !== e.value;
|
|
32
|
+
}
|
|
33
|
+
let i = new AbortController();
|
|
34
|
+
return V(() => {
|
|
35
|
+
if (e = b(y).value, !e) throw new Error("Form element is undefined");
|
|
36
|
+
f(), u = e.value, e.addEventListener("change", E, {
|
|
37
|
+
signal: i.signal,
|
|
38
|
+
passive: !0
|
|
39
|
+
}), e.addEventListener("invalid", C, {
|
|
40
|
+
signal: i.signal
|
|
41
|
+
}), e?.autofocus && s();
|
|
42
|
+
}), M(() => {
|
|
43
|
+
i.abort();
|
|
44
|
+
}), {
|
|
45
|
+
focus: s,
|
|
46
|
+
validate: v,
|
|
47
|
+
isValid: n,
|
|
48
|
+
validity: m(l),
|
|
49
|
+
validationMessage: m(r),
|
|
50
|
+
isChanged: a
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
k as useFormControl
|
|
55
|
+
};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ref as _, watch as M, nextTick as k, onMounted as F, onBeforeUnmount as U } from "vue";
|
|
2
|
+
import { useHTMLElement as y } from "./composable-ui23.js";
|
|
3
|
+
function D(z, A, {
|
|
4
|
+
direction: c = "down",
|
|
5
|
+
align: p = "left",
|
|
6
|
+
position: W = "fixed",
|
|
7
|
+
closeOnOutsideClick: B = !0,
|
|
8
|
+
closeOnInsideClick: O = !1
|
|
9
|
+
} = {}) {
|
|
10
|
+
const s = _(!1);
|
|
11
|
+
function v() {
|
|
12
|
+
const t = y(z);
|
|
13
|
+
if (!t.value) throw new Error("Activator element is undefined");
|
|
14
|
+
return t.value;
|
|
15
|
+
}
|
|
16
|
+
function $() {
|
|
17
|
+
const t = y(A);
|
|
18
|
+
if (!t.value) throw new Error("Popover element is undefined");
|
|
19
|
+
return t.value;
|
|
20
|
+
}
|
|
21
|
+
function L({ focus: t = !0 } = {}) {
|
|
22
|
+
s.value = !0, t && k(() => {
|
|
23
|
+
$().focus();
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
function E({ focus: t = !0 } = {}) {
|
|
27
|
+
s.value = !1, t && v().focus();
|
|
28
|
+
}
|
|
29
|
+
function R(t) {
|
|
30
|
+
s.value ? E(t) : L(t);
|
|
31
|
+
}
|
|
32
|
+
function h() {
|
|
33
|
+
if (!s.value) return;
|
|
34
|
+
const t = v(), r = $();
|
|
35
|
+
r.style.position = W;
|
|
36
|
+
const {
|
|
37
|
+
top: f,
|
|
38
|
+
right: l,
|
|
39
|
+
bottom: w,
|
|
40
|
+
left: u,
|
|
41
|
+
width: m,
|
|
42
|
+
height: H
|
|
43
|
+
} = t.getBoundingClientRect(), a = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
|
|
44
|
+
let i = c;
|
|
45
|
+
c == "up" ? f - a < 0 && (i = "down") : c == "down" ? w + a > x && (i = "up") : c == "right" ? l + d > b && (i = "left") : c == "left" && u - d < 0 && (i = "right");
|
|
46
|
+
let o = p;
|
|
47
|
+
p == "left" ? u + d > b && (o = "right") : p == "right" ? l - d < 0 && (o = "left") : p == "top" ? f + a > x && (o = "bottom") : p == "bottom" && w - a < 0 && (o = "top");
|
|
48
|
+
const e = {
|
|
49
|
+
top: "auto",
|
|
50
|
+
bottom: "auto",
|
|
51
|
+
left: "auto",
|
|
52
|
+
right: "auto",
|
|
53
|
+
width: "auto"
|
|
54
|
+
}, n = W === "fixed";
|
|
55
|
+
i == "up" ? e.bottom = `${H + (n ? x - w : 0)}px` : i == "down" ? e.top = `${H + (n ? f : 0)}px` : i == "right" ? e.left = `${m + (n ? u : 0)}px` : i == "left" && (e.right = `${m + (n ? b - l : 0)}px`), ["up", "down"].includes(i) ? o == "right" ? e.right = `${n ? b - l : 0}px` : o == "left" || o == "stretch" ? e.left = `${n ? u : 0}px` : o == "center" && (e.left = `${(n ? u : 0) - (d - m) / 2}px`) : o == "bottom" ? e.bottom = `${n ? x - w : 0}px` : o == "top" ? e.top = `${n ? f : 0}px` : o == "center" && (e.top = `${(n ? f : 0) - (a - H) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (e.width = m + "px");
|
|
56
|
+
for (const P in e)
|
|
57
|
+
r.style[P] = e[P];
|
|
58
|
+
}
|
|
59
|
+
M(
|
|
60
|
+
s,
|
|
61
|
+
(t) => {
|
|
62
|
+
t && k(() => {
|
|
63
|
+
h();
|
|
64
|
+
});
|
|
65
|
+
},
|
|
66
|
+
{ flush: "pre" }
|
|
67
|
+
);
|
|
68
|
+
function T(t) {
|
|
69
|
+
const r = t.target;
|
|
70
|
+
if (!v().contains(r))
|
|
71
|
+
try {
|
|
72
|
+
$().contains(r) ? O && E() : B && (s.value = !1);
|
|
73
|
+
} catch {
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const C = new ResizeObserver(h), g = new AbortController();
|
|
77
|
+
return F(() => {
|
|
78
|
+
window.addEventListener("resize", h, {
|
|
79
|
+
passive: !0,
|
|
80
|
+
signal: g.signal
|
|
81
|
+
}), window.addEventListener("scroll", h, {
|
|
82
|
+
passive: !0,
|
|
83
|
+
//capture: true,
|
|
84
|
+
signal: g.signal
|
|
85
|
+
}), window.addEventListener("click", T, {
|
|
86
|
+
passive: !0,
|
|
87
|
+
signal: g.signal
|
|
88
|
+
}), C.observe(v());
|
|
89
|
+
}), U(() => {
|
|
90
|
+
g.abort(), C.disconnect();
|
|
91
|
+
}), {
|
|
92
|
+
isOpen: s,
|
|
93
|
+
open: L,
|
|
94
|
+
close: E,
|
|
95
|
+
toggle: R
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
D as usePopover
|
|
100
|
+
};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { shallowRef as N, ref as R, computed as g, provide as B, readonly as h, shallowReadonly as J, triggerRef as S, unref as s } from "vue";
|
|
2
|
+
import { useHTMLElement as _ } from "./composable-ui23.js";
|
|
3
|
+
const q = Symbol();
|
|
4
|
+
function d(r, c) {
|
|
5
|
+
const [n, l] = [s(r), s(c)];
|
|
6
|
+
return typeof n == "object" ? typeof l == "object" ? JSON.stringify(n) === JSON.stringify(l) : !1 : n === l;
|
|
7
|
+
}
|
|
8
|
+
function P(r) {
|
|
9
|
+
let c = 0;
|
|
10
|
+
const n = N([]), l = R(), v = g(() => Array.isArray(r.value));
|
|
11
|
+
function o(e) {
|
|
12
|
+
const t = n.value.find((i) => i.id === e);
|
|
13
|
+
if (!t) throw new Error(`Item not found: (${e})`);
|
|
14
|
+
return t;
|
|
15
|
+
}
|
|
16
|
+
function b(e) {
|
|
17
|
+
const t = s(e.element);
|
|
18
|
+
if (t)
|
|
19
|
+
return t.focus(), t;
|
|
20
|
+
}
|
|
21
|
+
function f(e, { focus: t = !1 } = {}) {
|
|
22
|
+
l.value = e?.id ?? void 0, e !== void 0 && t && b(e);
|
|
23
|
+
}
|
|
24
|
+
function O(e, { focus: t = !1 } = {}) {
|
|
25
|
+
const i = o(e);
|
|
26
|
+
return f(i, { focus: t });
|
|
27
|
+
}
|
|
28
|
+
function m(e) {
|
|
29
|
+
return l.value === e;
|
|
30
|
+
}
|
|
31
|
+
function w(e, t, i = !1) {
|
|
32
|
+
const a = _(e), u = c++;
|
|
33
|
+
return n.value.push({
|
|
34
|
+
id: u,
|
|
35
|
+
value: t,
|
|
36
|
+
element: a,
|
|
37
|
+
disabled: i
|
|
38
|
+
}), S(n), u;
|
|
39
|
+
}
|
|
40
|
+
function A(e) {
|
|
41
|
+
m(e) && f();
|
|
42
|
+
const t = o(e), i = n.value.indexOf(t);
|
|
43
|
+
n.value.splice(i, 1), S(n);
|
|
44
|
+
}
|
|
45
|
+
function I(e) {
|
|
46
|
+
const t = o(e);
|
|
47
|
+
if (s(t.disabled)) return;
|
|
48
|
+
const i = s(t.value);
|
|
49
|
+
if (i !== void 0) {
|
|
50
|
+
if (s(v)) {
|
|
51
|
+
const a = r.value.findIndex(
|
|
52
|
+
(u) => d(i, u)
|
|
53
|
+
);
|
|
54
|
+
a > -1 ? r.value.splice(a, 1) : r.value = [...r.value, i];
|
|
55
|
+
} else
|
|
56
|
+
r.value = i;
|
|
57
|
+
f(t);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function y(e) {
|
|
61
|
+
return s(v) ? !!r.value.find(
|
|
62
|
+
(t) => d(e.value, t)
|
|
63
|
+
) : d(r, e.value);
|
|
64
|
+
}
|
|
65
|
+
function L(e) {
|
|
66
|
+
try {
|
|
67
|
+
const t = o(e);
|
|
68
|
+
return y(t);
|
|
69
|
+
} catch {
|
|
70
|
+
return !1;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function j({ focus: e = !1 } = {}) {
|
|
74
|
+
for (let t of n.value)
|
|
75
|
+
if (y(t))
|
|
76
|
+
return f(t, { focus: e });
|
|
77
|
+
}
|
|
78
|
+
function p({ focus: e = !1 } = {}) {
|
|
79
|
+
if (n.value.length)
|
|
80
|
+
return f(n.value[0], { focus: e });
|
|
81
|
+
}
|
|
82
|
+
function x({ focus: e = !1 } = {}) {
|
|
83
|
+
if (n.value.length)
|
|
84
|
+
return f(n.value[n.value.length - 1], { focus: e });
|
|
85
|
+
}
|
|
86
|
+
function E({
|
|
87
|
+
focus: e = !1,
|
|
88
|
+
loop: t = !1
|
|
89
|
+
} = {}) {
|
|
90
|
+
if (l.value === void 0) return p({ focus: e });
|
|
91
|
+
const i = o(l.value), a = n.value.indexOf(i);
|
|
92
|
+
let u;
|
|
93
|
+
if (a + 1 < n.value.length)
|
|
94
|
+
u = n.value[a + 1];
|
|
95
|
+
else if (t)
|
|
96
|
+
u = n.value[0];
|
|
97
|
+
else
|
|
98
|
+
return;
|
|
99
|
+
return f(u, { focus: e });
|
|
100
|
+
}
|
|
101
|
+
function M({
|
|
102
|
+
focus: e = !1,
|
|
103
|
+
loop: t = !1
|
|
104
|
+
} = {}) {
|
|
105
|
+
if (l.value === void 0) return x({ focus: e });
|
|
106
|
+
const i = o(l.value), a = n.value.indexOf(i);
|
|
107
|
+
let u;
|
|
108
|
+
if (a - 1 > -1)
|
|
109
|
+
u = n.value[a - 1];
|
|
110
|
+
else if (t)
|
|
111
|
+
u = n.value[n.value.length - 1];
|
|
112
|
+
else
|
|
113
|
+
return;
|
|
114
|
+
return f(u, { focus: e });
|
|
115
|
+
}
|
|
116
|
+
return B(q, {
|
|
117
|
+
value: h(r),
|
|
118
|
+
selectItem: I,
|
|
119
|
+
activateItem: O,
|
|
120
|
+
deactivateItem: () => f(),
|
|
121
|
+
isSelected: L,
|
|
122
|
+
isActive: m,
|
|
123
|
+
addItem: w,
|
|
124
|
+
removeItem: A
|
|
125
|
+
}), {
|
|
126
|
+
items: J(n),
|
|
127
|
+
isMultiselectable: h(v),
|
|
128
|
+
activeItem: g(
|
|
129
|
+
() => l.value !== void 0 ? o(l.value) : void 0
|
|
130
|
+
),
|
|
131
|
+
selectActiveItem: () => {
|
|
132
|
+
l.value !== void 0 && I(l.value);
|
|
133
|
+
},
|
|
134
|
+
activateSelectedItem: j,
|
|
135
|
+
activateFirstItem: p,
|
|
136
|
+
activateLastItem: x,
|
|
137
|
+
activateNextItem: E,
|
|
138
|
+
activatePrevItem: M
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
q as injectList,
|
|
143
|
+
P as useList
|
|
144
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { defineComponent as m, mergeModels as p, useModel as v, computed as b, createElementBlock as k, openBlock as w, unref as I, renderSlot as h } from "vue";
|
|
2
|
+
import { useList as A } from "./composable-ui22.js";
|
|
3
|
+
const _ = ["aria-activedescendant", "aria-orientation", "aria-multiselectable"], B = /* @__PURE__ */ m({
|
|
4
|
+
__name: "listbox",
|
|
5
|
+
props: /* @__PURE__ */ p({
|
|
6
|
+
orientation: { default: "vertical" },
|
|
7
|
+
loop: { type: Boolean, default: !1 }
|
|
8
|
+
}, {
|
|
9
|
+
modelValue: {},
|
|
10
|
+
modelModifiers: {}
|
|
11
|
+
}),
|
|
12
|
+
emits: ["update:modelValue"],
|
|
13
|
+
setup(i) {
|
|
14
|
+
const e = i, n = v(i, "modelValue"), {
|
|
15
|
+
isMultiselectable: t,
|
|
16
|
+
activeItem: s,
|
|
17
|
+
selectActiveItem: o,
|
|
18
|
+
activateFirstItem: c,
|
|
19
|
+
activateLastItem: u,
|
|
20
|
+
activateNextItem: r,
|
|
21
|
+
activatePrevItem: l
|
|
22
|
+
} = A(n), f = b(() => s.value?.element.value?.id);
|
|
23
|
+
function d(a) {
|
|
24
|
+
switch (a.code) {
|
|
25
|
+
case "Space":
|
|
26
|
+
o();
|
|
27
|
+
break;
|
|
28
|
+
case "ArrowUp":
|
|
29
|
+
if (e.orientation === "horizontal") return;
|
|
30
|
+
l({ focus: !1, loop: e.loop }), t.value || o();
|
|
31
|
+
break;
|
|
32
|
+
case "ArrowDown":
|
|
33
|
+
if (e.orientation === "horizontal") return;
|
|
34
|
+
r({ focus: !1, loop: e.loop }), t.value || o();
|
|
35
|
+
break;
|
|
36
|
+
case "ArrowLeft":
|
|
37
|
+
if (e.orientation === "vertical") return;
|
|
38
|
+
l({ focus: !1, loop: e.loop }), t.value || o();
|
|
39
|
+
break;
|
|
40
|
+
case "ArrowRight":
|
|
41
|
+
if (e.orientation === "vertical") return;
|
|
42
|
+
r({ focus: !1, loop: e.loop }), t.value || o();
|
|
43
|
+
break;
|
|
44
|
+
case "Home":
|
|
45
|
+
c({ focus: !1 });
|
|
46
|
+
break;
|
|
47
|
+
case "End":
|
|
48
|
+
u({ focus: !1 });
|
|
49
|
+
break;
|
|
50
|
+
default:
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
a.preventDefault();
|
|
54
|
+
}
|
|
55
|
+
return (a, x) => (w(), k("div", {
|
|
56
|
+
onKeydown: d,
|
|
57
|
+
"aria-activedescendant": f.value,
|
|
58
|
+
"aria-orientation": a.orientation,
|
|
59
|
+
"aria-multiselectable": I(t),
|
|
60
|
+
role: "listbox",
|
|
61
|
+
tabindex: "0"
|
|
62
|
+
}, [
|
|
63
|
+
h(a.$slots, "default")
|
|
64
|
+
], 40, _));
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
export {
|
|
68
|
+
B as _
|
|
69
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { defineComponent as p, useId as m, useTemplateRef as u, createElementBlock as f, openBlock as b, unref as e, renderSlot as v } from "vue";
|
|
2
|
+
import { useListOption as _ } from "./composable-ui17.js";
|
|
3
|
+
const k = ["id", "aria-disabled", "aria-selected", "data-active"], S = /* @__PURE__ */ p({
|
|
4
|
+
__name: "listboxOption",
|
|
5
|
+
props: {
|
|
6
|
+
id: {},
|
|
7
|
+
value: {},
|
|
8
|
+
disabled: { type: Boolean }
|
|
9
|
+
},
|
|
10
|
+
setup(n) {
|
|
11
|
+
const t = n, r = t.id ?? m(), i = u("itemEl"), { isSelected: s, isActive: o, select: a } = _(
|
|
12
|
+
i,
|
|
13
|
+
t.value,
|
|
14
|
+
t.disabled
|
|
15
|
+
);
|
|
16
|
+
return (d, l) => (b(), f("div", {
|
|
17
|
+
ref_key: "itemEl",
|
|
18
|
+
ref: i,
|
|
19
|
+
id: e(r),
|
|
20
|
+
onClick: l[0] || (l[0] = //@ts-ignore
|
|
21
|
+
(...c) => e(a) && e(a)(...c)),
|
|
22
|
+
"aria-disabled": d.disabled,
|
|
23
|
+
"aria-selected": e(s),
|
|
24
|
+
"data-active": e(o),
|
|
25
|
+
role: "option",
|
|
26
|
+
tabindex: "-1"
|
|
27
|
+
}, [
|
|
28
|
+
v(d.$slots, "default", {
|
|
29
|
+
isSelected: e(s),
|
|
30
|
+
isActive: e(o)
|
|
31
|
+
})
|
|
32
|
+
], 8, k));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export {
|
|
36
|
+
S as _
|
|
37
|
+
};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { defineComponent as b, mergeModels as M, useId as u, useModel as O, computed as m, provide as A, renderSlot as _, unref as h, nextTick as r } from "vue";
|
|
2
|
+
import { usePopover as C } from "./composable-ui21.js";
|
|
3
|
+
import { useList as D } from "./composable-ui22.js";
|
|
4
|
+
import { injectMenu as V } from "./composable-ui24.js";
|
|
5
|
+
const j = /* @__PURE__ */ b({
|
|
6
|
+
__name: "menu",
|
|
7
|
+
props: /* @__PURE__ */ M({
|
|
8
|
+
id: {},
|
|
9
|
+
activatorId: {},
|
|
10
|
+
direction: { default: "down" },
|
|
11
|
+
align: { default: "left" },
|
|
12
|
+
position: { default: "fixed" }
|
|
13
|
+
}, {
|
|
14
|
+
modelValue: {},
|
|
15
|
+
modelModifiers: {}
|
|
16
|
+
}),
|
|
17
|
+
emits: ["update:modelValue"],
|
|
18
|
+
setup(s) {
|
|
19
|
+
const e = s, a = e.id ?? u(), i = e.activatorId ?? u(), p = O(s, "modelValue"), {
|
|
20
|
+
isMultiselectable: v,
|
|
21
|
+
activeItem: f,
|
|
22
|
+
activateFirstItem: n,
|
|
23
|
+
activateLastItem: c,
|
|
24
|
+
activateNextItem: I,
|
|
25
|
+
activatePrevItem: k
|
|
26
|
+
} = D(p), { isOpen: t, toggle: d, open: l, close: w } = C(
|
|
27
|
+
`#${i}`,
|
|
28
|
+
`#${a}`,
|
|
29
|
+
{
|
|
30
|
+
direction: e.direction,
|
|
31
|
+
align: e.align,
|
|
32
|
+
position: e.position,
|
|
33
|
+
closeOnOutsideClick: !0,
|
|
34
|
+
closeOnInsideClick: !1
|
|
35
|
+
}
|
|
36
|
+
);
|
|
37
|
+
function g(o) {
|
|
38
|
+
switch (o.code) {
|
|
39
|
+
case "Space":
|
|
40
|
+
case "Enter":
|
|
41
|
+
d(), t.value && r(n);
|
|
42
|
+
break;
|
|
43
|
+
case "ArrowUp":
|
|
44
|
+
l(), r(c);
|
|
45
|
+
break;
|
|
46
|
+
case "ArrowDown":
|
|
47
|
+
l(), r(n);
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
o.preventDefault();
|
|
53
|
+
}
|
|
54
|
+
const x = m(() => ({
|
|
55
|
+
id: i,
|
|
56
|
+
"aria-controls": t.value ? a : void 0,
|
|
57
|
+
"aria-haspopup": "menu",
|
|
58
|
+
"aria-expanded": t.value,
|
|
59
|
+
onclick: () => d(),
|
|
60
|
+
onkeydown: g,
|
|
61
|
+
tabindex: 0
|
|
62
|
+
}));
|
|
63
|
+
return A(V, {
|
|
64
|
+
menuId: a,
|
|
65
|
+
activatorId: i,
|
|
66
|
+
isOpen: t,
|
|
67
|
+
close: w,
|
|
68
|
+
isMultiselectable: v,
|
|
69
|
+
activeItemId: m(() => f.value?.element.value?.id),
|
|
70
|
+
activateFirstItem: n,
|
|
71
|
+
activateLastItem: c,
|
|
72
|
+
activateNextItem: I,
|
|
73
|
+
activatePrevItem: k
|
|
74
|
+
}), (o, $) => _(o.$slots, "default", {
|
|
75
|
+
attrs: x.value,
|
|
76
|
+
isOpen: h(t)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
export {
|
|
81
|
+
j as _
|
|
82
|
+
};
|