litos-ui 0.13.0 → 0.14.1

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 (51) hide show
  1. package/lib/base.d.ts +1 -1
  2. package/lib/base.js +3 -3
  3. package/lib/button/index.d.ts +4 -1
  4. package/lib/button/index.js +28 -13
  5. package/lib/carousel/index.d.ts +20 -0
  6. package/lib/carousel/index.js +280 -0
  7. package/lib/carousel/item.d.ts +6 -0
  8. package/lib/carousel/item.js +15 -0
  9. package/lib/carousel/timer.d.ts +5 -0
  10. package/lib/carousel/timer.js +19 -0
  11. package/lib/check/check.d.ts +22 -0
  12. package/lib/check/check.js +81 -0
  13. package/lib/check/checkbox.d.ts +7 -0
  14. package/lib/check/checkbox.js +25 -0
  15. package/lib/check/checkbox_group.d.ts +9 -0
  16. package/lib/check/checkbox_group.js +33 -0
  17. package/lib/check/index.d.ts +12 -0
  18. package/lib/check/index.js +35 -0
  19. package/lib/check/radio.d.ts +6 -0
  20. package/lib/check/radio.js +19 -0
  21. package/lib/check/radio_group.d.ts +6 -0
  22. package/lib/check/radio_group.js +24 -0
  23. package/lib/check-BlDsQQo0.js +4 -0
  24. package/lib/color_picker/index.d.ts +1 -1
  25. package/lib/color_picker/index.js +5 -5
  26. package/lib/form/form_inner.d.ts +1 -8
  27. package/lib/form/form_inner.js +31 -39
  28. package/lib/form/form_item.d.ts +1 -1
  29. package/lib/form/form_item.js +30 -37
  30. package/lib/form/index.js +5 -5
  31. package/lib/icon/close_filled.d.ts +1 -1
  32. package/lib/index.d.ts +12 -4
  33. package/lib/index.js +80 -72
  34. package/lib/input/index.js +10 -10
  35. package/lib/list/index.d.ts +1 -2
  36. package/lib/list/index.js +17 -17
  37. package/lib/md_input/index.js +9 -9
  38. package/lib/menu/index.d.ts +2 -0
  39. package/lib/menu/index.js +47 -42
  40. package/lib/menu/sub_menu.d.ts +4 -2
  41. package/lib/menu/sub_menu.js +59 -41
  42. package/lib/select_ori/index.d.ts +1 -1
  43. package/lib/select_ori/index.js +1 -1
  44. package/lib/utils/index.d.ts +1 -1
  45. package/lib/utils/index.js +49 -49
  46. package/lib/utils/transition.js +3 -2
  47. package/package.json +1 -1
  48. package/lib/checkbox/index.d.ts +0 -17
  49. package/lib/checkbox/index.js +0 -135
  50. package/lib/radio/index.d.ts +0 -28
  51. package/lib/radio/index.js +0 -122
package/lib/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a, impactDetect as f, initAttr as s, parseAttrValue as l, regist as m, setAttrs as u, tagAttr as p, tagAttrs as d, useId as x } from "./utils/index.js";
1
+ import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a, impactDetect as f, initAttr as s, parseAttrValue as u, regist as l, setAttrs as m, tagAttr as p, tagAttrs as d, useId as x } from "./utils/index.js";
2
2
  import { set as c, remove as I } from "./utils/clickoutside.js";
3
- import { default as g } from "./base.js";
3
+ import { default as C } from "./base.js";
4
4
  import { default as h } from "./message/index.js";
5
5
  import { default as M } from "./popover/index.js";
6
- import { default as S } from "./popconfirm/index.js";
7
- import { default as D } from "./dialog/index.js";
8
- import { default as T } from "./dialog/dialog_container.js";
9
- import { default as v } from "./loading/index.js";
10
- import { default as O } from "./modal/index.js";
6
+ import { default as R } from "./popconfirm/index.js";
7
+ import { default as k } from "./dialog/index.js";
8
+ import { default as D } from "./dialog/dialog_container.js";
9
+ import { default as b } from "./loading/index.js";
10
+ import { default as L } from "./modal/index.js";
11
11
  import { default as B } from "./icon/base.js";
12
- import { default as y } from "./icon/arrow_down.js";
13
- import { default as V } from "./icon/arrow_left.js";
14
- import { default as X } from "./icon/arrow_right.js";
15
- import { default as j } from "./icon/arrow_up.js";
16
- import { default as z } from "./icon/caret_top.js";
17
- import { default as G } from "./icon/caret_bottom.js";
12
+ import { default as G } from "./icon/arrow_down.js";
13
+ import { default as U } from "./icon/arrow_left.js";
14
+ import { default as W } from "./icon/arrow_right.js";
15
+ import { default as Y } from "./icon/arrow_up.js";
16
+ import { default as q } from "./icon/caret_top.js";
17
+ import { default as E } from "./icon/caret_bottom.js";
18
18
  import { default as J } from "./icon/font_icon.js";
19
19
  import { default as N } from "./icon/loading.js";
20
20
  import { default as Z } from "./icon/search.js";
@@ -22,81 +22,89 @@ import { default as $ } from "./icon/sun.js";
22
22
  import { default as eo } from "./icon/moon.js";
23
23
  import { default as ro } from "./icon/reduction.js";
24
24
  import { default as fo } from "./icon/refresh_left.js";
25
- import { default as lo } from "./icon/refresh_right.js";
26
- import { default as uo } from "./icon/sort.js";
25
+ import { default as uo } from "./icon/refresh_right.js";
26
+ import { default as mo } from "./icon/sort.js";
27
27
  import { default as xo } from "./icon/theme_default.js";
28
28
  import { default as co } from "./icon/close.js";
29
29
  import { default as io } from "./icon/info.js";
30
- import { default as Co } from "./icon/success.js";
30
+ import { default as go } from "./icon/success.js";
31
31
  import { default as Ao } from "./icon/warn.js";
32
32
  import { default as Po } from "./icon/close_filled.js";
33
- import { default as wo } from "./form/index.js";
34
- import { default as Ro } from "./form/form_item.js";
35
- import { default as ko } from "./radio/index.js";
36
- import { default as Lo } from "./checkbox/index.js";
37
- import { default as bo } from "./button/index.js";
38
- import { default as Fo } from "./input/index.js";
39
- import { default as Uo } from "./select_ori/index.js";
40
- import { default as Wo } from "./switch/index.js";
41
- import { default as Yo } from "./md_input/index.js";
42
- import { default as qo } from "./list/index.js";
43
- import { default as Eo } from "./polygon/index.js";
44
- import { default as Ho } from "./color_picker/index.js";
45
- import { default as Ko } from "./tabbar/index.js";
46
- import { default as Qo } from "./theme/index.js";
47
- import { default as _o } from "./theme/theme_color.js";
48
- import { default as oe } from "./date_picker/index.js";
49
- import { default as te } from "./menu/index.js";
50
- import { default as ae } from "./menu/menu_item.js";
51
- import { default as se } from "./menu/sub_menu.js";
33
+ import { default as So } from "./form/index.js";
34
+ import { default as wo } from "./form/form_item.js";
35
+ import { default as To } from "./check/radio_group.js";
36
+ import { default as vo } from "./check/radio.js";
37
+ import { default as Oo } from "./check/checkbox.js";
38
+ import { default as Fo } from "./check/checkbox_group.js";
39
+ import { default as yo } from "./button/index.js";
40
+ import { default as Vo } from "./input/index.js";
41
+ import { default as Xo } from "./select_ori/index.js";
42
+ import { default as jo } from "./switch/index.js";
43
+ import { default as zo } from "./md_input/index.js";
44
+ import { default as Ho } from "./list/index.js";
45
+ import { default as Ko } from "./polygon/index.js";
46
+ import { default as Qo } from "./color_picker/index.js";
47
+ import { default as _o } from "./tabbar/index.js";
48
+ import { default as oe } from "./theme/index.js";
49
+ import { default as te } from "./theme/theme_color.js";
50
+ import { default as ae } from "./date_picker/index.js";
51
+ import { default as se } from "./menu/index.js";
52
+ import { default as le } from "./menu/menu_item.js";
53
+ import { default as pe } from "./menu/sub_menu.js";
54
+ import { default as xe } from "./carousel/index.js";
55
+ import { default as ce } from "./carousel/item.js";
52
56
  export {
53
- y as ArrowDownIcon,
54
- V as ArrowLeftIcon,
55
- X as ArrowRightIcon,
56
- j as ArrowUpIcon,
57
- g as BaseComponent,
57
+ G as ArrowDownIcon,
58
+ U as ArrowLeftIcon,
59
+ W as ArrowRightIcon,
60
+ Y as ArrowUpIcon,
61
+ C as BaseComponent,
58
62
  B as BaseIcon,
59
- bo as Button,
60
- G as CaretBottomIcon,
61
- z as CaretTopIcon,
62
- Lo as Checkbox,
63
+ yo as Button,
64
+ E as CaretBottomIcon,
65
+ q as CaretTopIcon,
66
+ xe as Carousel,
67
+ ce as CarouselItem,
68
+ Oo as Checkbox,
69
+ Fo as CheckboxGroup,
63
70
  Po as CloseFilledIcon,
64
71
  co as CloseIcon,
65
- Ho as ColorPicker,
66
- oe as DatePicker,
67
- D as Dialog,
68
- T as DialogContainer,
72
+ Qo as ColorPicker,
73
+ ae as DatePicker,
74
+ k as Dialog,
75
+ D as DialogContainer,
69
76
  J as FontIcon,
70
- wo as Form,
71
- Ro as FormItem,
77
+ So as Form,
78
+ wo as FormItem,
72
79
  io as InfoIcon,
73
- Fo as Input,
74
- qo as List,
75
- v as Loading,
80
+ Vo as Input,
81
+ Ho as List,
82
+ b as Loading,
76
83
  N as LoadingIcon,
77
- Yo as MdInput,
78
- te as Menu,
79
- ae as MenuItem,
84
+ zo as MdInput,
85
+ se as Menu,
86
+ le as MenuItem,
80
87
  h as Message,
81
- O as Modal,
88
+ L as Modal,
82
89
  eo as MoonIcon,
83
- Eo as Polygon,
84
- S as Popconfirm,
90
+ Ko as Polygon,
91
+ R as Popconfirm,
85
92
  M as Popover,
86
- ko as Radio,
93
+ vo as Radio,
94
+ To as RadioGroup,
87
95
  ro as ReductionIcon,
88
96
  fo as RefreshLeftIcon,
89
- lo as RefreshRightIcon,
97
+ uo as RefreshRightIcon,
90
98
  Z as SearchIcon,
91
- Uo as SelectOri,
92
- uo as SortIcon,
93
- se as SubMenu,
94
- Co as SuccessIcon,
99
+ Xo as SelectOri,
100
+ mo as SortIcon,
101
+ pe as SubMenu,
102
+ go as SuccessIcon,
95
103
  $ as SunIcon,
96
- Wo as Switch,
97
- Ko as Tabbar,
98
- Qo as Theme,
99
- _o as ThemeColor,
104
+ jo as Switch,
105
+ _o as Tabbar,
106
+ oe as Theme,
107
+ te as ThemeColor,
100
108
  xo as ThemeDefaultIcon,
101
109
  Ao as WarnIcon,
102
110
  c as addClickOutside,
@@ -105,10 +113,10 @@ export {
105
113
  a as getPopoverOffsetY,
106
114
  f as impactDetect,
107
115
  s as initAttr,
108
- l as parseAttrValue,
109
- m as regist,
116
+ u as parseAttrValue,
117
+ l as regist,
110
118
  I as removeClickOutside,
111
- u as setAttrs,
119
+ m as setAttrs,
112
120
  p as tagAttr,
113
121
  d as tagAttrs,
114
122
  x as useId
@@ -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;