litos-ui 0.15.4 → 0.15.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.
- package/lib/menu/sub_menu.js +15 -14
- package/package.json +1 -1
package/lib/menu/sub_menu.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addClass as
|
|
1
|
+
import { addClass as r, $one as l, on as h, off as p, removeClass as d, toggleClass as u, $$ as n } from "ph-utils/dom";
|
|
2
2
|
import m from "../base.js";
|
|
3
3
|
import { initAttr as g, parseAttrValue as c } from "../utils/index.js";
|
|
4
4
|
const f = ":host{display:block;width:100%;overflow:hidden}.l-submenu-title{display:flex;align-items:center;padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;border-right:2px solid transparent;transition:color .3s,background-color .3s,border-color .3s}.l-submenu-title:hover{background-color:var(--l-primary-color-light5)}.l-menu{--l-menu-level: 1;display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}.l-menu-icon-wrap{display:inline-flex;font-size:14px;margin-right:5px}.l-submenu-arrow-icon{position:absolute;top:50%;right:10px;transition:transform .3s;transform:translate3d(0,-50%,0) rotate(90deg);color:var(--l-info-color)}:host(.collapsed) .l-submenu-arrow-icon{transform:translate3d(0,-50%,0) rotate(0)}.l-menu--collapsed{display:none}.l-menu--hide{position:absolute;visibility:hidden}:host(.is-active) .l-submenu-title{color:var(--l-primary-color)}";
|
|
@@ -10,14 +10,14 @@ class C extends m {
|
|
|
10
10
|
active = !1;
|
|
11
11
|
#e;
|
|
12
12
|
connectedCallback() {
|
|
13
|
-
this.loadStyleText(f), g(this), this.expanded ||
|
|
13
|
+
this.loadStyleText(f), g(this), this.expanded || r(this, "collapsed"), this.active && r(this, "is-active"), super.connectedCallback();
|
|
14
14
|
}
|
|
15
15
|
afterInit() {
|
|
16
|
-
const e =
|
|
16
|
+
const e = l(".l-menu", this.root);
|
|
17
17
|
h(e, "transitionend", this.#t);
|
|
18
18
|
}
|
|
19
19
|
beforeDestroy() {
|
|
20
|
-
const e =
|
|
20
|
+
const e = l(".l-menu", this.root);
|
|
21
21
|
p(e, "transitionend", this.#t), this.#e && clearTimeout(this.#e);
|
|
22
22
|
}
|
|
23
23
|
static get observedAttributes() {
|
|
@@ -29,16 +29,17 @@ class C extends m {
|
|
|
29
29
|
const o = c(a, !1, "expanded");
|
|
30
30
|
if (this.expanded !== o) {
|
|
31
31
|
this.expanded = o;
|
|
32
|
-
const t =
|
|
33
|
-
if (this.expanded)
|
|
34
|
-
d(this, "collapsed"),
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
32
|
+
const t = l(".l-menu", this.root);
|
|
33
|
+
if (this.expanded)
|
|
34
|
+
d(this, "collapsed"), r(t, "l-menu--hide"), d(t, "l-menu--collapsed"), requestAnimationFrame(() => {
|
|
35
|
+
const s = t.getBoundingClientRect();
|
|
36
|
+
t.style.height = "0", d(t, "l-menu--hide"), requestAnimationFrame(() => {
|
|
37
|
+
t.style.height = `${s.height}px`;
|
|
38
|
+
});
|
|
38
39
|
});
|
|
39
|
-
|
|
40
|
+
else {
|
|
40
41
|
const s = t.getBoundingClientRect();
|
|
41
|
-
t.style.height = `${s.height}px`,
|
|
42
|
+
t.style.height = `${s.height}px`, r(this, "collapsed"), requestAnimationFrame(() => {
|
|
42
43
|
t.style.height = "0";
|
|
43
44
|
});
|
|
44
45
|
}
|
|
@@ -57,7 +58,7 @@ class C extends m {
|
|
|
57
58
|
}
|
|
58
59
|
render() {
|
|
59
60
|
const e = document.createDocumentFragment(), i = n("div", { class: "l-submenu-title" });
|
|
60
|
-
if (
|
|
61
|
+
if (l('[slot="icon"]', this)) {
|
|
61
62
|
const s = n("span", { class: "l-menu-icon-wrap" });
|
|
62
63
|
s.appendChild(n("slot", { name: "icon" })), i.appendChild(s);
|
|
63
64
|
}
|
|
@@ -73,7 +74,7 @@ class C extends m {
|
|
|
73
74
|
if (!this.expanded && e.propertyName === "height") {
|
|
74
75
|
this.#e && clearTimeout(this.#e);
|
|
75
76
|
const i = e.target;
|
|
76
|
-
i.style.removeProperty("height"),
|
|
77
|
+
i.style.removeProperty("height"), r(i, "l-menu--collapsed");
|
|
77
78
|
}
|
|
78
79
|
};
|
|
79
80
|
}
|