vue-composable-ui 1.1.2 → 1.1.4
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/composable-ui23.js +45 -40
- package/package.json +1 -1
package/dist/composable-ui23.js
CHANGED
|
@@ -1,90 +1,95 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { useHTMLElement as
|
|
3
|
-
function G(
|
|
1
|
+
import { ref as _, watch as F, nextTick as y, onBeforeMount as U, onMounted as V, onBeforeUnmount as j, toValue as z } from "vue";
|
|
2
|
+
import { useHTMLElement as A } from "./composable-ui24.js";
|
|
3
|
+
function G(L, B, {
|
|
4
4
|
direction: c = "down",
|
|
5
5
|
align: u = "left",
|
|
6
|
-
position:
|
|
7
|
-
closeOnOutsideClick:
|
|
8
|
-
closeOnInsideClick:
|
|
6
|
+
position: C = "fixed",
|
|
7
|
+
closeOnOutsideClick: M = !0,
|
|
8
|
+
closeOnInsideClick: O = !1
|
|
9
9
|
} = {}) {
|
|
10
|
-
const s =
|
|
10
|
+
const s = _(!1);
|
|
11
11
|
function v() {
|
|
12
|
-
const e =
|
|
13
|
-
if (!e.value)
|
|
12
|
+
const e = A(L);
|
|
13
|
+
if (!e.value)
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Activator element is undefined: " + z(L)
|
|
16
|
+
);
|
|
14
17
|
return e.value;
|
|
15
18
|
}
|
|
16
19
|
function $() {
|
|
17
|
-
const e =
|
|
18
|
-
if (!e.value)
|
|
20
|
+
const e = A(B);
|
|
21
|
+
if (!e.value)
|
|
22
|
+
throw new Error("Popover element is undefined: " + z(B));
|
|
19
23
|
return e.value;
|
|
20
24
|
}
|
|
21
|
-
function
|
|
22
|
-
s.value = !0, e &&
|
|
25
|
+
function P({ focus: e = !0 } = {}) {
|
|
26
|
+
s.value = !0, e && y(() => {
|
|
23
27
|
$().focus();
|
|
24
28
|
});
|
|
25
29
|
}
|
|
26
30
|
function E({ focus: e = !0 } = {}) {
|
|
27
31
|
s.value = !1, e && v().focus();
|
|
28
32
|
}
|
|
29
|
-
function
|
|
30
|
-
s.value ? E(e) :
|
|
33
|
+
function R(e) {
|
|
34
|
+
s.value ? E(e) : P(e);
|
|
31
35
|
}
|
|
32
36
|
function h() {
|
|
33
37
|
if (!s.value) return;
|
|
34
38
|
const e = v(), r = $();
|
|
35
|
-
r.style.position =
|
|
39
|
+
r.style.position = C;
|
|
36
40
|
const {
|
|
37
41
|
top: f,
|
|
38
42
|
right: l,
|
|
39
43
|
bottom: w,
|
|
40
|
-
left:
|
|
44
|
+
left: a,
|
|
41
45
|
width: m,
|
|
42
46
|
height: W
|
|
43
|
-
} = e.getBoundingClientRect(),
|
|
47
|
+
} = e.getBoundingClientRect(), p = r.offsetHeight, d = r.offsetWidth, x = document.documentElement.clientHeight, b = document.documentElement.clientWidth;
|
|
44
48
|
let i = c;
|
|
45
|
-
c == "up" ? f -
|
|
49
|
+
c == "up" ? f - p < 0 && (i = "down") : c == "down" ? w + p > x && (i = "up") : c == "right" ? l + d > b && (i = "left") : c == "left" && a - d < 0 && (i = "right");
|
|
46
50
|
let o = u;
|
|
47
|
-
u == "left" ?
|
|
51
|
+
u == "left" ? a + d > b && (o = "right") : u == "right" ? l - d < 0 && (o = "left") : u == "top" ? f + p > x && (o = "bottom") : u == "bottom" && w - p < 0 && (o = "top");
|
|
48
52
|
const t = {
|
|
49
53
|
top: "auto",
|
|
50
54
|
bottom: "auto",
|
|
51
55
|
left: "auto",
|
|
52
56
|
right: "auto",
|
|
53
57
|
width: "auto"
|
|
54
|
-
}, n =
|
|
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 ?
|
|
56
|
-
for (const
|
|
57
|
-
r.style[
|
|
58
|
+
}, n = C === "fixed";
|
|
59
|
+
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 ? a : 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 ? a : 0}px` : o == "center" && (t.left = `${(n ? a : 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) - (p - W) / 2}px`), ["up", "down"].includes(i) && o === "stretch" && (t.width = m + "px");
|
|
60
|
+
for (const k in t)
|
|
61
|
+
r.style[k] = t[k];
|
|
58
62
|
}
|
|
59
|
-
|
|
63
|
+
F(
|
|
64
|
+
s,
|
|
65
|
+
(e) => {
|
|
66
|
+
e && y(() => {
|
|
67
|
+
h();
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
{ flush: "pre" }
|
|
71
|
+
);
|
|
72
|
+
function T(e) {
|
|
60
73
|
const r = e.target;
|
|
61
74
|
if (!v().contains(r))
|
|
62
75
|
try {
|
|
63
|
-
$().contains(r) ?
|
|
76
|
+
$().contains(r) ? O && E() : M && (s.value = !1);
|
|
64
77
|
} catch {
|
|
65
78
|
}
|
|
66
79
|
}
|
|
67
80
|
let H;
|
|
68
81
|
const g = new AbortController();
|
|
69
|
-
return
|
|
82
|
+
return U(() => {
|
|
70
83
|
H = new ResizeObserver(h);
|
|
71
|
-
}),
|
|
72
|
-
|
|
73
|
-
s,
|
|
74
|
-
(e) => {
|
|
75
|
-
e && P(() => {
|
|
76
|
-
h();
|
|
77
|
-
});
|
|
78
|
-
},
|
|
79
|
-
{ flush: "pre" }
|
|
80
|
-
), window.addEventListener("resize", h, {
|
|
84
|
+
}), V(() => {
|
|
85
|
+
window.addEventListener("resize", h, {
|
|
81
86
|
passive: !0,
|
|
82
87
|
signal: g.signal
|
|
83
88
|
}), window.addEventListener("scroll", h, {
|
|
84
89
|
passive: !0,
|
|
85
90
|
//capture: true,
|
|
86
91
|
signal: g.signal
|
|
87
|
-
}), window.addEventListener("click",
|
|
92
|
+
}), window.addEventListener("click", T, {
|
|
88
93
|
passive: !0,
|
|
89
94
|
signal: g.signal
|
|
90
95
|
}), H.observe(v());
|
|
@@ -92,9 +97,9 @@ function G(y, z, {
|
|
|
92
97
|
g.abort(), H.disconnect();
|
|
93
98
|
}), {
|
|
94
99
|
isOpen: s,
|
|
95
|
-
open:
|
|
100
|
+
open: P,
|
|
96
101
|
close: E,
|
|
97
|
-
toggle:
|
|
102
|
+
toggle: R
|
|
98
103
|
};
|
|
99
104
|
}
|
|
100
105
|
export {
|