litos-ui 0.15.5 → 0.15.7

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 (84) hide show
  1. package/lib/button/index.d.ts +4 -0
  2. package/lib/button/index.js +84 -57
  3. package/lib/check/checkbox.js +1 -1
  4. package/lib/check/radio.js +1 -1
  5. package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
  6. package/lib/collapse/index.d.ts +19 -0
  7. package/lib/collapse/index.js +88 -0
  8. package/lib/collapse/item.d.ts +15 -0
  9. package/lib/collapse/item.js +115 -0
  10. package/lib/color_picker/index.js +1 -1
  11. package/lib/date_picker/index.js +1 -1
  12. package/lib/description_panel/index.d.ts +4 -4
  13. package/lib/description_panel/index.js +59 -11
  14. package/lib/dialog/dialog_container.js +1 -1
  15. package/lib/form/form_inner.d.ts +2 -1
  16. package/lib/form/form_inner.js +16 -15
  17. package/lib/form/form_item.d.ts +3 -1
  18. package/lib/form/form_item.js +19 -13
  19. package/lib/form/index.js +8 -6
  20. package/lib/icon/d_arrow_left.d.ts +6 -0
  21. package/lib/icon/d_arrow_left.js +13 -0
  22. package/lib/icon/d_arrow_right.d.ts +6 -0
  23. package/lib/icon/d_arrow_right.js +13 -0
  24. package/lib/icon/more.d.ts +6 -0
  25. package/lib/icon/more.js +13 -0
  26. package/lib/icon/select.d.ts +6 -0
  27. package/lib/icon/select.js +13 -0
  28. package/lib/icon/zoom_in.d.ts +6 -0
  29. package/lib/icon/zoom_in.js +13 -0
  30. package/lib/icon/zoom_out.d.ts +6 -0
  31. package/lib/icon/zoom_out.js +13 -0
  32. package/lib/image/image_preview.d.ts +24 -0
  33. package/lib/image/image_preview.js +104 -0
  34. package/lib/image/index.d.ts +50 -0
  35. package/lib/image/index.js +176 -0
  36. package/lib/index-D4II9KsF.js +4 -0
  37. package/lib/index.d.ts +36 -4
  38. package/lib/index.js +157 -120
  39. package/lib/input/index.d.ts +6 -2
  40. package/lib/input/index.js +70 -51
  41. package/lib/litos-ui.css +1 -1
  42. package/lib/mask/index.d.ts +23 -0
  43. package/lib/mask/index.js +110 -0
  44. package/lib/md_input/index.js +11 -11
  45. package/lib/menu/index.js +46 -42
  46. package/lib/modal/index.d.ts +1 -1
  47. package/lib/modal/index.js +7 -7
  48. package/lib/modal/modal_box.js +10 -10
  49. package/lib/page_header/index.d.ts +20 -0
  50. package/lib/page_header/index.js +109 -0
  51. package/lib/pagination/index.d.ts +27 -0
  52. package/lib/pagination/index.js +248 -0
  53. package/lib/qrcode/index.js +4 -4
  54. package/lib/select/index.d.ts +79 -0
  55. package/lib/select/index.js +406 -0
  56. package/lib/select_ori/index.js +10 -10
  57. package/lib/switch/index.js +4 -4
  58. package/lib/tabbar/index.js +1 -1
  59. package/lib/tabbar/item.js +1 -1
  60. package/lib/table/index.d.ts +46 -0
  61. package/lib/table/index.js +200 -0
  62. package/lib/table/types.d.ts +28 -0
  63. package/lib/table/types.js +1 -0
  64. package/lib/tabs/index.d.ts +7 -0
  65. package/lib/tabs/index.js +43 -0
  66. package/lib/tag/index.d.ts +16 -0
  67. package/lib/tag/index.js +77 -0
  68. package/lib/theme/index.js +6 -6
  69. package/lib/utils/index.d.ts +6 -28
  70. package/lib/utils/index.js +61 -86
  71. package/lib/utils/popover.d.ts +137 -0
  72. package/lib/utils/popover.js +354 -0
  73. package/lib/utils/transition.js +26 -50
  74. package/package.json +13 -13
  75. package/styles/popover.css +66 -0
  76. package/styles/reset.css +1 -1
  77. package/styles/select.css +37 -0
  78. package/styles/tabs.css +13 -0
  79. package/styles/vars.css +2 -1
  80. package/lib/index-dwS1N2uN.js +0 -4
  81. package/lib/popconfirm/index.d.ts +0 -7
  82. package/lib/popconfirm/index.js +0 -30
  83. package/lib/popover/index.d.ts +0 -34
  84. package/lib/popover/index.js +0 -150
@@ -1,8 +1,8 @@
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";
1
+ import { addClass as h, removeClass as u, $one as d, on as o, formatStyle as f, off as p, $ as c, $$ as a } from "ph-utils/dom";
2
+ import { initAttr as g, parseAttrValue as n } from "../utils/index.js";
3
3
  import b from "../form/form_inner.js";
4
- import { add as g, remove as v } from "../utils/event.js";
5
- import { i as C } from "../index-dwS1N2uN.js";
4
+ import { add as m, remove as x } from "../utils/event.js";
5
+ import { i as v } from "../index-D4II9KsF.js";
6
6
  class y extends b {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
@@ -18,58 +18,77 @@ class y extends b {
18
18
  /** 宽度铺满 */
19
19
  block = !1;
20
20
  error = !1;
21
- /** clearable */
22
- clearable = !1;
21
+ maxlength;
22
+ inputmode = "text";
23
23
  $inner;
24
+ #t = !1;
24
25
  set value(t) {
25
26
  this.setValue(t), this.$inner && (this.$inner.value = t);
26
27
  }
27
28
  get value() {
28
29
  return this.getValue();
29
30
  }
31
+ get clearable() {
32
+ return this.#t;
33
+ }
34
+ set clearable(t) {
35
+ this.#t = t, t ? h(this, "l-input--clearable") : u(this, "l-input--clearable");
36
+ }
30
37
  static get observedAttributes() {
31
- return ["disabled", "error"];
38
+ return ["disabled", "error", "clearable", "maxlength", "inputmode"];
32
39
  }
33
40
  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);
41
+ g(this), this.loadStyleText([v]), super.connectedCallback(), this.$inner = d(".l-input__inner", this.root), o(this.$inner, "input", this._input), o(this.$inner, "change", this.#s), this.style.cssText = f(this._getStyleObj()) + this.getAttr("style", ""), this.error && h(this, "is-error"), this.getName() && this.formAttrs.id && m(this.formAttrs.id, "validateChange", this._validateChange);
35
42
  }
36
43
  disconnectedCallback() {
37
- super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), u(this.$inner, "input", this._input);
44
+ super.disconnectedCallback(), this.formAttrs.id && x(this.formAttrs.id, "validateChange", this._validateChange), p(this.$inner, "input", this._input);
38
45
  }
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());
46
+ attributeChange(t, s, e) {
47
+ const r = n(
48
+ e,
49
+ this[t],
50
+ t
51
+ );
52
+ if (r !== this[t] && (this[t] = r), t === "error") {
53
+ const i = n(e, !1, t);
54
+ i !== this.error && (this.error = i, this._updateError());
55
+ } else if (t === "clearable") {
56
+ const i = n(e, !1, t);
57
+ i !== this.clearable && (this.clearable = i);
58
+ } else if (t === "maxlength") {
59
+ const i = n(e, -1);
60
+ i !== this.maxlength && (this.maxlength = i);
43
61
  }
44
62
  }
45
63
  render() {
46
64
  const t = document.createDocumentFragment();
47
- if (d('[slot="prefix"]', this).length > 0) {
48
- const r = n("slot", {
65
+ if (c('[slot="prefix"]', this).length > 0) {
66
+ const i = a("slot", {
49
67
  name: "prefix"
50
- }), l = n("span", {
68
+ }), l = a("span", {
51
69
  class: "l-input__prefix",
52
70
  part: "prefix"
53
71
  });
54
- l.appendChild(r), t.appendChild(l);
72
+ l.appendChild(i), t.appendChild(l);
55
73
  }
56
- const e = n("input", {
74
+ const e = a("input", {
57
75
  class: "l-input__inner",
58
76
  value: this.value,
59
77
  name: this.getName(),
60
78
  placeholder: this.placeholder,
61
79
  disabled: this.isDisabled(),
62
80
  part: "default",
63
- type: this.type
81
+ type: this.type,
82
+ inputmode: this.inputmode
64
83
  });
65
- if (t.appendChild(e), d('[slot="suffix"]', this).length > 0) {
66
- const r = n("slot", {
84
+ if (this.maxlength && this.maxlength >= 0 && e.setAttribute("maxlength", String(this.maxlength)), t.appendChild(e), c('[slot="suffix"]', this).length > 0) {
85
+ const i = a("slot", {
67
86
  name: "suffix"
68
- }), l = n("span", {
87
+ }), l = a("span", {
69
88
  class: "l-input__suffix",
70
89
  part: "suffix"
71
90
  });
72
- l.appendChild(r), t.appendChild(l);
91
+ l.appendChild(i), t.appendChild(l);
73
92
  }
74
93
  return t;
75
94
  }
@@ -81,53 +100,53 @@ class y extends b {
81
100
  this.parser = t;
82
101
  }
83
102
  _input = (t) => {
84
- const i = t.target;
85
- let e = i.value;
103
+ const s = t.target;
104
+ let e = s.value;
86
105
  if (this.allowInput != null) {
87
- let s = this.allowInput.indexOf("."), r = s === -1 ? s : parseInt(this.allowInput.substring(s + 1));
106
+ let r = this.allowInput.indexOf("."), i = r === -1 ? r : parseInt(this.allowInput.substring(r + 1));
88
107
  e = this._numberInputParse(e, {
89
108
  integer: this.allowInput.includes("integer"),
90
109
  negative: this.allowInput.startsWith("-"),
91
- precition: r
92
- }), e = String(e), i.value = e;
110
+ precition: i
111
+ }), e = String(e);
93
112
  }
94
- this.parser != null && (e = this.parser(e), i.value = e), this.setValue(e), this.#t();
113
+ this.parser != null && (e = this.parser(e)), s.value = e, this.setValue(e), this.#e();
95
114
  };
96
- #t() {
115
+ #e() {
97
116
  if (this.clearable) {
98
- let t = h(".l-clearable", this.root);
117
+ let t = d(".l-clearable", this.root);
99
118
  if (this.value.length > 0) {
100
119
  if (t == null) {
101
- t = n("span", {
120
+ t = a("span", {
102
121
  class: "l-input__suffix l-clearable"
103
122
  });
104
- const i = n("l-close-filled-icon");
105
- t.appendChild(i), this.root.appendChild(t), a(t, "click", this.#e);
123
+ const s = a("l-close-filled-icon");
124
+ t.appendChild(s), this.root.appendChild(t), o(t, "click", this.#i);
106
125
  }
107
126
  } else
108
- t && (u(t, "click", this.#e), t.remove());
127
+ t && (p(t, "click", this.#i), t.remove());
109
128
  }
110
129
  }
111
- #e = () => {
130
+ #i = () => {
112
131
  this.value = "", this.dispatchEvent(
113
132
  new CustomEvent("input", { bubbles: !0, detail: { value: this.value } })
114
- ), this.#t();
133
+ ), this.#e();
115
134
  };
116
135
  disabledChange() {
117
136
  this.isDisabled() ? this.classList.add("is-disabled") : this.classList.remove("is-disabled"), this.$inner && (this.$inner.disabled = this.isDisabled());
118
137
  }
119
- _numberInputParse(t, i) {
120
- let e = t, s = i.negative ? "-?" : "";
121
- if (i.integer) {
122
- const l = e.match(new RegExp(`^(${s}\\d*)`));
138
+ _numberInputParse(t, s) {
139
+ let e = t, r = s.negative ? "-?" : "";
140
+ if (s.integer) {
141
+ const l = e.match(new RegExp(`^(${r}\\d*)`));
123
142
  return l != null ? l[1] : e.substring(0, e.length - 1);
124
143
  }
125
- const r = e.match(
144
+ const i = e.match(
126
145
  new RegExp(
127
- `(${s}\\d+\\.\\d{0,${i.precition}})|(${s}\\d*)`
146
+ `(${r}\\d+\\.\\d{0,${s.precition}})|(${r}\\d*)`
128
147
  )
129
148
  );
130
- return r != null ? e = r[1] || r[2] : e = "", r != null ? r[1] || r[2] : "";
149
+ return i != null ? e = i[1] || i[2] : e = "", i != null ? i[1] || i[2] : "";
131
150
  }
132
151
  _getStyleObj() {
133
152
  const t = {};
@@ -137,22 +156,22 @@ class y extends b {
137
156
  return this.block === !0 || this.formItemAttrs.innerBlock === !0 || this.formAttrs.innerBlock === !0;
138
157
  }
139
158
  _updateError() {
140
- this.error ? o(this, "is-error") : f(this, "is-error");
159
+ this.error ? h(this, "is-error") : u(this, "is-error");
141
160
  }
142
- _validateChange = (t, i) => {
161
+ _validateChange = (t, s) => {
143
162
  const e = this.getName();
144
163
  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();
164
+ const r = t === !0 ? !1 : t[e] != null;
165
+ (s == null || s === e && this.error != r) && (this.error = r, this._updateError()), Object.keys(t)[0] === e && this.focus();
147
166
  }
148
167
  };
149
- #i = (t) => {
150
- const i = t.target;
168
+ #s = (t) => {
169
+ const s = t.target;
151
170
  this.dispatchEvent(
152
171
  new CustomEvent("change", {
153
172
  bubbles: !0,
154
173
  composed: !0,
155
- detail: { value: i.value }
174
+ detail: { value: s.value }
156
175
  })
157
176
  );
158
177
  };
package/lib/litos-ui.css CHANGED
@@ -1 +1 @@
1
- :host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}:host{display:inline-flex;width:auto}
1
+ :host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}:host{display:inline-flex;width:auto;box-sizing:border-box}
@@ -0,0 +1,23 @@
1
+ import BaseComponent from "../base";
2
+ export default class Mask extends BaseComponent {
3
+ #private;
4
+ static baseName: string;
5
+ zIndex: number;
6
+ /** 是否可以通过点击 mask 关闭对话框 */
7
+ maskClosable: boolean;
8
+ /** 是否在打开时禁用 body 滚动 */
9
+ lockScroll: boolean;
10
+ get open(): boolean;
11
+ set open(value: boolean);
12
+ static customAttributes: string[];
13
+ static get observedAttributes(): string[];
14
+ connectedCallback(): void;
15
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
16
+ render(): DocumentFragment;
17
+ contentRender(): string | HTMLElement | DocumentFragment;
18
+ afterInit(): void;
19
+ beforeDestroy(): void;
20
+ afterOpened(): void;
21
+ afterClosed(): void;
22
+ onAction(action: string): boolean;
23
+ }
@@ -0,0 +1,110 @@
1
+ import a from "../base.js";
2
+ import { kebabToCamel as r, parseAttrValue as c } from "../utils/index.js";
3
+ import { $$ as n, addClass as d, $one as i, transition as l, hasClass as p, removeClass as h, on as f, off as m, shouldEventNext as k } from "ph-utils/dom";
4
+ const u = ":host{display:none;position:relative}:host(.open){display:block}.l-mask,.l-panel{position:fixed;inset:0;opacity:1}.l-mask{background-color:#00000080;z-index:var(--l-mask-zindex, 100)}.l-panel{z-index:calc(var(--l-mask-zindex, 100) + 1);color:#fff}";
5
+ class x extends a {
6
+ static baseName = "mask";
7
+ #t = !1;
8
+ zIndex = 100;
9
+ /** 是否可以通过点击 mask 关闭对话框 */
10
+ maskClosable = !0;
11
+ /** 是否在打开时禁用 body 滚动 */
12
+ lockScroll = !0;
13
+ #e = "";
14
+ get open() {
15
+ return this.#t;
16
+ }
17
+ set open(t) {
18
+ this.#t = t, this.rendered && this.#s();
19
+ }
20
+ static customAttributes = [];
21
+ static get observedAttributes() {
22
+ return [
23
+ "open",
24
+ "z-index",
25
+ "mask-closable",
26
+ "lock-scroll",
27
+ ...this.customAttributes
28
+ ];
29
+ }
30
+ connectedCallback() {
31
+ this.loadStyleText(u), super.connectedCallback();
32
+ }
33
+ attributeChangedCallback(t, e, s) {
34
+ t = r(t);
35
+ const o = c(
36
+ s,
37
+ this[t],
38
+ t
39
+ );
40
+ if (o !== this[t])
41
+ switch (this[t] = o, t) {
42
+ case "zIndex":
43
+ o === 100 ? this.style.removeProperty("--l-mask-zindex") : this.style.setProperty("--l-mask-zindex", o);
44
+ break;
45
+ }
46
+ }
47
+ render() {
48
+ const t = document.createDocumentFragment(), e = n("div", {
49
+ class: "l-mask",
50
+ part: "mask"
51
+ });
52
+ t.appendChild(e);
53
+ const s = n("div", {
54
+ class: "l-panel",
55
+ part: "panel"
56
+ }), o = this.contentRender();
57
+ return typeof o == "string" ? s.innerHTML = o : s.appendChild(o), t.appendChild(s), t;
58
+ }
59
+ contentRender() {
60
+ return "<slot></slot>";
61
+ }
62
+ #s() {
63
+ if (this.open) {
64
+ this.lockScroll && (this.#e = getComputedStyle(document.body).overflow, document.body.style.overflow = "hidden"), d(this, "open");
65
+ const t = i(".l-mask", this.root);
66
+ t && l(t, [["opacity", "0", "0.3s"]], "enter");
67
+ const e = i(".l-panel", this.root);
68
+ e && l(e, [["opacity", "0", "0.3s"]], "enter"), this.afterOpened();
69
+ } else if (p(this, "open")) {
70
+ this.emit("close");
71
+ const t = i(".l-panel", this.root);
72
+ t && l(t, [["opacity", "0", "0.3s"]], "leave");
73
+ const e = i(".l-mask", this.root);
74
+ e && l(e, [["opacity", "0", "0.3s"]], "leave", () => {
75
+ h(this, "open"), this.emit("closed");
76
+ }), this.lockScroll && (document.body.style.overflow = this.#e), this.afterClosed();
77
+ }
78
+ }
79
+ afterInit() {
80
+ this.#s();
81
+ const t = i(".l-panel", this.root);
82
+ t && f(t, "click", this.#o);
83
+ }
84
+ beforeDestroy() {
85
+ const t = i(".l-panel", this.root);
86
+ t && m(t, "click", this.#o);
87
+ }
88
+ #o = (t) => {
89
+ const [e, s] = k(
90
+ t,
91
+ "data-action",
92
+ t.currentTarget
93
+ );
94
+ if (!e) {
95
+ this.maskClosable && (this.open = !1);
96
+ return;
97
+ }
98
+ this.onAction(s) || this.emit("action", { detail: s });
99
+ };
100
+ afterOpened() {
101
+ }
102
+ afterClosed() {
103
+ }
104
+ onAction(t) {
105
+ return !1;
106
+ }
107
+ }
108
+ export {
109
+ x as default
110
+ };
@@ -1,8 +1,8 @@
1
- import { addClass as n, $$ as r, $one as l, on as a, off as d, removeClass as u } from "ph-utils/dom";
1
+ import { addClass as i, $$ 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
- import { isBlank as s, random as h } from "ph-utils";
5
- const c = ":host{--l-input-width: 180px;position:relative;width:var(--l-input-width, 180px);height:var(--l-form-edit-height, 32px);display:inline-block}.l-md-input__inner{width:100%;height:100%;border:0;background:transparent;border-style:solid;border-color:silver;border-bottom-width:1px;box-sizing:border-box;outline:none;transition:border-color .3s}.l-md-input__inner:focus{border-color:var(--l-primary-color, #722ed1)}:host(.l-has-value) .l-md-input__label,.l-md-input__inner:focus+.l-md-input__label{transform:translate3d(0,-150%,0);font-size:12px}.l-md-input__inner:focus+.l-md-input__label{color:var(--nt-primary-color, #722ed1)}.l-md-input__label{display:flex;align-items:center;position:absolute;top:50%;bottom:0;left:0;transition:color .3s,transform .3s;color:#8c8c8c;cursor:text;line-height:1;transform:translate3d(0,-50%,0);font-size:13px}:host(.l-md-input-outline){--l-input-label-background: #ffffff}:host(.l-md-input-outline) .l-md-input__inner{border-width:1px;border-radius:4px;padding:0 10px}:host(.l-md-input-outline) .l-md-input__label{left:10px}:host(.l-md-input-outline) .l-md-input__inner:focus{border-width:2px}:host(.l-md-input-outline) .l-md-input__inner:focus+.l-md-input__label,:host(.l-md-input-outline.l-has-value) .l-md-input__label{padding-left:4px;padding-right:4px;background-color:#fff}";
4
+ import { isBlank as s, random as c } from "ph-utils";
5
+ const h = ":host{--l-input-width: 180px;position:relative;width:var(--l-input-width, 180px);height:var(--l-form-control-height, 32px);display:inline-block}.l-md-input__inner{width:100%;height:100%;border:0;background:transparent;border-style:solid;border-color:silver;border-bottom-width:1px;box-sizing:border-box;outline:none;transition:border-color .3s}.l-md-input__inner:focus{border-color:var(--l-primary-color, #722ed1)}:host(.l-has-value) .l-md-input__label,.l-md-input__inner:focus+.l-md-input__label{transform:translate3d(0,-150%,0);font-size:12px}.l-md-input__inner:focus+.l-md-input__label{color:var(--nt-primary-color, #722ed1)}.l-md-input__label{display:flex;align-items:center;position:absolute;top:50%;bottom:0;left:0;transition:color .3s,transform .3s;color:#8c8c8c;cursor:text;line-height:1;transform:translate3d(0,-50%,0);font-size:13px}:host(.l-md-input-outline){--l-input-label-background: #ffffff}:host(.l-md-input-outline) .l-md-input__inner{border-width:1px;border-radius:4px;padding:0 10px}:host(.l-md-input-outline) .l-md-input__label{left:10px}:host(.l-md-input-outline) .l-md-input__inner:focus{border-width:2px}:host(.l-md-input-outline) .l-md-input__inner:focus+.l-md-input__label,:host(.l-md-input-outline.l-has-value) .l-md-input__label{padding-left:4px;padding-right:4px;background-color:#fff}";
6
6
  class v extends p {
7
7
  static baseName = "md-input";
8
8
  /** 是否显示四周边框 */
@@ -14,21 +14,21 @@ class v extends p {
14
14
  return ["disabled"];
15
15
  }
16
16
  connectedCallback() {
17
- m(this), this.loadStyleText(c), super.connectedCallback(), this.#e();
17
+ m(this), this.loadStyleText(h), super.connectedCallback(), this.#e();
18
18
  }
19
19
  disconnectedCallback() {
20
- super.disconnectedCallback(), this.#i();
20
+ super.disconnectedCallback(), this.#n();
21
21
  }
22
22
  render() {
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", {
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-${c(8)}`, n = r("input", {
25
25
  class: "l-md-input__inner",
26
26
  type: this.htmlType,
27
27
  name: this.getName(),
28
28
  inputmode: this.inputmode,
29
29
  id: e
30
30
  });
31
- if (t.appendChild(i), this.label) {
31
+ if (t.appendChild(n), 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
- #i() {
49
+ #n() {
50
50
  const t = l("input", this.root);
51
51
  t && d(t, "input", this.#t);
52
52
  }
53
53
  #t = (t) => {
54
- const i = t.target.value;
55
- this.setValue(i), s(i) ? u(this, "l-has-value") : n(this, "l-has-value");
54
+ const n = t.target.value;
55
+ this.setValue(n), s(n) ? u(this, "l-has-value") : i(this, "l-has-value");
56
56
  };
57
57
  }
58
58
  export {
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
  };
@@ -3,7 +3,7 @@ export default class Modal extends BaseComponent {
3
3
  #private;
4
4
  static baseName: string;
5
5
  /** 是否显示对话框 */
6
- open: boolean;
6
+ show: boolean;
7
7
  /** 关闭时销毁 Modal 里的子元素 */
8
8
  destroyOnClose: boolean;
9
9
  /** 点击蒙层是否允许关闭 */
@@ -1,11 +1,11 @@
1
1
  import x from "../base.js";
2
2
  import { parseAttrValue as c, initAttr as g } from "../utils/index.js";
3
3
  import { $one as i, transition as s, $$ as a, on as u, off as k, shouldEventNext as y } from "ph-utils/dom";
4
- const v = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex, 100)}.l-modal-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:calc(var(--l-modal-zindex, 100) + 1)}.l-modal{--l-modal-translate: translate3d(0, 80px, 0);background-color:#fff;border-radius:5px;width:var(--l-modal-width, 27%);margin:auto;box-shadow:0 0 8px #0000001a;position:relative;opacity:1;transform:var(--l-modal-translate) scaleZ(1);transition:opacity .3s,transform .3s}.l-modal-header{display:block;padding:10px;font-size:16px;border-bottom:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-modal-footer{padding:10px;border-top:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-modal-container{padding:var(--l-modal-container-padding, 15px 10px);font-size:14px}.l-btn-modal-close{--l-form-edit-height: auto;position:absolute}.l-modal-close1{right:5px;top:8px}.l-modal-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-modal-close2{right:-10px;top:-10px}.l-modal-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translateZ(0) scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:transparent;padding:20px 10px 5px;display:flex;justify-content:center}.l-modal--mobile .l-modal-container{--l-modal-container-padding: 5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{display:flex;justify-content:stretch;align-items:stretch;padding:0;text-align:center;height:50px;gap:0}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06))}.l-modal--middle{--l-modal-translate: translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate: translate3d(0, -100%, 0);top:100%;width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0}@media screen and (max-width: 768px){:host{--l-modal-width: 80%}}", C = ".l-mask{position:fixed;z-index:var(--l-mask-zindex, 100);inset:0;background-color:#0009;transition:opacity .3s;opacity:1}";
4
+ const v = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex, 100)}.l-modal-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:calc(var(--l-modal-zindex, 100) + 1)}.l-modal{--l-modal-translate: translate3d(0, 80px, 0);background-color:#fff;border-radius:5px;width:var(--l-modal-width, 27%);margin:auto;box-shadow:0 0 8px #0000001a;position:relative;opacity:1;transform:var(--l-modal-translate) scaleZ(1);transition:opacity .3s,transform .3s}.l-modal-header{display:block;padding:10px;font-size:16px;border-bottom:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-modal-footer{padding:10px;border-top:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-modal-container{padding:var(--l-modal-container-padding, 15px 10px);font-size:14px}.l-btn-modal-close{--l-form-control-height: auto;position:absolute}.l-modal-close1{right:5px;top:8px}.l-modal-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-modal-close2{right:-10px;top:-10px}.l-modal-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translateZ(0) scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:transparent;padding:20px 10px 5px;display:flex;justify-content:center}.l-modal--mobile .l-modal-container{--l-modal-container-padding: 5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{display:flex;justify-content:stretch;align-items:stretch;padding:0;text-align:center;height:50px;gap:0}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06))}.l-modal--middle{--l-modal-translate: translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate: translate3d(0, -100%, 0);top:100%;width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0}@media screen and (max-width: 768px){:host{--l-modal-width: 80%}}", w = ".l-mask{position:fixed;z-index:var(--l-mask-zindex, 100);inset:0;background-color:#0009;transition:opacity .3s;opacity:1}";
5
5
  class L extends x {
6
6
  static baseName = "modal";
7
7
  /** 是否显示对话框 */
8
- open = !1;
8
+ show = !1;
9
9
  /** 关闭时销毁 Modal 里的子元素 */
10
10
  destroyOnClose = !1;
11
11
  /** 点击蒙层是否允许关闭 */
@@ -36,12 +36,12 @@ class L extends x {
36
36
  zIndex;
37
37
  #t = "";
38
38
  static get observedAttributes() {
39
- return ["open", "width", "confirm-loading"];
39
+ return ["show", "width", "confirm-loading"];
40
40
  }
41
41
  attributeChangedCallback(t, e, o) {
42
42
  if (this.rendered) {
43
- if (t === "open")
44
- this.open = c(o, !1), this.open ? this.#e() : this.#i();
43
+ if (t === "show")
44
+ this.show = c(o, !1), this.show ? this.#e() : this.#i();
45
45
  else if (t === "width")
46
46
  this.width = c(o, void 0), this.#o();
47
47
  else if (t === "confirm-loading") {
@@ -52,10 +52,10 @@ class L extends x {
52
52
  }
53
53
  }
54
54
  connectedCallback() {
55
- g(this), this.loadStyleText([C, v]), super.connectedCallback(), this.#o(), this.zIndex && this.style.setProperty("--l-modal-zindex", this.zIndex);
55
+ g(this), this.loadStyleText([w, v]), super.connectedCallback(), this.#o(), this.zIndex && this.style.setProperty("--l-modal-zindex", this.zIndex);
56
56
  }
57
57
  render() {
58
- this.open && this.#e();
58
+ this.show && this.#e();
59
59
  }
60
60
  #o() {
61
61
  this.width ? this.style.setProperty("--l-modal-width", this.width) : this.style.removeProperty("--l-modal-width");