adverich-kun-ui 0.1.280 → 0.1.281
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,52 +1,36 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
function
|
|
3
|
-
const
|
|
1
|
+
import { ref as a, computed as x } from "vue";
|
|
2
|
+
function q(n, p, u, w) {
|
|
3
|
+
const f = a({}), c = a(null), g = a(null), H = {
|
|
4
4
|
top: { class: "origin-bottom" },
|
|
5
5
|
bottom: { class: "origin-top" },
|
|
6
6
|
left: { class: "origin-right" },
|
|
7
7
|
right: { class: "origin-left" }
|
|
8
|
-
},
|
|
8
|
+
}, M = x(() => {
|
|
9
9
|
var t;
|
|
10
|
-
return ((t =
|
|
10
|
+
return ((t = H[n.location]) == null ? void 0 : t.class) || "origin-top";
|
|
11
11
|
});
|
|
12
|
-
function
|
|
13
|
-
const o = n.parentRef ||
|
|
12
|
+
function s(t = 0) {
|
|
13
|
+
const o = n.parentRef || g.value, i = c.value;
|
|
14
14
|
if (!(o instanceof HTMLElement) || !(i instanceof HTMLElement)) return;
|
|
15
15
|
const e = o.getBoundingClientRect();
|
|
16
16
|
if ((e.width < 1 || e.height < 1) && t < 10) {
|
|
17
|
-
requestAnimationFrame(() =>
|
|
17
|
+
requestAnimationFrame(() => s(t + 1));
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
20
|
requestAnimationFrame(() => {
|
|
21
|
-
const
|
|
22
|
-
if ((
|
|
23
|
-
requestAnimationFrame(() =>
|
|
21
|
+
const h = i.getBoundingClientRect();
|
|
22
|
+
if ((h.width < 1 || h.height < 1) && t < 10) {
|
|
23
|
+
requestAnimationFrame(() => s(t + 1));
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
let l = 0, c = 0;
|
|
30
|
-
v === "right" ? c = e.right - x : v === "center" ? c = e.left + e.width / 2 - x / 2 : c = e.left, p === "top" ? l = e.top - r : p === "center" ? l = e.top + e.height / 2 - r / 2 : l = e.bottom - A, h.value = {
|
|
26
|
+
const A = n.origin || L(n.location), [d, m] = A.split(" "), F = n.hideDetails ? 0 : 19, v = i.offsetWidth, E = i.offsetHeight;
|
|
27
|
+
let l = 0, r = 0;
|
|
28
|
+
m === "right" ? r = e.right - v : m === "center" ? r = e.left + e.width / 2 - v / 2 : r = e.left, d === "top" ? l = e.top - E : d === "center" ? l = e.top + e.height / 2 - E / 2 : l = e.bottom - F, f.value = {
|
|
31
29
|
position: "fixed",
|
|
32
30
|
top: `${l}px`,
|
|
33
|
-
left: `${
|
|
31
|
+
left: `${r}px`,
|
|
34
32
|
width: n.width === "w-full" ? `${e.width}px` : void 0
|
|
35
|
-
}
|
|
36
|
-
origin: m,
|
|
37
|
-
parent: {
|
|
38
|
-
top: e.top,
|
|
39
|
-
bottom: e.bottom,
|
|
40
|
-
height: e.height
|
|
41
|
-
},
|
|
42
|
-
menu: {
|
|
43
|
-
height: r,
|
|
44
|
-
offsetHeight: i.offsetHeight,
|
|
45
|
-
rectHeight: u.height
|
|
46
|
-
},
|
|
47
|
-
calculatedTop: l,
|
|
48
|
-
expectedTop: e.top - r
|
|
49
|
-
});
|
|
33
|
+
};
|
|
50
34
|
});
|
|
51
35
|
}
|
|
52
36
|
function L(t) {
|
|
@@ -63,26 +47,26 @@ function F(n, H, g, b) {
|
|
|
63
47
|
return "bottom left";
|
|
64
48
|
}
|
|
65
49
|
}
|
|
66
|
-
function
|
|
50
|
+
function b() {
|
|
67
51
|
var o, i;
|
|
68
|
-
const t = ((o = n.parentRef) == null ? void 0 : o.$el) || ((i =
|
|
52
|
+
const t = ((o = n.parentRef) == null ? void 0 : o.$el) || ((i = c.value) == null ? void 0 : i.parentElement);
|
|
69
53
|
if (!(t instanceof HTMLElement)) {
|
|
70
54
|
console.warn("[KunMenu] Activator no válido:", t);
|
|
71
55
|
return;
|
|
72
56
|
}
|
|
73
|
-
t.addEventListener("click",
|
|
57
|
+
t.addEventListener("click", p), t.addEventListener("mouseenter", () => u("enter")), t.addEventListener("mouseleave", () => u("leave")), t.addEventListener("focus", w);
|
|
74
58
|
}
|
|
75
|
-
const
|
|
59
|
+
const R = x(() => typeof n.maxHeight == "number" ? n.maxHeight + "px" : n.maxHeight);
|
|
76
60
|
return {
|
|
77
|
-
initializeMenu:
|
|
78
|
-
repositionMenu:
|
|
79
|
-
contentEl:
|
|
80
|
-
activatorEl:
|
|
81
|
-
originClass:
|
|
82
|
-
computedMaxHeight:
|
|
83
|
-
menuPositionStyle:
|
|
61
|
+
initializeMenu: b,
|
|
62
|
+
repositionMenu: s,
|
|
63
|
+
contentEl: c,
|
|
64
|
+
activatorEl: g,
|
|
65
|
+
originClass: M,
|
|
66
|
+
computedMaxHeight: R,
|
|
67
|
+
menuPositionStyle: f
|
|
84
68
|
};
|
|
85
69
|
}
|
|
86
70
|
export {
|
|
87
|
-
|
|
71
|
+
q as useKunMenuStyles
|
|
88
72
|
};
|