vue-composable-ui 1.0.3 → 1.0.5
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.
|
@@ -8,7 +8,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
8
8
|
inheritAttrs: !1,
|
|
9
9
|
__name: "combobox",
|
|
10
10
|
props: /* @__PURE__ */ H({
|
|
11
|
-
displayValue: { type: Function, default: (e) => Array.isArray(e) ? e.map((
|
|
11
|
+
displayValue: { type: Function, default: (e) => e && Array.isArray(e) ? e.map((o) => o.toString()).join(", ") : e.toString() || void 0 },
|
|
12
12
|
id: {},
|
|
13
13
|
activatorId: {},
|
|
14
14
|
name: {},
|
|
@@ -19,7 +19,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
19
19
|
}),
|
|
20
20
|
emits: ["update:modelValue"],
|
|
21
21
|
setup(e) {
|
|
22
|
-
const
|
|
22
|
+
const o = e, I = p(() => u.value ? l.value.map((a) => o.formValue(a)) : o.formValue(l.value)), l = T(e, "modelValue"), i = o.id ?? j(), y = o.activatorId ?? i, n = `${i}-popover`, { isOpen: t, toggle: E, open: s, close: c } = z(
|
|
23
23
|
`#${y}`,
|
|
24
24
|
`#${n}`,
|
|
25
25
|
{
|
|
@@ -39,7 +39,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
39
39
|
activateLastItem: V,
|
|
40
40
|
activateNextItem: C,
|
|
41
41
|
activatePrevItem: M
|
|
42
|
-
} = G(l), g = p(() =>
|
|
42
|
+
} = G(l), g = p(() => o.displayValue(l.value));
|
|
43
43
|
N(w, () => {
|
|
44
44
|
!f.value && w.value.length && (S({ focus: !1 }), f.value || d({ focus: !1 }));
|
|
45
45
|
});
|
|
@@ -47,7 +47,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
47
47
|
q(`#${y}`).value?.focus();
|
|
48
48
|
}
|
|
49
49
|
function D(a) {
|
|
50
|
-
if (
|
|
50
|
+
if (t.value)
|
|
51
51
|
switch (a.code) {
|
|
52
52
|
case "Space":
|
|
53
53
|
m(), u.value || c({ focus: !0 });
|
|
@@ -99,8 +99,8 @@ const ae = /* @__PURE__ */ B({
|
|
|
99
99
|
onkeydown: D,
|
|
100
100
|
onclick: () => s({ focus: !1 }),
|
|
101
101
|
id: i,
|
|
102
|
-
"aria-controls":
|
|
103
|
-
"aria-expanded":
|
|
102
|
+
"aria-controls": t.value ? n : void 0,
|
|
103
|
+
"aria-expanded": t.value,
|
|
104
104
|
"aria-activedescendant": f.value?.element.value?.id,
|
|
105
105
|
"aria-haspopup": "listbox",
|
|
106
106
|
role: "combobox"
|
|
@@ -108,7 +108,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
108
108
|
return P(J, {
|
|
109
109
|
displayValue: g,
|
|
110
110
|
popoverId: n,
|
|
111
|
-
isOpen:
|
|
111
|
+
isOpen: t,
|
|
112
112
|
open: s,
|
|
113
113
|
close: c,
|
|
114
114
|
focus: O,
|
|
@@ -127,7 +127,7 @@ const ae = /* @__PURE__ */ B({
|
|
|
127
127
|
], 64)) : U("", !0),
|
|
128
128
|
K(a.$slots, "default", {
|
|
129
129
|
popoverId: n,
|
|
130
|
-
isOpen: k(
|
|
130
|
+
isOpen: k(t),
|
|
131
131
|
toggle: () => k(E)(),
|
|
132
132
|
displayValue: g.value,
|
|
133
133
|
attrs: x.value
|
package/dist/composable-ui.js
CHANGED
|
@@ -16,7 +16,7 @@ import { _ as k } from "./tooltip.vue_vue_type_script_setup_true_lang-D4uAZmQb.j
|
|
|
16
16
|
import { _ as w } from "./menu.vue_vue_type_script_setup_true_lang-Ci7q2rOg.js";
|
|
17
17
|
import { _ as z } from "./menuItems.vue_vue_type_script_setup_true_lang-p9vftREy.js";
|
|
18
18
|
import { _ as B } from "./menuItem.vue_vue_type_script_setup_true_lang-ezPw3j-i.js";
|
|
19
|
-
import { _ as J } from "./combobox.vue_vue_type_script_setup_true_lang-
|
|
19
|
+
import { _ as J } from "./combobox.vue_vue_type_script_setup_true_lang-CAbgDlD9.js";
|
|
20
20
|
import { _ as N } from "./comboboxInput.vue_vue_type_script_setup_true_lang-DzRfJ5ke.js";
|
|
21
21
|
import { _ as R } from "./comboboxOptions.vue_vue_type_script_setup_true_lang-Doy6MfEQ.js";
|
|
22
22
|
import { _ as U } from "./comboboxOption.vue_vue_type_script_setup_true_lang-DPEArk3M.js";
|
package/dist/composable-ui20.js
CHANGED
package/dist/composable-ui21.js
CHANGED
|
@@ -1,80 +1,83 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useHTMLElement as
|
|
3
|
-
function
|
|
1
|
+
import { ref as T, watch as _, nextTick as P, onBeforeMount as F, onMounted as U, onBeforeUnmount as j } from "vue";
|
|
2
|
+
import { useHTMLElement as k } from "./composable-ui23.js";
|
|
3
|
+
function G(y, z, {
|
|
4
4
|
direction: c = "down",
|
|
5
|
-
align:
|
|
6
|
-
position:
|
|
7
|
-
closeOnOutsideClick:
|
|
8
|
-
closeOnInsideClick:
|
|
5
|
+
align: u = "left",
|
|
6
|
+
position: L = "fixed",
|
|
7
|
+
closeOnOutsideClick: A = !0,
|
|
8
|
+
closeOnInsideClick: M = !1
|
|
9
9
|
} = {}) {
|
|
10
|
-
const s =
|
|
10
|
+
const s = T(!1);
|
|
11
11
|
function v() {
|
|
12
|
-
const
|
|
13
|
-
if (!
|
|
14
|
-
return
|
|
12
|
+
const e = k(y);
|
|
13
|
+
if (!e.value) throw new Error("Activator element is undefined");
|
|
14
|
+
return e.value;
|
|
15
15
|
}
|
|
16
16
|
function $() {
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
19
|
-
return
|
|
17
|
+
const e = k(z);
|
|
18
|
+
if (!e.value) throw new Error("Popover element is undefined");
|
|
19
|
+
return e.value;
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
s.value = !0,
|
|
21
|
+
function B({ focus: e = !0 } = {}) {
|
|
22
|
+
s.value = !0, e && P(() => {
|
|
23
23
|
$().focus();
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
|
-
function E({ focus:
|
|
27
|
-
s.value = !1,
|
|
26
|
+
function E({ focus: e = !0 } = {}) {
|
|
27
|
+
s.value = !1, e && v().focus();
|
|
28
28
|
}
|
|
29
|
-
function
|
|
30
|
-
s.value ? E(
|
|
29
|
+
function O(e) {
|
|
30
|
+
s.value ? E(e) : B(e);
|
|
31
31
|
}
|
|
32
32
|
function h() {
|
|
33
33
|
if (!s.value) return;
|
|
34
|
-
const
|
|
35
|
-
r.style.position =
|
|
34
|
+
const e = v(), r = $();
|
|
35
|
+
r.style.position = L;
|
|
36
36
|
const {
|
|
37
37
|
top: f,
|
|
38
38
|
right: l,
|
|
39
39
|
bottom: w,
|
|
40
|
-
left:
|
|
40
|
+
left: p,
|
|
41
41
|
width: m,
|
|
42
|
-
height:
|
|
43
|
-
} =
|
|
42
|
+
height: W
|
|
43
|
+
} = e.getBoundingClientRect(), a = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
|
|
44
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" &&
|
|
46
|
-
let o =
|
|
47
|
-
|
|
48
|
-
const
|
|
45
|
+
c == "up" ? f - a < 0 && (i = "down") : c == "down" ? w + a > x && (i = "up") : c == "right" ? l + d > b && (i = "left") : c == "left" && p - d < 0 && (i = "right");
|
|
46
|
+
let o = u;
|
|
47
|
+
u == "left" ? p + d > b && (o = "right") : u == "right" ? l - d < 0 && (o = "left") : u == "top" ? f + a > x && (o = "bottom") : u == "bottom" && w - a < 0 && (o = "top");
|
|
48
|
+
const t = {
|
|
49
49
|
top: "auto",
|
|
50
50
|
bottom: "auto",
|
|
51
51
|
left: "auto",
|
|
52
52
|
right: "auto",
|
|
53
53
|
width: "auto"
|
|
54
|
-
}, n =
|
|
55
|
-
i == "up" ?
|
|
56
|
-
for (const
|
|
57
|
-
r.style[
|
|
54
|
+
}, n = L === "fixed";
|
|
55
|
+
i == "up" ? t.bottom = `${W + (n ? x - w : 0)}px` : i == "down" ? t.top = `${W + (n ? f : 0)}px` : i == "right" ? t.left = `${m + (n ? p : 0)}px` : i == "left" && (t.right = `${m + (n ? b - l : 0)}px`), ["up", "down"].includes(i) ? o == "right" ? t.right = `${n ? b - l : 0}px` : o == "left" || o == "stretch" ? t.left = `${n ? p : 0}px` : o == "center" && (t.left = `${(n ? p : 0) - (d - m) / 2}px`) : o == "bottom" ? t.bottom = `${n ? x - w : 0}px` : o == "top" ? t.top = `${n ? f : 0}px` : o == "center" && (t.top = `${(n ? f : 0) - (a - W) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (t.width = m + "px");
|
|
56
|
+
for (const C in t)
|
|
57
|
+
r.style[C] = t[C];
|
|
58
58
|
}
|
|
59
|
-
|
|
59
|
+
_(
|
|
60
60
|
s,
|
|
61
|
-
(
|
|
62
|
-
|
|
61
|
+
(e) => {
|
|
62
|
+
e && P(() => {
|
|
63
63
|
h();
|
|
64
64
|
});
|
|
65
65
|
},
|
|
66
66
|
{ flush: "pre" }
|
|
67
67
|
);
|
|
68
|
-
function
|
|
69
|
-
const r =
|
|
68
|
+
function R(e) {
|
|
69
|
+
const r = e.target;
|
|
70
70
|
if (!v().contains(r))
|
|
71
71
|
try {
|
|
72
|
-
$().contains(r) ?
|
|
72
|
+
$().contains(r) ? M && E() : A && (s.value = !1);
|
|
73
73
|
} catch {
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
let H;
|
|
77
|
+
const g = new AbortController();
|
|
77
78
|
return F(() => {
|
|
79
|
+
H = new ResizeObserver(h);
|
|
80
|
+
}), U(() => {
|
|
78
81
|
window.addEventListener("resize", h, {
|
|
79
82
|
passive: !0,
|
|
80
83
|
signal: g.signal
|
|
@@ -82,19 +85,19 @@ function D(z, A, {
|
|
|
82
85
|
passive: !0,
|
|
83
86
|
//capture: true,
|
|
84
87
|
signal: g.signal
|
|
85
|
-
}), window.addEventListener("click",
|
|
88
|
+
}), window.addEventListener("click", R, {
|
|
86
89
|
passive: !0,
|
|
87
90
|
signal: g.signal
|
|
88
|
-
}),
|
|
89
|
-
}),
|
|
90
|
-
g.abort(),
|
|
91
|
+
}), H.observe(v());
|
|
92
|
+
}), j(() => {
|
|
93
|
+
g.abort(), H.disconnect();
|
|
91
94
|
}), {
|
|
92
95
|
isOpen: s,
|
|
93
|
-
open:
|
|
96
|
+
open: B,
|
|
94
97
|
close: E,
|
|
95
|
-
toggle:
|
|
98
|
+
toggle: O
|
|
96
99
|
};
|
|
97
100
|
}
|
|
98
101
|
export {
|
|
99
|
-
|
|
102
|
+
G as usePopover
|
|
100
103
|
};
|