vue-composable-ui 0.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/LICENSE +1 -1
- package/README.md +5 -1
- 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 +49 -0
- 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 +6 -0
- package/dist/types/components/combobox/comboboxInput.vue.d.ts +9 -0
- package/dist/types/components/combobox/comboboxOption.vue.d.ts +20 -0
- package/dist/types/components/combobox/comboboxOptions.vue.d.ts +12 -0
- package/dist/types/components/injectionKeys.d.ts +43 -0
- package/dist/types/components/listbox/listbox.vue.d.ts +26 -0
- package/dist/types/components/listbox/listboxOption.vue.d.ts +20 -0
- package/dist/types/components/menu/menu.vue.d.ts +42 -0
- package/dist/types/components/menu/menuItem.vue.d.ts +24 -0
- package/dist/types/components/menu/menuItems.vue.d.ts +12 -0
- package/dist/types/components/popover/popover.vue.d.ts +40 -0
- package/dist/types/components/popover/popoverDialog.vue.d.ts +12 -0
- package/dist/types/components/tabs/tab.vue.d.ts +17 -0
- package/dist/types/components/tabs/tabContainer.vue.d.ts +19 -0
- package/dist/types/components/tabs/tabList.vue.d.ts +17 -0
- package/dist/types/components/tabs/tabPanel.vue.d.ts +15 -0
- package/dist/types/components/tooltip.vue.d.ts +34 -0
- package/dist/types/composables/formControl.d.ts +48 -0
- package/dist/types/composables/list.d.ts +107 -0
- package/dist/types/composables/listOption.d.ts +34 -0
- package/dist/types/composables/popover.d.ts +68 -0
- package/dist/types/main.d.ts +22 -0
- package/dist/types/utils/element.d.ts +3 -0
- package/package.json +28 -12
- package/.github/workflows/deploy.yml +0 -21
- package/.github/workflows/docs.yml +0 -62
- package/.vscode/extensions.json +0 -7
- package/docs/.vitepress/config.mts +0 -40
- package/docs/.vitepress/theme/index.js +0 -4
- package/docs/.vitepress/theme/style.scss +0 -155
- package/docs/components/combobox.md +0 -174
- package/docs/components/demos/combobox.vue +0 -142
- package/docs/components/demos/combobox_autocomplete.vue +0 -75
- package/docs/components/demos/combobox_tags.vue +0 -127
- package/docs/components/demos/input.vue +0 -35
- package/docs/components/demos/listbox.vue +0 -64
- package/docs/components/demos/menu.vue +0 -93
- package/docs/components/demos/popover.vue +0 -16
- package/docs/components/demos/tabs.vue +0 -59
- package/docs/components/demos/tooltip.vue +0 -27
- package/docs/components/listbox.md +0 -9
- package/docs/components/menu.md +0 -121
- package/docs/components/popover.md +0 -82
- package/docs/components/tabs.md +0 -9
- package/docs/components/tooltip.md +0 -78
- package/docs/composables/form-control.md +0 -130
- package/docs/composables/list-option.md +0 -47
- package/docs/composables/list.md +0 -192
- package/docs/composables/popover.md +0 -90
- package/docs/index.md +0 -24
- package/docs/intro.md +0 -0
- package/src/components/combobox/combobox.vue +0 -229
- package/src/components/combobox/comboboxFormInput.vue +0 -33
- package/src/components/combobox/comboboxOption.vue +0 -52
- package/src/components/combobox/comboboxOptions.vue +0 -17
- package/src/components/injectionKeys.ts +0 -50
- package/src/components/listbox/listbox.vue +0 -91
- package/src/components/listbox/listboxOption.vue +0 -37
- package/src/components/menu/menu.vue +0 -100
- package/src/components/menu/menuItem.vue +0 -86
- package/src/components/menu/menuItems.vue +0 -51
- package/src/components/popover/popover.vue +0 -68
- package/src/components/popover/popoverDialog.vue +0 -35
- package/src/components/tabs/tab.vue +0 -35
- package/src/components/tabs/tabContainer.vue +0 -50
- package/src/components/tabs/tabList.vue +0 -52
- package/src/components/tabs/tabPanel.vue +0 -36
- package/src/components/tooltip.vue +0 -115
- package/src/composables/formControl.ts +0 -144
- package/src/composables/list.ts +0 -326
- package/src/composables/listOption.ts +0 -80
- package/src/composables/popover.ts +0 -306
- package/src/main.ts +0 -65
- package/src/utils/element.ts +0 -19
- package/src/utils/id.ts +0 -5
- package/src/vite-env.d.ts +0 -1
- package/tsconfig.json +0 -27
- package/tsconfig.node.json +0 -10
- package/vite.config.ts +0 -28
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { defineComponent as w, useId as y, useTemplateRef as S, inject as h, computed as j, createElementBlock as A, openBlock as B, unref as t, renderSlot as I } from "vue";
|
|
2
|
+
import { useListOption as _ } from "./composable-ui17.js";
|
|
3
|
+
import { injectMenu as $ } from "./composable-ui24.js";
|
|
4
|
+
const x = ["id", "data-active", "role", "aria-checked", "aria-disabled"], L = /* @__PURE__ */ w({
|
|
5
|
+
__name: "menuItem",
|
|
6
|
+
props: {
|
|
7
|
+
id: {},
|
|
8
|
+
value: {},
|
|
9
|
+
disabled: { type: Boolean }
|
|
10
|
+
},
|
|
11
|
+
emits: ["select"],
|
|
12
|
+
setup(d, { emit: r }) {
|
|
13
|
+
const e = d, u = r, m = e.id ?? y(), l = S("itemEl"), { isSelected: s, isActive: c, select: v, activate: f, deactivate: p } = _(
|
|
14
|
+
l,
|
|
15
|
+
e.value,
|
|
16
|
+
e.disabled
|
|
17
|
+
), i = h($);
|
|
18
|
+
if (!i)
|
|
19
|
+
throw new Error("Menu injectable context is not provided");
|
|
20
|
+
const b = j(() => e.value !== void 0 ? i.isMultiselectable.value ? "menuitemcheckbox" : "menuitemradio" : "menuitem");
|
|
21
|
+
function a() {
|
|
22
|
+
v(), u("select", e.value);
|
|
23
|
+
}
|
|
24
|
+
function k() {
|
|
25
|
+
a(), (e.value === void 0 || !i?.isMultiselectable.value) && i.close();
|
|
26
|
+
}
|
|
27
|
+
function E(o) {
|
|
28
|
+
switch (o.code) {
|
|
29
|
+
case "Space":
|
|
30
|
+
a(), e.value === void 0 && i.close();
|
|
31
|
+
break;
|
|
32
|
+
case "Enter":
|
|
33
|
+
a(), i.close();
|
|
34
|
+
break;
|
|
35
|
+
default:
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
o.preventDefault();
|
|
39
|
+
}
|
|
40
|
+
return (o, n) => (B(), A("div", {
|
|
41
|
+
ref_key: "itemEl",
|
|
42
|
+
ref: l,
|
|
43
|
+
id: t(m),
|
|
44
|
+
onClick: k,
|
|
45
|
+
onKeydown: E,
|
|
46
|
+
onMouseenter: n[0] || (n[0] = (M) => t(f)({ focus: !1 })),
|
|
47
|
+
onMouseleave: n[1] || (n[1] = (M) => t(p)()),
|
|
48
|
+
"data-active": t(c),
|
|
49
|
+
role: b.value,
|
|
50
|
+
"aria-checked": o.value !== void 0 ? t(s) : void 0,
|
|
51
|
+
"aria-disabled": o.disabled || void 0,
|
|
52
|
+
tabindex: "-1"
|
|
53
|
+
}, [
|
|
54
|
+
I(o.$slots, "default", {
|
|
55
|
+
isSelected: t(s),
|
|
56
|
+
isActive: t(c)
|
|
57
|
+
})
|
|
58
|
+
], 40, x));
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
export {
|
|
62
|
+
L as _
|
|
63
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { defineComponent as n, inject as o, createElementBlock as c, createCommentVNode as s, unref as a, openBlock as i, renderSlot as u } from "vue";
|
|
2
|
+
import { injectMenu as l } from "./composable-ui24.js";
|
|
3
|
+
const d = ["id", "aria-activedescendant", "aria-labelledby"], b = /* @__PURE__ */ n({
|
|
4
|
+
__name: "menuItems",
|
|
5
|
+
setup(m) {
|
|
6
|
+
const e = o(l);
|
|
7
|
+
if (!e)
|
|
8
|
+
throw new Error("Menu injectable context is not provided");
|
|
9
|
+
function r(t) {
|
|
10
|
+
switch (t.code) {
|
|
11
|
+
case "ArrowUp":
|
|
12
|
+
e.activatePrevItem({ focus: !0, loop: !1 });
|
|
13
|
+
break;
|
|
14
|
+
case "ArrowDown":
|
|
15
|
+
e.activateNextItem({ focus: !0, loop: !1 });
|
|
16
|
+
break;
|
|
17
|
+
case "Home":
|
|
18
|
+
e.activateFirstItem({ focus: !0 });
|
|
19
|
+
break;
|
|
20
|
+
case "End":
|
|
21
|
+
e.activateLastItem({ focus: !0 });
|
|
22
|
+
break;
|
|
23
|
+
case "Escape":
|
|
24
|
+
e.close();
|
|
25
|
+
break;
|
|
26
|
+
case "Tab":
|
|
27
|
+
e.isOpen.value = !1;
|
|
28
|
+
return;
|
|
29
|
+
default:
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
t.preventDefault();
|
|
33
|
+
}
|
|
34
|
+
return (t, f) => a(e).isOpen.value ? (i(), c("div", {
|
|
35
|
+
key: 0,
|
|
36
|
+
onKeydown: r,
|
|
37
|
+
id: a(e).menuId,
|
|
38
|
+
"aria-activedescendant": a(e).activeItemId.value,
|
|
39
|
+
"aria-labelledby": a(e).activatorId,
|
|
40
|
+
role: "menu",
|
|
41
|
+
tabindex: "-1"
|
|
42
|
+
}, [
|
|
43
|
+
u(t.$slots, "default")
|
|
44
|
+
], 40, d)) : s("", !0);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
export {
|
|
48
|
+
b as _
|
|
49
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { defineComponent as u, useId as r, computed as f, provide as v, renderSlot as O, unref as t } from "vue";
|
|
2
|
+
import { usePopover as m } from "./composable-ui21.js";
|
|
3
|
+
import { injectPopover as g } from "./composable-ui24.js";
|
|
4
|
+
const x = /* @__PURE__ */ u({
|
|
5
|
+
__name: "popover",
|
|
6
|
+
props: {
|
|
7
|
+
id: {},
|
|
8
|
+
activatorId: {},
|
|
9
|
+
direction: { default: "down" },
|
|
10
|
+
align: { default: "left" },
|
|
11
|
+
position: { default: "fixed" },
|
|
12
|
+
closeOnOutsideClick: { type: Boolean, default: !0 },
|
|
13
|
+
closeOnInsideClick: { type: Boolean, default: !1 },
|
|
14
|
+
role: { default: "dialog" }
|
|
15
|
+
},
|
|
16
|
+
setup(s) {
|
|
17
|
+
const e = s, n = e.id ?? r(), i = e.activatorId ?? r(), { isOpen: o, toggle: a, open: d, close: l } = m(
|
|
18
|
+
`#${i}`,
|
|
19
|
+
`#${n}`,
|
|
20
|
+
{
|
|
21
|
+
direction: e.direction,
|
|
22
|
+
align: e.align,
|
|
23
|
+
position: e.position,
|
|
24
|
+
closeOnOutsideClick: e.closeOnOutsideClick,
|
|
25
|
+
closeOnInsideClick: e.closeOnInsideClick
|
|
26
|
+
}
|
|
27
|
+
), c = f(() => ({
|
|
28
|
+
id: i,
|
|
29
|
+
"aria-controls": o.value ? e.id : void 0,
|
|
30
|
+
"aria-haspopup": e.role,
|
|
31
|
+
"aria-expanded": o.value
|
|
32
|
+
}));
|
|
33
|
+
return v(g, {
|
|
34
|
+
popoverId: n,
|
|
35
|
+
activatorId: i,
|
|
36
|
+
role: e.role,
|
|
37
|
+
isOpen: o,
|
|
38
|
+
close: l
|
|
39
|
+
}), (p, I) => O(p.$slots, "default", {
|
|
40
|
+
attrs: c.value,
|
|
41
|
+
isOpen: t(o),
|
|
42
|
+
toggle: () => t(a)(),
|
|
43
|
+
open: () => t(d)(),
|
|
44
|
+
close: () => t(l)()
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export {
|
|
49
|
+
x as _
|
|
50
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineComponent as n, inject as a, createElementBlock as i, createCommentVNode as c, unref as r, openBlock as l, renderSlot as p } from "vue";
|
|
2
|
+
import { injectPopover as d } from "./composable-ui24.js";
|
|
3
|
+
const s = ["id", "role", "aria-labelledby"], v = /* @__PURE__ */ n({
|
|
4
|
+
__name: "popoverDialog",
|
|
5
|
+
setup(u) {
|
|
6
|
+
const e = a(d);
|
|
7
|
+
if (!e)
|
|
8
|
+
throw new Error("Popover injectable context is not provided");
|
|
9
|
+
function t(o) {
|
|
10
|
+
switch (o.code) {
|
|
11
|
+
case "Escape":
|
|
12
|
+
e.close();
|
|
13
|
+
break;
|
|
14
|
+
default:
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
o.preventDefault();
|
|
18
|
+
}
|
|
19
|
+
return (o, f) => r(e).isOpen.value ? (l(), i("div", {
|
|
20
|
+
key: 0,
|
|
21
|
+
onKeydown: t,
|
|
22
|
+
id: r(e).popoverId,
|
|
23
|
+
role: r(e).role,
|
|
24
|
+
"aria-labelledby": r(e).activatorId,
|
|
25
|
+
tabindex: "-1"
|
|
26
|
+
}, [
|
|
27
|
+
p(o.$slots, "default")
|
|
28
|
+
], 40, s)) : c("", !0);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
export {
|
|
32
|
+
v as _
|
|
33
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineComponent as u, useTemplateRef as b, useId as s, createElementBlock as f, openBlock as m, unref as e, renderSlot as _ } from "vue";
|
|
2
|
+
import { useListOption as k } from "./composable-ui17.js";
|
|
3
|
+
const C = ["id", "aria-selected", "aria-controls", "tabindex"], v = /* @__PURE__ */ u({
|
|
4
|
+
__name: "tab",
|
|
5
|
+
props: {
|
|
6
|
+
id: {},
|
|
7
|
+
ariaControls: {},
|
|
8
|
+
value: {}
|
|
9
|
+
},
|
|
10
|
+
setup(i) {
|
|
11
|
+
const t = i, o = b("tab"), { isSelected: a, select: n } = k(o, t.value), l = t.id ?? s(), c = t.ariaControls ?? s();
|
|
12
|
+
return (d, r) => (m(), f("button", {
|
|
13
|
+
ref_key: "tab",
|
|
14
|
+
ref: o,
|
|
15
|
+
onClick: r[0] || (r[0] = //@ts-ignore
|
|
16
|
+
(...p) => e(n) && e(n)(...p)),
|
|
17
|
+
id: e(l),
|
|
18
|
+
"aria-selected": e(a),
|
|
19
|
+
"aria-controls": e(c),
|
|
20
|
+
tabindex: e(a) ? 0 : -1,
|
|
21
|
+
role: "tab"
|
|
22
|
+
}, [
|
|
23
|
+
_(d.$slots, "default")
|
|
24
|
+
], 8, C));
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
export {
|
|
28
|
+
v as _
|
|
29
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { defineComponent as c, useModel as u, provide as v, computed as p, createElementBlock as f, openBlock as I, renderSlot as _ } from "vue";
|
|
2
|
+
import { useList as b } from "./composable-ui22.js";
|
|
3
|
+
import { injectTabs as g } from "./composable-ui24.js";
|
|
4
|
+
const x = /* @__PURE__ */ c({
|
|
5
|
+
__name: "tabContainer",
|
|
6
|
+
props: {
|
|
7
|
+
modelValue: {},
|
|
8
|
+
modelModifiers: {}
|
|
9
|
+
},
|
|
10
|
+
emits: ["update:modelValue"],
|
|
11
|
+
setup(o) {
|
|
12
|
+
const a = u(o, "modelValue"), {
|
|
13
|
+
items: i,
|
|
14
|
+
selectActiveItem: l,
|
|
15
|
+
activateFirstItem: m,
|
|
16
|
+
activateLastItem: r,
|
|
17
|
+
activateNextItem: n,
|
|
18
|
+
activatePrevItem: s
|
|
19
|
+
} = b(a);
|
|
20
|
+
return v(g, {
|
|
21
|
+
getIds: (e) => p(() => {
|
|
22
|
+
const t = i.value.find((d) => d.value === e);
|
|
23
|
+
return {
|
|
24
|
+
tabId: t?.element.value?.getAttribute("id") || void 0,
|
|
25
|
+
panelId: t?.element.value?.getAttribute("aria-controls") || void 0
|
|
26
|
+
};
|
|
27
|
+
}),
|
|
28
|
+
selectActiveItem: l,
|
|
29
|
+
activateFirstItem: m,
|
|
30
|
+
activateLastItem: r,
|
|
31
|
+
activateNextItem: n,
|
|
32
|
+
activatePrevItem: s
|
|
33
|
+
}), (e, t) => (I(), f("div", null, [
|
|
34
|
+
_(e.$slots, "default")
|
|
35
|
+
]));
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
export {
|
|
39
|
+
x as _
|
|
40
|
+
};
|