adverich-kun-ui 0.1.601 → 0.1.602
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,68 +1,69 @@
|
|
|
1
|
-
import { onMounted as
|
|
1
|
+
import { computed as u, onMounted as R, nextTick as U, onUnmounted as x, watch as I, onBeforeUnmount as O, openBlock as d, createElementBlock as k, Fragment as Y, createBlock as j, Teleport as q, createVNode as G, Transition as J, unref as n, withCtx as Q, withDirectives as X, createElementVNode as Z, withKeys as _, withModifiers as ee, normalizeStyle as te, normalizeClass as ne, renderSlot as C, vShow as oe, createCommentVNode as L } from "vue";
|
|
2
2
|
import { useKunMenu as se } from "../composables/useKunMenu.js";
|
|
3
3
|
import { kunMenuProps as re } from "../composables/kunMenuProps.js";
|
|
4
4
|
import { useKunMenuStyles as ae } from "../composables/useKunMenuStyles.js";
|
|
5
5
|
import { useKunMenuComposable as le } from "../composables/useKunMenuComposable.js";
|
|
6
|
-
const
|
|
6
|
+
const me = {
|
|
7
7
|
__name: "KunMenu",
|
|
8
8
|
props: re,
|
|
9
9
|
emits: ["update:modelValue", "click:outside", "handleEscape"],
|
|
10
10
|
setup(M, { emit: T }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
const s = M, v = T, a = u(() => {
|
|
12
|
+
const e = s.parentRef;
|
|
13
|
+
return (e == null ? void 0 : e.$el) ?? (e == null ? void 0 : e.value) ?? e ?? null;
|
|
14
|
+
}), {
|
|
15
|
+
menuVisible: m,
|
|
16
|
+
handleActivatorClick: f,
|
|
17
|
+
handleHover: l,
|
|
18
|
+
handleFocus: p,
|
|
19
|
+
handleEscape: h,
|
|
18
20
|
hideMenu: b
|
|
19
|
-
} = se(
|
|
21
|
+
} = se(s, v), {
|
|
20
22
|
initializeMenu: S,
|
|
21
|
-
repositionMenu:
|
|
23
|
+
repositionMenu: i,
|
|
22
24
|
startScrollTracking: H,
|
|
23
|
-
stopScrollTracking:
|
|
25
|
+
stopScrollTracking: y,
|
|
24
26
|
contentEl: r,
|
|
25
|
-
activatorEl:
|
|
27
|
+
activatorEl: w,
|
|
26
28
|
originClass: z,
|
|
27
29
|
computedMaxHeight: B,
|
|
28
30
|
menuPositionStyle: K
|
|
29
|
-
} = ae(
|
|
31
|
+
} = ae(s, f, l, p), { onClickOutside: V } = le(), { addEventListeners: F, removeEventListeners: $ } = V(
|
|
30
32
|
r,
|
|
31
33
|
() => {
|
|
32
|
-
var
|
|
33
|
-
const e =
|
|
34
|
-
(
|
|
34
|
+
var o;
|
|
35
|
+
const e = a.value || w.value, t = window.__lastClickEvent;
|
|
36
|
+
(o = e == null ? void 0 : e.contains) != null && o.call(e, t == null ? void 0 : t.target) || (b(), v("click:outside"));
|
|
35
37
|
},
|
|
36
|
-
|
|
38
|
+
s.parentRef ? [{ value: a.value }] : []
|
|
37
39
|
);
|
|
38
|
-
|
|
40
|
+
R(() => {
|
|
39
41
|
U(() => {
|
|
40
|
-
S(), window.addEventListener("resize",
|
|
42
|
+
S(), window.addEventListener("resize", i);
|
|
41
43
|
});
|
|
42
44
|
}), x(() => {
|
|
43
|
-
|
|
45
|
+
y();
|
|
44
46
|
const e = r.value;
|
|
45
|
-
e && e.removeEventListener("wheel",
|
|
46
|
-
}), I(
|
|
47
|
+
e && e.removeEventListener("wheel", c), window.removeEventListener("resize", i);
|
|
48
|
+
}), I(m, (e) => {
|
|
47
49
|
const t = r.value;
|
|
48
|
-
t && (e ? (
|
|
50
|
+
t && (e ? (i(), H(a.value), t.addEventListener("wheel", c, { passive: !1 }), F()) : (y(), t.removeEventListener("wheel", c), $()));
|
|
49
51
|
});
|
|
50
|
-
function
|
|
52
|
+
function c(e) {
|
|
51
53
|
const t = r.value;
|
|
52
54
|
if (!t) return;
|
|
53
|
-
const
|
|
54
|
-
(
|
|
55
|
+
const o = e.deltaY > 0, W = t.scrollTop + t.clientHeight >= t.scrollHeight, P = t.scrollTop <= 0;
|
|
56
|
+
(o && W || !o && P) && e.preventDefault();
|
|
55
57
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
e && (e.removeEventListener("click", m), e.removeEventListener("mouseenter", () => a("enter")), e.removeEventListener("mouseleave", () => a("leave")), e.removeEventListener("focus", v));
|
|
58
|
+
function A() {
|
|
59
|
+
const e = a.value;
|
|
60
|
+
e && (e.removeEventListener("click", f), e.removeEventListener("mouseenter", () => l("enter")), e.removeEventListener("mouseleave", () => l("leave")), e.removeEventListener("focus", p));
|
|
60
61
|
}
|
|
61
62
|
O(() => {
|
|
62
|
-
|
|
63
|
+
A();
|
|
63
64
|
});
|
|
64
|
-
const
|
|
65
|
-
switch (
|
|
65
|
+
const E = u(() => {
|
|
66
|
+
switch (s.transition) {
|
|
66
67
|
case "fade":
|
|
67
68
|
return "opacity-0";
|
|
68
69
|
case "fade-scale":
|
|
@@ -78,19 +79,19 @@ const ve = {
|
|
|
78
79
|
default:
|
|
79
80
|
return "";
|
|
80
81
|
}
|
|
81
|
-
}),
|
|
82
|
-
return (e, t) => (
|
|
83
|
-
e.attach !== !0 ? (
|
|
82
|
+
}), g = u(() => "opacity-100 scale-100 translate-x-0 translate-y-0"), D = g, N = E;
|
|
83
|
+
return (e, t) => (d(), k(Y, null, [
|
|
84
|
+
e.attach !== !0 ? (d(), j(q, {
|
|
84
85
|
key: 0,
|
|
85
86
|
to: e.attach || "body"
|
|
86
87
|
}, [
|
|
87
88
|
G(J, {
|
|
88
89
|
"enter-active-class": "transition ease-out duration-150",
|
|
89
90
|
"leave-active-class": "transition ease-in duration-100",
|
|
90
|
-
"enter-from-class":
|
|
91
|
-
"enter-to-class":
|
|
92
|
-
"leave-from-class":
|
|
93
|
-
"leave-to-class":
|
|
91
|
+
"enter-from-class": E.value,
|
|
92
|
+
"enter-to-class": g.value,
|
|
93
|
+
"leave-from-class": n(D),
|
|
94
|
+
"leave-to-class": n(N)
|
|
94
95
|
}, {
|
|
95
96
|
default: Q(() => [
|
|
96
97
|
X(Z("div", {
|
|
@@ -98,22 +99,22 @@ const ve = {
|
|
|
98
99
|
ref: r,
|
|
99
100
|
role: "menu",
|
|
100
101
|
tabindex: "-1",
|
|
101
|
-
class: ne(["relative shadow-xl rounded-b overflow-y-auto focus:outline-none border border-gray-300 dark:border-gray-700", [
|
|
102
|
-
style: te({ ...
|
|
103
|
-
onKeydown: t[0] || (t[0] = _(ee((...
|
|
102
|
+
class: ne(["relative shadow-xl rounded-b overflow-y-auto focus:outline-none border border-gray-300 dark:border-gray-700", [s.class, n(z), e.width, e.minWidth, e.maxWidth, e.minHeight, e.height, e.maxHeight, e.zIndex, e.bgColor]]),
|
|
103
|
+
style: te({ ...n(K), maxHeight: n(B) }),
|
|
104
|
+
onKeydown: t[0] || (t[0] = _(ee((...o) => n(h) && n(h)(...o), ["stop"]), ["escape"]))
|
|
104
105
|
}, [
|
|
105
106
|
C(e.$slots, "default")
|
|
106
107
|
], 38), [
|
|
107
|
-
[oe,
|
|
108
|
+
[oe, n(m)]
|
|
108
109
|
])
|
|
109
110
|
]),
|
|
110
111
|
_: 3
|
|
111
112
|
}, 8, ["enter-from-class", "enter-to-class", "leave-from-class", "leave-to-class"])
|
|
112
113
|
], 8, ["to"])) : L("", !0),
|
|
113
|
-
e.$slots.activator ? (
|
|
114
|
+
e.$slots.activator ? (d(), k("span", {
|
|
114
115
|
key: 1,
|
|
115
116
|
ref_key: "activatorEl",
|
|
116
|
-
ref:
|
|
117
|
+
ref: w
|
|
117
118
|
}, [
|
|
118
119
|
C(e.$slots, "activator")
|
|
119
120
|
], 512)) : L("", !0)
|
|
@@ -121,5 +122,5 @@ const ve = {
|
|
|
121
122
|
}
|
|
122
123
|
};
|
|
123
124
|
export {
|
|
124
|
-
|
|
125
|
+
me as default
|
|
125
126
|
};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
import { ref as d, computed as
|
|
2
|
-
function
|
|
3
|
-
const H = d({}), w = d(null), L = d(null), m = d(null), x = d("bottom"),
|
|
1
|
+
import { ref as d, computed as T } from "vue";
|
|
2
|
+
function Y(i, R, E, q) {
|
|
3
|
+
const H = d({}), w = d(null), L = d(null), m = d(null), x = d("bottom"), B = {
|
|
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
|
+
}, C = T(() => {
|
|
9
9
|
var t;
|
|
10
|
-
return x.value === "top" ? "origin-bottom" : ((t =
|
|
10
|
+
return x.value === "top" ? "origin-bottom" : ((t = B[i.location]) == null ? void 0 : t.class) || "origin-top";
|
|
11
11
|
});
|
|
12
12
|
let c = null, h = [];
|
|
13
|
-
function
|
|
13
|
+
function A() {
|
|
14
|
+
const t = i.parentRef;
|
|
15
|
+
return t ? (t == null ? void 0 : t.$el) ?? (t == null ? void 0 : t.value) ?? t ?? null : L.value;
|
|
16
|
+
}
|
|
17
|
+
function W(t) {
|
|
14
18
|
const o = [];
|
|
15
19
|
let n = t.parentElement;
|
|
16
20
|
for (; n; ) {
|
|
@@ -19,27 +23,27 @@ function I(i, R, E, T) {
|
|
|
19
23
|
}
|
|
20
24
|
return o;
|
|
21
25
|
}
|
|
22
|
-
function
|
|
23
|
-
|
|
26
|
+
function k(t) {
|
|
27
|
+
M();
|
|
24
28
|
const o = (t == null ? void 0 : t.$el) || t;
|
|
25
29
|
if (!(o instanceof HTMLElement)) return;
|
|
26
|
-
const n =
|
|
30
|
+
const n = W(o), e = () => {
|
|
27
31
|
c || (c = requestAnimationFrame(() => {
|
|
28
32
|
c = null, g();
|
|
29
33
|
}));
|
|
30
34
|
}, l = { capture: !0, passive: !0 };
|
|
31
35
|
window.addEventListener("scroll", e, l), h.push({ target: window, handler: e, options: l }), n.forEach((r) => {
|
|
32
|
-
const
|
|
33
|
-
r.addEventListener("scroll", e,
|
|
36
|
+
const a = { passive: !0 };
|
|
37
|
+
r.addEventListener("scroll", e, a), h.push({ target: r, handler: e, options: a });
|
|
34
38
|
});
|
|
35
39
|
}
|
|
36
|
-
function
|
|
40
|
+
function M() {
|
|
37
41
|
c && (cancelAnimationFrame(c), c = null), h.forEach(({ target: t, handler: o, options: n }) => {
|
|
38
42
|
t.removeEventListener("scroll", o, n);
|
|
39
43
|
}), h = [];
|
|
40
44
|
}
|
|
41
45
|
function g(t = 0) {
|
|
42
|
-
const o =
|
|
46
|
+
const o = A(), n = w.value;
|
|
43
47
|
if (!(o instanceof HTMLElement) || !(n instanceof HTMLElement)) return;
|
|
44
48
|
const e = o.getBoundingClientRect();
|
|
45
49
|
if ((e.width < 1 || e.height < 1) && t < 10) {
|
|
@@ -52,20 +56,20 @@ function I(i, R, E, T) {
|
|
|
52
56
|
requestAnimationFrame(() => g(t + 1));
|
|
53
57
|
return;
|
|
54
58
|
}
|
|
55
|
-
const r = window.innerHeight,
|
|
56
|
-
x.value =
|
|
57
|
-
const
|
|
59
|
+
const r = window.innerHeight, a = window.innerWidth, u = 8, S = i.hideDetails ? 0 : 19, y = n.offsetHeight, v = i.width === "w-full" ? e.width : n.offsetWidth, p = r - e.bottom + S - u, b = e.top - u, D = p >= y, K = b >= y, $ = !D && (K || b > p);
|
|
60
|
+
x.value = $ ? "top" : "bottom";
|
|
61
|
+
const _ = i.origin && i.origin !== "auto" ? i.origin : O(i.location), [, F] = _.split(" ");
|
|
58
62
|
let s = 0;
|
|
59
|
-
|
|
63
|
+
F === "right" ? s = e.right - v : F === "center" ? s = e.left + e.width / 2 - v / 2 : s = e.left, i.width !== "w-full" && (s + v > a - u && (s = a - v - u), s < u && (s = u));
|
|
60
64
|
const f = {
|
|
61
65
|
position: "fixed",
|
|
62
66
|
left: `${s}px`,
|
|
63
67
|
width: i.width === "w-full" ? `${e.width}px` : void 0
|
|
64
68
|
};
|
|
65
|
-
|
|
69
|
+
$ ? (f.top = "auto", f.bottom = `${r - e.top}px`, m.value = b) : (f.top = `${e.bottom - S}px`, f.bottom = "auto", m.value = p), H.value = f;
|
|
66
70
|
});
|
|
67
71
|
}
|
|
68
|
-
function
|
|
72
|
+
function O(t) {
|
|
69
73
|
switch (t) {
|
|
70
74
|
case "top":
|
|
71
75
|
return "top left";
|
|
@@ -79,31 +83,31 @@ function I(i, R, E, T) {
|
|
|
79
83
|
return "bottom left";
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
|
-
function
|
|
83
|
-
var o
|
|
84
|
-
const t = (
|
|
86
|
+
function P() {
|
|
87
|
+
var o;
|
|
88
|
+
const t = A() || ((o = w.value) == null ? void 0 : o.parentElement);
|
|
85
89
|
if (!(t instanceof HTMLElement)) {
|
|
86
90
|
console.warn("[KunMenu] Activator no válido:", t);
|
|
87
91
|
return;
|
|
88
92
|
}
|
|
89
|
-
t.addEventListener("click", R), t.addEventListener("mouseenter", () => E("enter")), t.addEventListener("mouseleave", () => E("leave")), t.addEventListener("focus",
|
|
93
|
+
t.addEventListener("click", R), t.addEventListener("mouseenter", () => E("enter")), t.addEventListener("mouseleave", () => E("leave")), t.addEventListener("focus", q);
|
|
90
94
|
}
|
|
91
|
-
const z =
|
|
95
|
+
const z = T(() => {
|
|
92
96
|
if (!i.maxHeight && m.value !== null)
|
|
93
97
|
return `${m.value}px`;
|
|
94
98
|
});
|
|
95
99
|
return {
|
|
96
|
-
initializeMenu:
|
|
100
|
+
initializeMenu: P,
|
|
97
101
|
repositionMenu: g,
|
|
98
|
-
startScrollTracking:
|
|
99
|
-
stopScrollTracking:
|
|
102
|
+
startScrollTracking: k,
|
|
103
|
+
stopScrollTracking: M,
|
|
100
104
|
contentEl: w,
|
|
101
105
|
activatorEl: L,
|
|
102
|
-
originClass:
|
|
106
|
+
originClass: C,
|
|
103
107
|
computedMaxHeight: z,
|
|
104
108
|
menuPositionStyle: H
|
|
105
109
|
};
|
|
106
110
|
}
|
|
107
111
|
export {
|
|
108
|
-
|
|
112
|
+
Y as useKunMenuStyles
|
|
109
113
|
};
|