litos-ui 0.15.4 → 0.15.6

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,12 +1,12 @@
1
1
  import BaseComponent from "../base";
2
2
  import type { RuleType } from "ph-utils/validator";
3
3
  export default class FormItem extends BaseComponent {
4
+ #private;
4
5
  static baseName: string;
5
6
  disabled: boolean;
6
7
  sharedAttrs: string[];
7
8
  /** 是否必须 */
8
9
  required: boolean;
9
- error?: string;
10
10
  /** 标签文本 */
11
11
  label?: string;
12
12
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
@@ -20,6 +20,8 @@ export default class FormItem extends BaseComponent {
20
20
  labelPosition?: "left" | "right" | "top";
21
21
  private formId?;
22
22
  static get observedAttributes(): string[];
23
+ get error(): string | undefined;
24
+ set error(error: string | undefined);
23
25
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
24
26
  connectedCallback(): void;
25
27
  disconnectedCallback(): void;
@@ -1,7 +1,7 @@
1
1
  import { $$ as i, $one as s, addClass as n, removeClass as d } from "ph-utils/dom";
2
2
  import { parseAttrValue as h, initAttr as m } from "../utils/index.js";
3
3
  import f from "../base.js";
4
- import { emit as o, add as p, clear as c, remove as b } from "../utils/event.js";
4
+ import { emit as o, add as c, clear as p, remove as b } from "../utils/event.js";
5
5
  import { random as a } from "ph-utils";
6
6
  const u = ':host{display:var(--l-form-item-display, flex);font-size:14px}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-edit-height, 32px);line-height:var(--l-form-edit-height, 32px);color:#606266;padding:0 10px 0 0;box-sizing:border-box}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}:host(.is-required) .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}:host(.l-form-item--left){--l-form-label-align: left}:host(.l-form-item--top){--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}';
7
7
  class I extends f {
@@ -10,7 +10,6 @@ class I extends f {
10
10
  sharedAttrs = ["disabled", "id", "name", "innerBlock"];
11
11
  /** 是否必须 */
12
12
  required = !1;
13
- error;
14
13
  /** 标签文本 */
15
14
  label;
16
15
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
@@ -23,12 +22,19 @@ class I extends f {
23
22
  innerBlock = !1;
24
23
  labelPosition = "right";
25
24
  formId;
25
+ #e;
26
26
  static get observedAttributes() {
27
27
  return ["error", "label", "disabled"];
28
28
  }
29
+ get error() {
30
+ return this.#e;
31
+ }
32
+ set error(e) {
33
+ this.#e = e, this._updateError();
34
+ }
29
35
  attributeChangedCallback(e, t, r) {
30
36
  if (e === "error")
31
- r != this.error && (this.error = r, this._updateError());
37
+ r != this.#e && (this.error = r);
32
38
  else if (e === "label")
33
39
  this.label = r, this._updateLabel();
34
40
  else if (e === "disabled") {
@@ -46,11 +52,11 @@ class I extends f {
46
52
  message: this.validity,
47
53
  rules: e
48
54
  };
49
- o(this.formId, "ruleChange", t), p(this.formId, "validateChange", this._validateChange);
55
+ o(this.formId, "ruleChange", t), c(this.formId, "validateChange", this._validateChange);
50
56
  }
51
57
  }
52
58
  disconnectedCallback() {
53
- c(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
59
+ p(this.id), this.formId && b(this.formId, "validateChange", this._validateChange);
54
60
  }
55
61
  setRules(e) {
56
62
  const t = { ...e, key: this.name };
@@ -75,7 +81,7 @@ class I extends f {
75
81
  }
76
82
  _validateChange = (e, t) => {
77
83
  const r = e === !0 ? void 0 : e[this.name];
78
- (t == null || t === this.name && this.error != r) && (this.error = r, this._updateError());
84
+ (t == null || t === this.name && this.error != r) && (this.error = r);
79
85
  };
80
86
  _updateError() {
81
87
  if (!this.rendered) return;
package/lib/form/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { $one as h, formatClass as o, formatStyle as f } from "ph-utils/dom";
1
+ import { $one as n, formatClass as o, formatStyle as f } from "ph-utils/dom";
2
2
  import m from "../base.js";
3
3
  import { parseAttrValue as c, initAttr as u } from "../utils/index.js";
4
4
  import { random as d } from "ph-utils";
5
- import { emit as l, add as n, clear as v } from "../utils/event.js";
5
+ import { emit as l, add as h, clear as v } from "../utils/event.js";
6
6
  import p from "ph-utils/validator";
7
7
  const b = ":host{display:block}.l-form{display:flex;gap:20px;flex-flow:column nowrap}.l-form-inline{display:flex;gap:20px;flex-flow:row wrap}.l-form.l-form-inline{--l-form-item-display: flex}.l-form.l-form--left{--l-form-label-align: left}.l-form.l-form--top{--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}";
8
8
  class $ extends m {
@@ -28,7 +28,7 @@ class $ extends m {
28
28
  const a = c(i, !1, t);
29
29
  a !== this.disabled && (l(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
30
30
  } else if (t === "label-position") {
31
- const a = h("form", this.root);
31
+ const a = n("form", this.root);
32
32
  a && (a.className = o([
33
33
  "l-form",
34
34
  this.inline ? "l-form-inline" : void 0,
@@ -37,7 +37,7 @@ class $ extends m {
37
37
  }
38
38
  }
39
39
  connectedCallback() {
40
- u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), n(this.id, "ruleChange", this.ruleChange), n(this.id, "valueChange", this._valueChange);
40
+ u(this), this.id || (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([b]), super.connectedCallback(), h(this.id, "ruleChange", this.ruleChange), h(this.id, "valueChange", this._valueChange);
41
41
  }
42
42
  disconnectedCallback() {
43
43
  v(this.id), this.validator = void 0;
@@ -96,8 +96,10 @@ class $ extends m {
96
96
  this.clearValidate(), l(this.id, "reset");
97
97
  }
98
98
  submit() {
99
- this.novalidate ? this.dispatchEvent(new CustomEvent("submit")) : this.validate().then((t) => {
100
- t && this.dispatchEvent(new CustomEvent("submit"));
99
+ this.novalidate ? this.dispatchEvent(new CustomEvent("submit", { detail: this.getData() })) : this.validate().then((t) => {
100
+ t && this.dispatchEvent(
101
+ new CustomEvent("submit", { detail: this.getData() })
102
+ );
101
103
  });
102
104
  }
103
105
  /**
@@ -28,11 +28,11 @@ export default class Input extends FormInner {
28
28
  /** 宽度铺满 */
29
29
  block: boolean;
30
30
  error: boolean;
31
- /** clearable */
32
- clearable: boolean;
33
31
  $inner?: HTMLInputElement;
34
32
  set value(value: any);
35
33
  get value(): any;
34
+ get clearable(): boolean;
35
+ set clearable(value: boolean);
36
36
  static get observedAttributes(): string[];
37
37
  connectedCallback(): void;
38
38
  disconnectedCallback(): void;
@@ -1,9 +1,9 @@
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
- import { initAttr as c, parseAttrValue as m } from "../utils/index.js";
3
- import b from "../form/form_inner.js";
1
+ import { addClass as n, removeClass as o, $one as u, on as h, formatStyle as f, off as d, $ as p, $$ as a } from "ph-utils/dom";
2
+ import { initAttr as b, parseAttrValue as c } from "../utils/index.js";
3
+ import m from "../form/form_inner.js";
4
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 b {
6
+ class y extends m {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
9
9
  type = "text";
@@ -18,42 +18,50 @@ class y extends b {
18
18
  /** 宽度铺满 */
19
19
  block = !1;
20
20
  error = !1;
21
- /** clearable */
22
- clearable = !1;
23
21
  $inner;
24
- set value(t) {
25
- this.setValue(t), this.$inner && (this.$inner.value = t);
22
+ #e = !1;
23
+ set value(e) {
24
+ this.setValue(e), this.$inner && (this.$inner.value = e);
26
25
  }
27
26
  get value() {
28
27
  return this.getValue();
29
28
  }
29
+ get clearable() {
30
+ return this.#e;
31
+ }
32
+ set clearable(e) {
33
+ this.#e = e, e ? n(this, "l-input--clearable") : o(this, "l-input--clearable");
34
+ }
30
35
  static get observedAttributes() {
31
- return ["disabled", "error"];
36
+ return ["disabled", "error", "clearable"];
32
37
  }
33
38
  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 = p(this._getStyleObj()) + this.getAttr("style", ""), this.error && o(this, "is-error"), this.getName() && this.formAttrs.id && g(this.formAttrs.id, "validateChange", this._validateChange);
39
+ b(this), this.loadStyleText([C]), super.connectedCallback(), this.$inner = u(".l-input__inner", this.root), h(this.$inner, "input", this._input), h(this.$inner, "change", this.#s), this.style.cssText = f(this._getStyleObj()) + this.getAttr("style", ""), this.error && n(this, "is-error"), this.getName() && this.formAttrs.id && g(this.formAttrs.id, "validateChange", this._validateChange);
35
40
  }
36
41
  disconnectedCallback() {
37
- super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), u(this.$inner, "input", this._input);
42
+ super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), d(this.$inner, "input", this._input);
38
43
  }
39
- attributeChange(t, i, e) {
40
- if (t === "error") {
41
- const s = m(e, !1, t);
42
- s !== this.error && (this.error = s, this._updateError());
44
+ attributeChange(e, s, t) {
45
+ if (e === "error") {
46
+ const i = c(t, !1, e);
47
+ i !== this.error && (this.error = i, this._updateError());
48
+ } else if (e === "clearable") {
49
+ const i = c(t, !1, e);
50
+ i !== this.clearable && (this.clearable = i);
43
51
  }
44
52
  }
45
53
  render() {
46
- const t = document.createDocumentFragment();
47
- if (d('[slot="prefix"]', this).length > 0) {
48
- const r = n("slot", {
54
+ const e = document.createDocumentFragment();
55
+ if (p('[slot="prefix"]', this).length > 0) {
56
+ const r = a("slot", {
49
57
  name: "prefix"
50
- }), l = n("span", {
58
+ }), l = a("span", {
51
59
  class: "l-input__prefix",
52
60
  part: "prefix"
53
61
  });
54
- l.appendChild(r), t.appendChild(l);
62
+ l.appendChild(r), e.appendChild(l);
55
63
  }
56
- const e = n("input", {
64
+ const t = a("input", {
57
65
  class: "l-input__inner",
58
66
  value: this.value,
59
67
  name: this.getName(),
@@ -62,53 +70,53 @@ class y extends b {
62
70
  part: "default",
63
71
  type: this.type
64
72
  });
65
- if (t.appendChild(e), d('[slot="suffix"]', this).length > 0) {
66
- const r = n("slot", {
73
+ if (e.appendChild(t), p('[slot="suffix"]', this).length > 0) {
74
+ const r = a("slot", {
67
75
  name: "suffix"
68
- }), l = n("span", {
76
+ }), l = a("span", {
69
77
  class: "l-input__suffix",
70
78
  part: "suffix"
71
79
  });
72
- l.appendChild(r), t.appendChild(l);
80
+ l.appendChild(r), e.appendChild(l);
73
81
  }
74
- return t;
82
+ return e;
75
83
  }
76
84
  /**
77
85
  * 设置自定义的输入解析器
78
86
  * @param cb
79
87
  */
80
- setParser(t) {
81
- this.parser = t;
88
+ setParser(e) {
89
+ this.parser = e;
82
90
  }
83
- _input = (t) => {
84
- const i = t.target;
85
- let e = i.value;
91
+ _input = (e) => {
92
+ const s = e.target;
93
+ let t = s.value;
86
94
  if (this.allowInput != null) {
87
- let s = this.allowInput.indexOf("."), r = s === -1 ? s : parseInt(this.allowInput.substring(s + 1));
88
- e = this._numberInputParse(e, {
95
+ let i = this.allowInput.indexOf("."), r = i === -1 ? i : parseInt(this.allowInput.substring(i + 1));
96
+ t = this._numberInputParse(t, {
89
97
  integer: this.allowInput.includes("integer"),
90
98
  negative: this.allowInput.startsWith("-"),
91
99
  precition: r
92
- }), e = String(e), i.value = e;
100
+ }), t = String(t), s.value = t;
93
101
  }
94
- this.parser != null && (e = this.parser(e), i.value = e), this.setValue(e), this.#t();
102
+ this.parser != null && (t = this.parser(t), s.value = t), this.setValue(t), this.#t();
95
103
  };
96
104
  #t() {
97
105
  if (this.clearable) {
98
- let t = h(".l-clearable", this.root);
106
+ let e = u(".l-clearable", this.root);
99
107
  if (this.value.length > 0) {
100
- if (t == null) {
101
- t = n("span", {
108
+ if (e == null) {
109
+ e = a("span", {
102
110
  class: "l-input__suffix l-clearable"
103
111
  });
104
- const i = n("l-close-filled-icon");
105
- t.appendChild(i), this.root.appendChild(t), a(t, "click", this.#e);
112
+ const s = a("l-close-filled-icon");
113
+ e.appendChild(s), this.root.appendChild(e), h(e, "click", this.#i);
106
114
  }
107
115
  } else
108
- t && (u(t, "click", this.#e), t.remove());
116
+ e && (d(e, "click", this.#i), e.remove());
109
117
  }
110
118
  }
111
- #e = () => {
119
+ #i = () => {
112
120
  this.value = "", this.dispatchEvent(
113
121
  new CustomEvent("input", { bubbles: !0, detail: { value: this.value } })
114
122
  ), this.#t();
@@ -116,43 +124,43 @@ class y extends b {
116
124
  disabledChange() {
117
125
  this.isDisabled() ? this.classList.add("is-disabled") : this.classList.remove("is-disabled"), this.$inner && (this.$inner.disabled = this.isDisabled());
118
126
  }
119
- _numberInputParse(t, i) {
120
- let e = t, s = i.negative ? "-?" : "";
121
- if (i.integer) {
122
- const l = e.match(new RegExp(`^(${s}\\d*)`));
123
- return l != null ? l[1] : e.substring(0, e.length - 1);
127
+ _numberInputParse(e, s) {
128
+ let t = e, i = s.negative ? "-?" : "";
129
+ if (s.integer) {
130
+ const l = t.match(new RegExp(`^(${i}\\d*)`));
131
+ return l != null ? l[1] : t.substring(0, t.length - 1);
124
132
  }
125
- const r = e.match(
133
+ const r = t.match(
126
134
  new RegExp(
127
- `(${s}\\d+\\.\\d{0,${i.precition}})|(${s}\\d*)`
135
+ `(${i}\\d+\\.\\d{0,${s.precition}})|(${i}\\d*)`
128
136
  )
129
137
  );
130
- return r != null ? e = r[1] || r[2] : e = "", r != null ? r[1] || r[2] : "";
138
+ return r != null ? t = r[1] || r[2] : t = "", r != null ? r[1] || r[2] : "";
131
139
  }
132
140
  _getStyleObj() {
133
- const t = {};
134
- return this._isBlock() && (t["--l-input-width"] = "100%"), this.width && (t["--l-input-width"] = this.width), t;
141
+ const e = {};
142
+ return this._isBlock() && (e["--l-input-width"] = "100%"), this.width && (e["--l-input-width"] = this.width), e;
135
143
  }
136
144
  _isBlock() {
137
145
  return this.block === !0 || this.formItemAttrs.innerBlock === !0 || this.formAttrs.innerBlock === !0;
138
146
  }
139
147
  _updateError() {
140
- this.error ? o(this, "is-error") : f(this, "is-error");
148
+ this.error ? n(this, "is-error") : o(this, "is-error");
141
149
  }
142
- _validateChange = (t, i) => {
143
- const e = this.getName();
144
- if (e) {
145
- const s = t === !0 ? !1 : t[e] != null;
146
- (i == null || i === e && this.error != s) && (this.error = s, this._updateError()), Object.keys(t)[0] === e && this.focus();
150
+ _validateChange = (e, s) => {
151
+ const t = this.getName();
152
+ if (t) {
153
+ const i = e === !0 ? !1 : e[t] != null;
154
+ (s == null || s === t && this.error != i) && (this.error = i, this._updateError()), Object.keys(e)[0] === t && this.focus();
147
155
  }
148
156
  };
149
- #i = (t) => {
150
- const i = t.target;
157
+ #s = (e) => {
158
+ const s = e.target;
151
159
  this.dispatchEvent(
152
160
  new CustomEvent("change", {
153
161
  bubbles: !0,
154
162
  composed: !0,
155
- detail: { value: i.value }
163
+ detail: { value: s.value }
156
164
  })
157
165
  );
158
166
  };
package/lib/menu/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { on as c, off as u, $$ as h, $ as o, iterate as a, $one as f } from "ph-utils/dom";
1
+ import { on as c, off as u, $$ as h, $ as l, iterate as a, $one as f } from "ph-utils/dom";
2
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 k extends m {
3
+ import { initAttr as b, parseAttrValue as p } from "../utils/index.js";
4
+ const x = ":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 A extends m {
6
6
  static baseName = "menu";
7
7
  /** 当前选中的菜单项 key 数组, 用 , 分割 */
8
8
  selectedIndex = "";
@@ -17,18 +17,22 @@ class k extends m {
17
17
  "l-menu",
18
18
  `l-menu--${this.orientation}`,
19
19
  `l-menu-${this.theme}`
20
- ), this.loadStyleText(p), super.connectedCallback();
20
+ ), this.loadStyleText(x), super.connectedCallback();
21
21
  }
22
22
  static get observedAttributes() {
23
- return ["selected-index", "orientation"];
23
+ return ["selected-index", "orientation", "accordion"];
24
24
  }
25
- attributeChangedCallback(e, s, t) {
25
+ attributeChangedCallback(t, s, i) {
26
+ if (t === "accordion") {
27
+ const e = p(i, !1, "accordion");
28
+ e !== this.accordion && (this.accordion = e);
29
+ }
26
30
  if (this.rendered) {
27
- if (e === "selected-index")
28
- this.selectedIndex !== t && this.updateSelectedKeys(t);
29
- else if (e === "orientation") {
30
- const i = this.classList;
31
- i.remove(`l-menu--${s}`), i.add(`l-menu--${t}`);
31
+ if (t === "selected-index")
32
+ this.selectedIndex !== i && this.updateSelectedKeys(i);
33
+ else if (t === "orientation") {
34
+ const e = this.classList;
35
+ e.remove(`l-menu--${s}`), e.add(`l-menu--${i}`);
32
36
  }
33
37
  }
34
38
  }
@@ -41,23 +45,23 @@ class k extends m {
41
45
  render() {
42
46
  return h("slot");
43
47
  }
44
- #t = (e) => {
45
- const { type: s, key: t, keyPaths: i, target: n } = this.#e(
46
- e.target
48
+ #t = (t) => {
49
+ const { type: s, key: i, keyPaths: e, target: n } = this.#e(
50
+ t.target
47
51
  );
48
- n && (s === 2 ? n.hasAttribute("expanded") ? n.removeAttribute("expanded") : (n.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(i, !0)) : s === 1 && (this.#i(i), this.updateSelectedKeys(t), this.emit("select", { detail: { key: t, keyPaths: i } })));
52
+ n && (s === 2 ? n.hasAttribute("expanded") ? n.removeAttribute("expanded") : (n.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(e, !0)) : s === 1 && (this.#i(e), this.updateSelectedKeys(i), this.emit("select", { detail: { key: i, keyPaths: e } })));
49
53
  };
50
- #e(e, s) {
51
- let t = 0, i = "", n;
52
- const l = [];
54
+ #e(t, s) {
55
+ let i = 0, e = "", n;
56
+ const o = [];
53
57
  do {
54
- const d = e.tagName;
58
+ const d = t.tagName;
55
59
  if (["L-MENU", "BODY"].includes(d))
56
60
  break;
57
- const r = e.getAttribute("index");
58
- r && (i || (i = r), l.unshift(r), s && s(e, r)), t === 0 && (d === "L-MENU-ITEM" ? (t = 1, n = e) : d === "L-SUB-MENU" && (n = e, t = 2)), e = e.parentElement;
59
- } while (t >= 0);
60
- return { type: t, key: i, keyPaths: l, target: n };
61
+ const r = t.getAttribute("index");
62
+ r && (e || (e = r), o.unshift(r), s && s(t, r)), i === 0 && (d === "L-MENU-ITEM" ? (i = 1, n = t) : d === "L-SUB-MENU" && (n = t, i = 2)), t = t.parentElement;
63
+ } while (i >= 0);
64
+ return { type: i, key: e, keyPaths: o, target: n };
61
65
  }
62
66
  /**
63
67
  * 展开与提供的 keys 对应的子菜单。
@@ -69,33 +73,33 @@ class k extends m {
69
73
  * @param keys - 表示要展开的子菜单的 key 的字符串数组。
70
74
  * @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
71
75
  */
72
- expandSubmenus(e, s = !1) {
73
- const t = o("l-sub-menu[index]", this);
74
- a(t, (i) => {
75
- const n = i.getAttribute("index") || "";
76
- e.includes(n) ? i.setAttribute("expanded", "") : s && i.removeAttribute("expanded");
76
+ expandSubmenus(t, s = !1) {
77
+ const i = l("l-sub-menu[index]", this);
78
+ a(i, (e) => {
79
+ const n = e.getAttribute("index") || "";
80
+ t.includes(n) ? e.setAttribute("expanded", "") : s && e.removeAttribute("expanded");
77
81
  });
78
82
  }
79
- updateSelectedKeys(e) {
80
- this.selectedIndex = e;
81
- const s = f(`l-menu-item[index="${e}"]`, this);
83
+ updateSelectedKeys(t) {
84
+ this.selectedIndex = t;
85
+ const s = f(`l-menu-item[index="${t}"]`, this);
82
86
  if (s) {
83
- const t = this.#e(s, (i) => {
84
- i.setAttribute("active", ""), i.setAttribute("expanded", "");
87
+ const i = this.#e(s, (e) => {
88
+ e.setAttribute("active", ""), e.setAttribute("expanded", "");
85
89
  });
86
- this.#i(t.keyPaths);
90
+ this.#i(i.keyPaths);
87
91
  }
88
92
  }
89
- #i(e) {
90
- const s = o("l-menu-item[active]", this);
91
- a(s, (t) => {
92
- const i = t.getAttribute("index") || "";
93
- e.includes(i) || this.#e(t, (n, l) => {
94
- e.includes(l) || (n.removeAttribute("expanded"), n.removeAttribute("active"));
93
+ #i(t) {
94
+ const s = l("l-menu-item[active]", this);
95
+ a(s, (i) => {
96
+ const e = i.getAttribute("index") || "";
97
+ t.includes(e) || this.#e(i, (n, o) => {
98
+ t.includes(o) || (n.removeAttribute("expanded"), n.removeAttribute("active"));
95
99
  });
96
100
  });
97
101
  }
98
102
  }
99
103
  export {
100
- k as default
104
+ A as default
101
105
  };
@@ -1,4 +1,4 @@
1
- import { addClass as l, $one as r, on as h, off as p, removeClass as d, toggleClass as u, $$ as n } from "ph-utils/dom";
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 || l(this, "collapsed"), this.active && l(this, "is-active"), super.connectedCallback();
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 = r(".l-menu", this.root);
16
+ const e = l(".l-menu", this.root);
17
17
  h(e, "transitionend", this.#t);
18
18
  }
19
19
  beforeDestroy() {
20
- const e = r(".l-menu", this.root);
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 = r(".l-menu", this.root);
33
- if (this.expanded) {
34
- d(this, "collapsed"), l(t, "l-menu--hide"), d(t, "l-menu--collapsed");
35
- const s = t.getBoundingClientRect();
36
- t.style.height = "0", d(t, "l-menu--hide"), requestAnimationFrame(() => {
37
- t.style.height = `${s.height}px`;
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
- } else {
40
+ else {
40
41
  const s = t.getBoundingClientRect();
41
- t.style.height = `${s.height}px`, l(this, "collapsed"), requestAnimationFrame(() => {
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 (r('[slot="icon"]', this)) {
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"), l(i, "l-menu--collapsed");
77
+ i.style.removeProperty("height"), r(i, "l-menu--collapsed");
77
78
  }
78
79
  };
79
80
  }
@@ -1,19 +1,19 @@
1
- import n from "../form/form_inner.js";
2
- import { initAttr as c, tagAttrs as r } from "../utils/index.js";
3
- import { $one as h, on as o, off as d } from "ph-utils/dom";
4
- import { i as u } from "../index-dwS1N2uN.js";
5
- class g extends n {
1
+ import a from "../form/form_inner.js";
2
+ import { tagAttrs as c } from "../utils/index.js";
3
+ import { $one as r, on as h, off as o } from "ph-utils/dom";
4
+ import { i as d } from "../index-dwS1N2uN.js";
5
+ class v extends a {
6
6
  static baseName = "select-ori";
7
7
  $select;
8
8
  connectedCallback() {
9
- c(this), this.loadStyleText(u), super.connectedCallback(), this.$select = h("select", this.root), this.value && (this.$select.value = this.value), o(this.$select, "change", this._handleChange);
9
+ this.loadStyleText(d), super.connectedCallback(), this.$select = r("select", this.root), this.value && (this.$select.value = this.value), h(this.$select, "change", this._handleChange);
10
10
  }
11
11
  disconnectedCallback() {
12
- super.disconnectedCallback(), this.$select && d(this.$select, "change", this._handleChange), this.$select = void 0;
12
+ super.disconnectedCallback(), this.$select && o(this.$select, "change", this._handleChange), this.$select = void 0;
13
13
  }
14
14
  render() {
15
15
  let e = this.innerHTML.trim();
16
- return `<select class="l-input"${r([
16
+ return `<select class="l-input__inner"${c([
17
17
  ["name", this.getName()],
18
18
  ["disabled", this.isDisabled()]
19
19
  ])}>${e}</select>`;
@@ -29,7 +29,7 @@ class g extends n {
29
29
  appendOptions(e) {
30
30
  if (!this.$select) return;
31
31
  const t = document.createDocumentFragment();
32
- for (let s = 0, a = e.length; s < a; s++) {
32
+ for (let s = 0, n = e.length; s < n; s++) {
33
33
  const l = e[s], i = document.createElement("option");
34
34
  i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
35
35
  }
@@ -47,5 +47,5 @@ class g extends n {
47
47
  };
48
48
  }
49
49
  export {
50
- g as default
50
+ v as default
51
51
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.15.4",
4
+ "version": "0.15.6",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
7
  "@eslint/js": "^9.30.1",