litos-ui 0.13.0 → 0.14.0

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.
Files changed (49) hide show
  1. package/lib/base.d.ts +1 -1
  2. package/lib/base.js +3 -3
  3. package/lib/carousel/index.d.ts +20 -0
  4. package/lib/carousel/index.js +280 -0
  5. package/lib/carousel/item.d.ts +6 -0
  6. package/lib/carousel/item.js +15 -0
  7. package/lib/carousel/timer.d.ts +5 -0
  8. package/lib/carousel/timer.js +19 -0
  9. package/lib/check/check.d.ts +22 -0
  10. package/lib/check/check.js +81 -0
  11. package/lib/check/checkbox.d.ts +7 -0
  12. package/lib/check/checkbox.js +25 -0
  13. package/lib/check/checkbox_group.d.ts +9 -0
  14. package/lib/check/checkbox_group.js +33 -0
  15. package/lib/check/index.d.ts +12 -0
  16. package/lib/check/index.js +35 -0
  17. package/lib/check/radio.d.ts +6 -0
  18. package/lib/check/radio.js +19 -0
  19. package/lib/check/radio_group.d.ts +6 -0
  20. package/lib/check/radio_group.js +24 -0
  21. package/lib/check-BlDsQQo0.js +4 -0
  22. package/lib/color_picker/index.d.ts +1 -1
  23. package/lib/color_picker/index.js +5 -5
  24. package/lib/form/form_inner.d.ts +1 -8
  25. package/lib/form/form_inner.js +31 -39
  26. package/lib/form/form_item.d.ts +1 -1
  27. package/lib/form/form_item.js +30 -37
  28. package/lib/form/index.js +5 -5
  29. package/lib/icon/close_filled.d.ts +1 -1
  30. package/lib/index.d.ts +12 -4
  31. package/lib/index.js +80 -72
  32. package/lib/input/index.js +10 -10
  33. package/lib/list/index.d.ts +1 -2
  34. package/lib/list/index.js +17 -17
  35. package/lib/md_input/index.js +9 -9
  36. package/lib/menu/index.d.ts +2 -0
  37. package/lib/menu/index.js +47 -42
  38. package/lib/menu/sub_menu.d.ts +4 -2
  39. package/lib/menu/sub_menu.js +59 -41
  40. package/lib/select_ori/index.d.ts +1 -1
  41. package/lib/select_ori/index.js +1 -1
  42. package/lib/utils/index.d.ts +1 -1
  43. package/lib/utils/index.js +49 -49
  44. package/lib/utils/transition.js +3 -2
  45. package/package.json +1 -1
  46. package/lib/checkbox/index.d.ts +0 -17
  47. package/lib/checkbox/index.js +0 -135
  48. package/lib/radio/index.d.ts +0 -28
  49. package/lib/radio/index.js +0 -122
@@ -1,9 +1,9 @@
1
- import { $one as h, on as a, formatStyle as d, addClass as p, off as o, $ as u, $$ as n, toggleClass as f } from "ph-utils/dom";
1
+ import { $one as h, on as a, formatStyle as p, addClass as o, off as u, $ as d, $$ as n, removeClass as f } from "ph-utils/dom";
2
2
  import { initAttr as c, parseAttrValue as m } from "../utils/index.js";
3
- import g from "../form/form_inner.js";
4
- import { add as b, remove as v } from "../utils/event.js";
3
+ import b from "../form/form_inner.js";
4
+ import { add as g, remove as v } from "../utils/event.js";
5
5
  import { i as C } from "../index-dwS1N2uN.js";
6
- class y extends g {
6
+ class y extends b {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
9
9
  type = "text";
@@ -31,10 +31,10 @@ class y extends g {
31
31
  return ["disabled", "error"];
32
32
  }
33
33
  connectedCallback() {
34
- c(this), this.loadStyleText([C]), super.connectedCallback(), this.$inner = h(".l-input__inner", this.root), a(this.$inner, "input", this._input), a(this.$inner, "change", this.#i), this.style.cssText = d(this._getStyleObj()) + this.getAttr("style", ""), this.error && p(this, "is-error"), this.getName() && this.formAttrs.id && b(this.formAttrs.id, "validateChange", this._validateChange);
34
+ c(this), this.loadStyleText([C]), super.connectedCallback(), this.$inner = h(".l-input__inner", this.root), a(this.$inner, "input", this._input), a(this.$inner, "change", this.#i), this.style.cssText = p(this._getStyleObj()) + this.getAttr("style", ""), this.error && o(this, "is-error"), this.getName() && this.formAttrs.id && g(this.formAttrs.id, "validateChange", this._validateChange);
35
35
  }
36
36
  disconnectedCallback() {
37
- super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), o(this.$inner, "input", this._input);
37
+ super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), u(this.$inner, "input", this._input);
38
38
  }
39
39
  attributeChange(t, i, e) {
40
40
  if (t === "error") {
@@ -44,7 +44,7 @@ class y extends g {
44
44
  }
45
45
  render() {
46
46
  const t = document.createDocumentFragment();
47
- if (u('[slot="prefix"]', this).length > 0) {
47
+ if (d('[slot="prefix"]', this).length > 0) {
48
48
  const r = n("slot", {
49
49
  name: "prefix"
50
50
  }), l = n("span", {
@@ -62,7 +62,7 @@ class y extends g {
62
62
  part: "default",
63
63
  type: this.type
64
64
  });
65
- if (t.appendChild(e), u('[slot="suffix"]', this).length > 0) {
65
+ if (t.appendChild(e), d('[slot="suffix"]', this).length > 0) {
66
66
  const r = n("slot", {
67
67
  name: "suffix"
68
68
  }), l = n("span", {
@@ -105,7 +105,7 @@ class y extends g {
105
105
  t.appendChild(i), this.root.appendChild(t), a(t, "click", this.#e);
106
106
  }
107
107
  } else
108
- t && (o(t, "click", this.#e), t.remove());
108
+ t && (u(t, "click", this.#e), t.remove());
109
109
  }
110
110
  }
111
111
  #e = () => {
@@ -137,7 +137,7 @@ class y extends g {
137
137
  return this.block === !0 || this.formItemAttrs.innerBlock === !0 || this.formAttrs.innerBlock === !0;
138
138
  }
139
139
  _updateError() {
140
- f(this, "is-error");
140
+ this.error ? o(this, "is-error") : f(this, "is-error");
141
141
  }
142
142
  _validateChange = (t, i) => {
143
143
  const e = this.getName();
@@ -6,9 +6,8 @@ export default class List extends BaseComponent {
6
6
  /** 是否显示无限加载模式 */
7
7
  infinite: boolean;
8
8
  private observer?;
9
- private loadMoreEmit;
10
9
  private $more?;
11
- constructor();
10
+ private _page;
12
11
  static get observedAttributes(): string[] | null | undefined;
13
12
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
14
13
  connectedCallback(): void;
package/lib/list/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import r from "../base.js";
2
- import { initAttr as n, parseAttrValue as l } from "../utils/index.js";
3
- import { $one as e } from "ph-utils/dom";
4
- import { a } from "../animation-DttknHkX.js";
5
- const h = ":host{display:block;overflow:auto;-webkit-overflow-scrolling:touch;height:100%;position:relative}.l-list-loadmore{padding:10px;display:flex;align-items:center;justify-content:center;color:#999}.l-list-icon{font-size:24px;margin-right:10px;transform:rotate3d(0,0,1,80deg)}";
2
+ import { parseAttrValue as n } from "../utils/index.js";
3
+ import { $one as s } from "ph-utils/dom";
4
+ import { a as l } from "../animation-DttknHkX.js";
5
+ const a = ":host{display:block;overflow:auto;-webkit-overflow-scrolling:touch;height:100%;position:relative}.l-list-loadmore{padding:10px;display:flex;align-items:center;justify-content:center;color:#999}.l-list-icon{font-size:24px;margin-right:10px;transform:rotate3d(0,0,1,80deg)}";
6
6
  class b extends r {
7
7
  static baseName = "list";
8
8
  /** 是否已经全部加载完成 */
@@ -10,27 +10,27 @@ class b extends r {
10
10
  /** 是否显示无限加载模式 */
11
11
  infinite = !0;
12
12
  observer;
13
- loadMoreEmit;
14
13
  $more;
15
- constructor() {
16
- super(), n(this), this.loadMoreEmit = new CustomEvent("load-more");
17
- }
14
+ _page = 0;
18
15
  static get observedAttributes() {
19
- return ["finish"];
16
+ return ["finish", "infinite"];
20
17
  }
21
18
  attributeChangedCallback(i, t, o) {
22
19
  if (i === "finish") {
23
- const s = l(o, !1, i);
24
- this.finish !== s && (this.finish = s, this._finishChange());
20
+ const e = n(o, !1, i);
21
+ this.finish !== e && (this.finish = e, this._finishChange());
22
+ } else if (i === "infinite") {
23
+ const e = n(o, !0, i);
24
+ this.infinite !== e && (this.infinite = e);
25
25
  }
26
26
  }
27
27
  connectedCallback() {
28
- this.loadStyleText([h, a]), super.connectedCallback(), this.infinite && (this.observer = new IntersectionObserver((i) => {
29
- i[0].isIntersecting && !this.finish && this.dispatchEvent(this.loadMoreEmit);
30
- }), this.$more = e(".l-list-loadmore", this.root), !this.finish && this.$more && this.observer.observe(this.$more));
28
+ this.loadStyleText([a, l]), super.connectedCallback(), this.infinite && (this.observer = new IntersectionObserver((i) => {
29
+ i[0].isIntersecting && !this.finish && (this._page++, this.setAttribute("loading", ""), this.emit("load", { detail: { page: this._page } }));
30
+ }), this.$more = s(".l-list-loadmore", this.root), !this.finish && this.$more && this.observer.observe(this.$more));
31
31
  }
32
32
  disconnectedCallback() {
33
- super.disconnectedCallback(), this.observer && (this.$more && (this.observer.unobserve(this.$more), this.$more = void 0), this.observer.disconnect(), this.observer = void 0), this.loadMoreEmit = void 0;
33
+ super.disconnectedCallback(), this.observer && (this.$more && (this.observer.unobserve(this.$more), this.$more = void 0), this.observer.disconnect(), this.observer = void 0);
34
34
  }
35
35
  render() {
36
36
  const i = ["<slot></slot>"];
@@ -46,9 +46,9 @@ class b extends r {
46
46
  _finishChange() {
47
47
  if (this.$more) {
48
48
  this.observer && (this.finish ? this.observer.unobserve(this.$more) : this.observer.observe(this.$more));
49
- const i = e(".l-list-loadmore-text", this.$more);
49
+ const i = s(".l-list-loadmore-text", this.$more);
50
50
  i && (i.textContent = this._loadingText());
51
- let t = e(".l-list-icon", this.$more);
51
+ let t = s(".l-list-icon", this.$more);
52
52
  this.finish ? t && t.remove() : t == null && (t = document.createElement("l-loading-icon"), t.className = "l-list-icon l-rotate-anim", this.$more.prepend(t));
53
53
  }
54
54
  }
@@ -1,4 +1,4 @@
1
- import { addClass as i, $$ as r, $one as l, on as a, off as d, removeClass as u } from "ph-utils/dom";
1
+ import { addClass as n, $$ as r, $one as l, on as a, off as d, removeClass as u } from "ph-utils/dom";
2
2
  import p from "../form/form_inner.js";
3
3
  import { initAttr as m } from "../utils/index.js";
4
4
  import { isBlank as s, random as h } from "ph-utils";
@@ -17,18 +17,18 @@ class v extends p {
17
17
  m(this), this.loadStyleText(c), super.connectedCallback(), this.#e();
18
18
  }
19
19
  disconnectedCallback() {
20
- super.disconnectedCallback(), this.#n();
20
+ super.disconnectedCallback(), this.#i();
21
21
  }
22
22
  render() {
23
- s(this.value) || i(this, "l-has-value"), this.outline && i(this, "l-md-input-outline");
24
- const t = document.createDocumentFragment(), e = `l-md-input-${h(8)}`, n = r("input", {
23
+ s(this.value) || n(this, "l-has-value"), this.outline && n(this, "l-md-input-outline");
24
+ const t = document.createDocumentFragment(), e = `l-md-input-${h(8)}`, i = r("input", {
25
25
  class: "l-md-input__inner",
26
26
  type: this.htmlType,
27
- name: this.name,
27
+ name: this.getName(),
28
28
  inputmode: this.inputmode,
29
29
  id: e
30
30
  });
31
- if (t.appendChild(n), this.label) {
31
+ if (t.appendChild(i), this.label) {
32
32
  const o = r("label", {
33
33
  class: "l-md-input__label",
34
34
  for: e
@@ -46,13 +46,13 @@ class v extends p {
46
46
  const t = l("input", this.root);
47
47
  t && a(t, "input", this.#t);
48
48
  }
49
- #n() {
49
+ #i() {
50
50
  const t = l("input", this.root);
51
51
  t && d(t, "input", this.#t);
52
52
  }
53
53
  #t = (t) => {
54
- const n = t.target.value;
55
- this.setValue(n), s(n) ? u(this, "l-has-value") : i(this, "l-has-value");
54
+ const i = t.target.value;
55
+ this.setValue(i), s(i) ? u(this, "l-has-value") : n(this, "l-has-value");
56
56
  };
57
57
  }
58
58
  export {
@@ -8,6 +8,8 @@ export default class Menu extends BaseComponent {
8
8
  orientation: "horizontal" | "vertical";
9
9
  /** 主题 */
10
10
  theme: "light" | "dark";
11
+ /** 是否手风琴模式, 只有一个子菜单展开 */
12
+ accordion: boolean;
11
13
  connectedCallback(): void;
12
14
  static get observedAttributes(): string[];
13
15
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
package/lib/menu/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { on as r, off as a, $$ as c, $ as d, iterate as h, $one as u } from "ph-utils/dom";
2
- import f from "../base.js";
3
- import { initAttr as m } from "../utils/index.js";
4
- const b = ":host{--l-menu-width: 240px;--l-menu-height: auto;--l-menu-color: #333333;--l-menu-background: #ffffff;--l-menu-level: 0;--l-menu-item-height: 40px;--l-menu-active-color: var(--l-primary-color, #722ed1);--l-menu-active-background: var(--l-primary-color-light5, #f9f0ff);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)}";
5
- class v extends f {
1
+ import { on as d, off as c, $$ as u, $ as h, iterate as f, $one as a } from "ph-utils/dom";
2
+ import m from "../base.js";
3
+ import { initAttr as b } from "../utils/index.js";
4
+ const p = ":host{--l-menu-width: 240px;--l-menu-height: auto;--l-menu-color: #333333;--l-menu-background: #ffffff;--l-menu-level: 0;--l-menu-item-height: 40px;--l-menu-active-color: var(--l-primary-color, #722ed1);--l-menu-active-background: var(--l-primary-color-light5, #f9f0ff);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)}";
5
+ class x extends m {
6
6
  static baseName = "menu";
7
7
  /** 当前选中的菜单项 key 数组, 用 , 分割 */
8
8
  selectedKey = "";
@@ -10,54 +10,54 @@ class v extends f {
10
10
  orientation = "vertical";
11
11
  /** 主题 */
12
12
  theme = "light";
13
- /** 展开的菜单项数组 */
14
- #e = /* @__PURE__ */ new Set();
13
+ /** 是否手风琴模式, 只有一个子菜单展开 */
14
+ accordion = !1;
15
15
  connectedCallback() {
16
- m(this), this.classList.add(
16
+ b(this), this.classList.add(
17
17
  "l-menu",
18
18
  `l-menu--${this.orientation}`,
19
19
  `l-menu-${this.theme}`
20
- ), this.loadStyleText(b), super.connectedCallback();
20
+ ), this.loadStyleText(p), super.connectedCallback();
21
21
  }
22
22
  static get observedAttributes() {
23
23
  return ["selectedKeys", "orientation"];
24
24
  }
25
- attributeChangedCallback(e, t, i) {
25
+ attributeChangedCallback(t, i, e) {
26
26
  if (this.rendered) {
27
- if (e === "selectedKeys")
28
- this.selectedKey = i;
29
- else if (e === "orientation") {
27
+ if (t === "selectedKeys")
28
+ this.selectedKey !== e && (this.selectedKey = e, this.updateSelectedKeys(e));
29
+ else if (t === "orientation") {
30
30
  const s = this.classList;
31
- s.remove(`l-menu--${t}`), s.add(`l-menu--${i}`);
31
+ s.remove(`l-menu--${i}`), s.add(`l-menu--${e}`);
32
32
  }
33
33
  }
34
34
  }
35
35
  afterInit() {
36
- r(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
36
+ d(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
37
37
  }
38
38
  beforeDestroy() {
39
- a(this, "click", this.#t);
39
+ c(this, "click", this.#t);
40
40
  }
41
41
  render() {
42
- return c("slot");
42
+ return u("slot");
43
43
  }
44
- #t = (e) => {
45
- const { type: t, key: i, keyPaths: s, target: l } = this.#i(
46
- e.target
44
+ #t = (t) => {
45
+ const { type: i, key: e, keyPaths: s, target: l } = this.#e(
46
+ t.target
47
47
  );
48
- l && t === 2 && (this.#e.has(i) ? (l.setAttribute("collapse", "on"), this.#e.delete(i)) : (l.setAttribute("collapse", "off"), this.#e.add(i)));
48
+ l && (i === 2 ? l.hasAttribute("expanded") ? l.removeAttribute("expanded") : (l.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(s, !0)) : i === 1 && (this.#i(s), this.updateSelectedKeys(e), this.emit("select", { detail: { key: e, keyPaths: s } })));
49
49
  };
50
- #i(e) {
51
- let t = 0, i = "", s;
52
- const l = [];
50
+ #e(t, i) {
51
+ let e = 0, s = "", l;
52
+ const o = [];
53
53
  do {
54
- const o = e.tagName;
55
- if (["L-MENU", "BODY"].includes(o))
54
+ const r = t.tagName;
55
+ if (["L-MENU", "BODY"].includes(r))
56
56
  break;
57
- const n = e.getAttribute("key");
58
- n && (i || (i = n), l.unshift(n)), t === 0 && (o === "L-MENU-ITEM" ? (t = 1, s = e) : o === "L-SUB-MENU" && (s = e, t = 2)), e = e.parentElement;
59
- } while (t >= 0);
60
- return { type: t, key: i, keyPaths: l, target: s };
57
+ const n = t.getAttribute("key");
58
+ n && (s || (s = n), o.unshift(n), i && i(t, n)), e === 0 && (r === "L-MENU-ITEM" ? (e = 1, l = t) : r === "L-SUB-MENU" && (l = t, e = 2)), t = t.parentElement;
59
+ } while (e >= 0);
60
+ return { type: e, key: s, keyPaths: o, target: l };
61
61
  }
62
62
  /**
63
63
  * 展开与提供的 keys 对应的子菜单。
@@ -69,22 +69,27 @@ class v extends f {
69
69
  * @param keys - 表示要展开的子菜单的 key 的字符串数组。
70
70
  * @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
71
71
  */
72
- expandSubmenus(e, t = !1) {
73
- const i = d("l-sub-menu[key]", this);
74
- h(i, (s) => {
72
+ expandSubmenus(t, i = !1) {
73
+ const e = h("l-sub-menu[key]", this);
74
+ f(e, (s) => {
75
75
  const l = s.getAttribute("key") || "";
76
- e.includes(l) ? s.setAttribute("collapse", "off") : t && s.setAttribute("collapse", "on");
76
+ t.includes(l) ? s.setAttribute("expanded", "") : i && s.removeAttribute("expanded");
77
77
  });
78
78
  }
79
- updateSelectedKeys(e) {
80
- this.selectedKey = e;
81
- const t = u(`l-menu-item[key="${e}"]`, this);
82
- if (t) {
83
- t.setAttribute("active", "on");
84
- const { keyPaths: i } = this.#i(t);
85
- }
79
+ updateSelectedKeys(t) {
80
+ this.selectedKey = t;
81
+ const i = a(`l-menu-item[key="${t}"]`, this);
82
+ i && (i.setAttribute("active", ""), this.#e(i, (e) => {
83
+ e.setAttribute("active", ""), e.setAttribute("expanded", "");
84
+ }));
85
+ }
86
+ #i(t) {
87
+ const i = a("l-menu-item[active]", this);
88
+ i && this.#e(i, (e, s) => {
89
+ t.includes(s) || e.removeAttribute("active");
90
+ });
86
91
  }
87
92
  }
88
93
  export {
89
- v as default
94
+ x as default
90
95
  };
@@ -1,9 +1,11 @@
1
1
  import BaseComponent from "../base";
2
- export default class Menu extends BaseComponent {
2
+ export default class SubMenu extends BaseComponent {
3
3
  #private;
4
4
  static baseName: string;
5
5
  /** 默认折叠子菜单 */
6
- collapse: boolean;
6
+ expanded: boolean;
7
+ /** 是否激活状态, 通常是下面的子菜单项被选中 */
8
+ active: boolean;
7
9
  connectedCallback(): void;
8
10
  afterInit(): void;
9
11
  beforeDestroy(): void;
@@ -1,64 +1,82 @@
1
- import { addClass as r, removeClass as a, $one as i, on as p, off as d, queryHideNodeSize as h, $$ as l } from "ph-utils/dom";
2
- import u from "../base.js";
3
- import { initAttr as m, parseAttrValue as b } from "../utils/index.js";
4
- const g = ":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(.collapse) .l-submenu-arrow-icon{transform:translate3d(0,-50%,0) rotate(0)}.l-menu--collapse{display:none}";
5
- class y extends u {
1
+ import { addClass as r, $one as a, on as h, off as p, removeClass as d, queryHideNodeSize as u, toggleClass as m, $$ as n } from "ph-utils/dom";
2
+ import g from "../base.js";
3
+ import { initAttr as f, parseAttrValue as c } from "../utils/index.js";
4
+ const v = ":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}:host(.is-active) .l-submenu-title{color:var(--l-primary-color)}";
5
+ class C extends g {
6
6
  static baseName = "sub-menu";
7
7
  /** 默认折叠子菜单 */
8
- collapse = !0;
8
+ expanded = !1;
9
+ /** 是否激活状态, 通常是下面的子菜单项被选中 */
10
+ active = !1;
11
+ #e;
9
12
  connectedCallback() {
10
- this.loadStyleText(g), m(this), this.collapse ? r(this, "collapse") : a(this, "collapse"), super.connectedCallback();
13
+ this.loadStyleText(v), f(this), this.expanded || r(this, "collapsed"), this.active && r(this, "is-active"), super.connectedCallback();
11
14
  }
12
15
  afterInit() {
13
- const e = i(".l-menu", this.root);
14
- p(e, "transitionend", this.#e);
16
+ const e = a(".l-menu", this.root);
17
+ h(e, "transitionend", this.#t);
15
18
  }
16
19
  beforeDestroy() {
17
- const e = i(".l-menu", this.root);
18
- d(e, "transitionend", this.#e);
20
+ const e = a(".l-menu", this.root);
21
+ p(e, "transitionend", this.#t), this.#e && clearTimeout(this.#e);
19
22
  }
20
23
  static get observedAttributes() {
21
- return ["collapse"];
24
+ return ["expanded", "active"];
22
25
  }
23
- attributeChangedCallback(e, t, c) {
24
- if (this.rendered && e === "collapse") {
25
- const s = b(c, !0, "collapse");
26
- if (this.collapse !== s) {
27
- this.collapse = s;
28
- const o = i(".l-menu", this.root);
29
- if (this.collapse)
30
- r(this, "collapse"), o.style.height = "0";
31
- else {
32
- a(this, "collapse");
33
- const n = h(o, null);
34
- o.style.height = "0", a(o, "l-menu--collapse"), requestAnimationFrame(() => {
35
- o.style.height = `${n.height}px`;
36
- });
26
+ attributeChangedCallback(e, i, l) {
27
+ if (this.rendered) {
28
+ if (e === "expanded") {
29
+ const o = c(l, !1, "expanded");
30
+ if (this.expanded !== o) {
31
+ this.expanded = o;
32
+ const t = a(".l-menu", this.root);
33
+ if (this.expanded) {
34
+ d(this, "collapsed");
35
+ const s = u(t, null);
36
+ t.style.height = "0", d(t, "l-menu--collapsed"), requestAnimationFrame(() => {
37
+ t.style.height = `${s.height}px`;
38
+ });
39
+ } else {
40
+ const s = t.getBoundingClientRect();
41
+ t.style.height = `${s.height}px`, r(this, "collapsed"), requestAnimationFrame(() => {
42
+ t.style.height = "0";
43
+ });
44
+ }
45
+ this.#e = setTimeout(() => {
46
+ this.#t({
47
+ target: t,
48
+ propertyName: "height"
49
+ });
50
+ }, 350);
37
51
  }
52
+ } else if (e === "active") {
53
+ const o = c(l, !1, "active");
54
+ o !== this.active && (this.active = o, m(this, "is-active"));
38
55
  }
39
56
  }
40
57
  }
41
58
  render() {
42
- const e = document.createDocumentFragment(), t = l("div", { class: "l-submenu-title" });
43
- if (i('[slot="icon"]', this)) {
44
- const n = l("span", { class: "l-menu-icon-wrap" });
45
- n.appendChild(l("slot", { name: "icon" })), t.appendChild(n);
59
+ const e = document.createDocumentFragment(), i = n("div", { class: "l-submenu-title" });
60
+ if (a('[slot="icon"]', this)) {
61
+ const s = n("span", { class: "l-menu-icon-wrap" });
62
+ s.appendChild(n("slot", { name: "icon" })), i.appendChild(s);
46
63
  }
47
- t.appendChild(l("slot", { name: "title" }));
48
- const s = l("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
49
- t.appendChild(s), e.appendChild(t);
50
- const o = l("div", {
51
- class: ["l-menu", this.collapse ? "l-menu--collapse" : void 0]
64
+ i.appendChild(n("slot", { name: "title" }));
65
+ const o = n("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
66
+ i.appendChild(o), e.appendChild(i);
67
+ const t = n("div", {
68
+ class: ["l-menu", this.expanded ? void 0 : "l-menu--collapsed"]
52
69
  });
53
- return o.appendChild(l("slot")), e.appendChild(o), e;
70
+ return t.appendChild(n("slot")), e.appendChild(t), e;
54
71
  }
55
- #e = (e) => {
56
- if (this.collapse) {
57
- const t = e.target;
58
- t.style.removeProperty("height"), r(t, "l-menu--collapse");
72
+ #t = (e) => {
73
+ if (!this.expanded && e.propertyName === "height") {
74
+ this.#e && clearTimeout(this.#e);
75
+ const i = e.target;
76
+ i.style.removeProperty("height"), r(i, "l-menu--collapsed");
59
77
  }
60
78
  };
61
79
  }
62
80
  export {
63
- y as default
81
+ C as default
64
82
  };
@@ -9,7 +9,7 @@ export default class SelectOri extends FormInner {
9
9
  connectedCallback(): void;
10
10
  disconnectedCallback(): void;
11
11
  render(): string;
12
- protected _changeDisabled(): void;
12
+ protected disabledChange(): void;
13
13
  setOptions(options: Option[]): void;
14
14
  appendOptions(options: Option[]): void;
15
15
  reset(): void;
@@ -18,7 +18,7 @@ class g extends n {
18
18
  ["disabled", this.isDisabled()]
19
19
  ])}>${e}</select>`;
20
20
  }
21
- _changeDisabled() {
21
+ disabledChange() {
22
22
  this.$select && (this.$select.disabled = this.isDisabled());
23
23
  }
24
24
  setOptions(e) {
@@ -12,7 +12,7 @@ export declare function regist(component: any | any[], name?: string): void;
12
12
  export declare function useId(): string;
13
13
  export declare function parseAttrValue(value: string, defaultValue?: string): string;
14
14
  export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
15
- export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
15
+ export declare function parseAttrValue(value: string, defaultValue?: number): number;
16
16
  /**
17
17
  * 初始化元素的属性值。
18
18
  * 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。