litos-ui 0.12.1 → 0.12.2

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 (54) hide show
  1. package/lib/base.d.ts +1 -14
  2. package/lib/base.js +5 -22
  3. package/lib/button/index.d.ts +1 -3
  4. package/lib/button/index.js +19 -18
  5. package/lib/form/form_inner.d.ts +2 -7
  6. package/lib/form/form_inner.js +20 -26
  7. package/lib/form/form_item.d.ts +2 -0
  8. package/lib/form/form_item.js +9 -5
  9. package/lib/form/index.d.ts +2 -0
  10. package/lib/form/index.js +25 -23
  11. package/lib/icon/base.d.ts +1 -0
  12. package/lib/icon/base.js +17 -15
  13. package/lib/index.d.ts +2 -26
  14. package/lib/index.js +83 -106
  15. package/lib/input/index.d.ts +2 -1
  16. package/lib/input/index.js +8 -5
  17. package/lib/list/index.d.ts +1 -1
  18. package/lib/litos-ui.css +1 -1
  19. package/lib/litos-ui.min.js +1 -0
  20. package/lib/popover/index.d.ts +4 -1
  21. package/lib/popover/index.js +12 -6
  22. package/lib/radio/index.js +3 -3
  23. package/lib/select_ori/index.d.ts +2 -0
  24. package/lib/select_ori/index.js +15 -11
  25. package/lib/switch/index.d.ts +1 -0
  26. package/lib/switch/index.js +13 -8
  27. package/lib/tabbar/index.d.ts +1 -0
  28. package/lib/tabbar/index.js +63 -55
  29. package/lib/theme/index.d.ts +2 -1
  30. package/lib/theme/index.js +12 -9
  31. package/lib/utils/index.d.ts +5 -0
  32. package/lib/utils/index.js +52 -45
  33. package/lib/utils/transition.js +2 -3
  34. package/package.json +1 -1
  35. package/lib/date_picker/index.d.ts +0 -22
  36. package/lib/date_picker/index.js +0 -99
  37. package/lib/dialog/dialog_container.d.ts +0 -28
  38. package/lib/dialog/dialog_container.js +0 -100
  39. package/lib/dialog/index.d.ts +0 -30
  40. package/lib/dialog/index.js +0 -86
  41. package/lib/icon/close.d.ts +0 -5
  42. package/lib/icon/close.js +0 -10
  43. package/lib/loading/index.d.ts +0 -45
  44. package/lib/loading/index.js +0 -141
  45. package/lib/menu/base.js +0 -1
  46. package/lib/menu/index.d.ts +0 -29
  47. package/lib/menu/index.js +0 -90
  48. package/lib/menu/menu_item.d.ts +0 -6
  49. package/lib/menu/menu_item.js +0 -21
  50. package/lib/menu/sub_menu.d.ts +0 -13
  51. package/lib/menu/sub_menu.js +0 -64
  52. package/lib/modal/index.d.ts +0 -40
  53. package/lib/modal/index.js +0 -153
  54. package/lib/modal/modal_box.js +0 -95
package/lib/base.d.ts CHANGED
@@ -7,7 +7,7 @@ export default class BaseComponent extends HTMLElement {
7
7
  * 返回一个数组,表示观察的属性列表
8
8
  */
9
9
  static get observedAttributes(): string[] | undefined | null;
10
- attributeChangedCallback(_name: string, _oldValue: string, _newValue: string): void;
10
+ attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
11
11
  get shadow(): ShadowRoot;
12
12
  get root(): ShadowRoot | HTMLElement;
13
13
  createStyle(text: string): void;
@@ -31,17 +31,4 @@ export default class BaseComponent extends HTMLElement {
31
31
  connectedCallback(): void;
32
32
  disconnectedCallback(): void;
33
33
  render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
34
- /**
35
- * 初始化事件
36
- * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
37
- */
38
- initEvents(): void;
39
- afterInit(): void;
40
- /** 移除事件 */
41
- /**
42
- * 移除事件
43
- * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
44
- */
45
- removeEvents(): void;
46
- beforeDestroy(): void;
47
34
  }
package/lib/base.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getAttr as r } from "ph-utils/dom";
2
- class i extends HTMLElement {
2
+ class a extends HTMLElement {
3
3
  static baseName = "base-component";
4
4
  /** 组件是否渲染完成, 是否已经调用 connectedCallback */
5
5
  rendered = !1;
@@ -40,35 +40,18 @@ class i extends HTMLElement {
40
40
  if (t)
41
41
  if (typeof t == "string") {
42
42
  let e = document.createElement("div");
43
- e.innerHTML = t, this.root.append(...e.childNodes), e = void 0;
43
+ e.innerHTML = t, this.root.append(...e.children), e = void 0;
44
44
  } else t.length ? this.root.append(...t) : this.root.append(t);
45
45
  }
46
46
  connectedCallback() {
47
- this.appendToRoot(this.render()), this.initEvents(), this.afterInit(), this.rendered = !0;
47
+ this.appendToRoot(this.render()), this.rendered = !0;
48
48
  }
49
49
  disconnectedCallback() {
50
- this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
50
+ this.root.innerHTML = "", this.rendered = !1;
51
51
  }
52
52
  render() {
53
53
  }
54
- /**
55
- * 初始化事件
56
- * @deprecated 自0.12.0起弃用,使用 afterInit() 替代
57
- */
58
- initEvents() {
59
- }
60
- afterInit() {
61
- }
62
- /** 移除事件 */
63
- /**
64
- * 移除事件
65
- * @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
66
- */
67
- removeEvents() {
68
- }
69
- beforeDestroy() {
70
- }
71
54
  }
72
55
  export {
73
- i as default
56
+ a as default
74
57
  };
@@ -2,9 +2,7 @@ import BaseComponent from "../base";
2
2
  export default class Button extends BaseComponent {
3
3
  static baseName: string;
4
4
  htmlType: "submit" | "reset" | "button";
5
- /** 加载中文本 */
6
- loadingText: string;
7
- disabled: boolean;
5
+ constructor();
8
6
  static get observedAttributes(): string[];
9
7
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
10
8
  connectedCallback(): void;
@@ -1,15 +1,15 @@
1
- import { parseAttrValue as b, initAttr as s } from "../utils/index.js";
2
- import c from "../base.js";
3
- import { $one as h, addClass as g, removeClass as f, on as p, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
4
- import { adjust as i } from "ph-utils/color";
1
+ import { initAttr as s, parseAttrValue as c } from "../utils/index.js";
2
+ import d from "../base.js";
3
+ import { $one as h, addClass as g, removeClass as p, on as v, off as f, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
4
+ import { adjust as b } from "ph-utils/color";
5
5
  import { a as x } from "../animation-DttknHkX.js";
6
- const y = ":host{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-block;width:auto;height:var(--l-form-edit-height, 32px);font-size:0}:host([block]){width:100%}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:100%;border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab);--l-btn-disabled-border-color: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-background: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-color: #ffffff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
7
- class M extends c {
6
+ const y = ":host{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-block;width:auto}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:var(--l-form-edit-height, 32px);border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab)}.l-btn:not(.l-btn-loading):disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;height:auto;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn-block{width:100%}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
7
+ class w extends d {
8
8
  static baseName = "button";
9
9
  htmlType = "button";
10
- /** 加载中文本 */
11
- loadingText = "";
12
- disabled = !1;
10
+ constructor() {
11
+ super(), s(this);
12
+ }
13
13
  // 初始化属性观察器
14
14
  static get observedAttributes() {
15
15
  return ["loading", "color", "disabled"];
@@ -19,39 +19,40 @@ class M extends c {
19
19
  const l = h(".l-btn", this.root);
20
20
  if (l)
21
21
  if (r === "loading")
22
- b(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (f(l, "l-btn-loading"), l.disabled = this.disabled, l.innerHTML = "<slot></slot>");
22
+ c(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (p(l, "l-btn-loading"), l.disabled = this.getAttr("disabled", !1), l.innerHTML = "<slot></slot>");
23
23
  else if (r === "color") {
24
24
  const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
25
25
  l.style.cssText = this.applyColor(o, e, n);
26
- } else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
26
+ } else r === "disabled" && (l.disabled = this.getAttr("disabled", !1));
27
27
  }
28
28
  connectedCallback() {
29
- s(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
29
+ this.loadStyleText([y, x]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
30
30
  }
31
31
  disconnectedCallback() {
32
- super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
32
+ super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && f(this, "click", this._handleClick);
33
33
  }
34
34
  render() {
35
- const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), d = [
35
+ const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), i = [
36
36
  "l-btn",
37
37
  `l-btn-${r}`,
38
+ this.getAttr("block", !1) ? "l-btn-block" : "",
38
39
  l === "round" ? "l-btn-round" : "",
39
40
  l === "circle" ? "l-btn-circle" : "",
40
41
  n ? "l-btn-ghost" : "",
41
42
  e ? "l-btn-text" : "",
42
43
  o ? "l-btn-loading" : ""
43
44
  ];
44
- t.className = u(d), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
45
+ t.className = u(i), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
45
46
  const a = this.applyColor(this.getAttr("color"), e, n);
46
47
  a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
47
48
  }
48
49
  loadingBody() {
49
50
  const r = this.getAttr("loading-text", ""), t = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
50
- return r ? t.push(`<span>${r}</span>`) : t.push("<slot></slot>"), t.join("");
51
+ return r === "" ? t.push("<slot></slot>") : t.push(`<span>${r}</span>`), t.join("");
51
52
  }
52
53
  applyColor(r, t = !1, o = !1) {
53
54
  if (!r) return "";
54
- const l = i(r, 1, !0), e = i(r, 3, !1);
55
+ const l = b(r, 1, !0), e = b(r, 3, !1);
55
56
  return m({
56
57
  "--l-btn-border-color": t ? "transparent" : r,
57
58
  "--l-btn-text-color": o || t ? r : "#ffffff",
@@ -86,5 +87,5 @@ class M extends c {
86
87
  }
87
88
  }
88
89
  export {
89
- M as default
90
+ w as default
90
91
  };
@@ -19,20 +19,15 @@ export default class FormInner extends BaseComponent {
19
19
  getValue(): any;
20
20
  static get observedAttributes(): string[];
21
21
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
22
- protected attributeChange(_name: string, _oldValue: string, _newValue: string): void;
22
+ protected attributeChange(name: string, oldValue: string, newValue: string): void;
23
23
  connectedCallback(): void;
24
24
  disconnectedCallback(): void;
25
25
  isDisabled(): any;
26
26
  getName(): any;
27
27
  private _getForm;
28
28
  private _formAttributeChanged;
29
- /** */
30
- /**
31
- * disable 属性改变时回调
32
- * @deprecated 使用 disabledChange 代替
33
- */
29
+ /** disable 属性改变时回调 */
34
30
  protected _changeDisabled(): void;
35
- protected disabledChange(): void;
36
31
  protected pushValueChange(): void;
37
32
  private _resetFieldValue;
38
33
  reset(): void;
@@ -1,7 +1,7 @@
1
- import n from "../base.js";
1
+ import d from "../base.js";
2
2
  import { parseAttrValue as u } from "../utils/index.js";
3
- import { add as l, remove as d, emit as o } from "../utils/event.js";
4
- class A extends n {
3
+ import { add as l, remove as n, emit as o } from "../utils/event.js";
4
+ class b extends d {
5
5
  disabled = !1;
6
6
  name = void 0;
7
7
  formAttrs = {};
@@ -32,15 +32,15 @@ class A extends n {
32
32
  static get observedAttributes() {
33
33
  return ["disabled"];
34
34
  }
35
- attributeChangedCallback(t, e, s) {
35
+ attributeChangedCallback(t, e, r) {
36
36
  if (this.rendered)
37
37
  if (t === "disabled") {
38
- const i = u(s, !1, t);
39
- i !== this.disabled && (this._changeDisabled(), this.disabledChange(), this.disabled = i);
38
+ const i = u(r, !1, t);
39
+ i !== this.disabled && (this._changeDisabled(), this.disabled = i);
40
40
  } else
41
- this.attributeChange(t, e, s);
41
+ this.attributeChange(t, e, r);
42
42
  }
43
- attributeChange(t, e, s) {
43
+ attributeChange(t, e, r) {
44
44
  }
45
45
  connectedCallback() {
46
46
  const t = this._getForm();
@@ -51,7 +51,7 @@ class A extends n {
51
51
  ), super.connectedCallback();
52
52
  }
53
53
  disconnectedCallback() {
54
- this.formAttrs.id && (d(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), d(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && d(
54
+ this.formAttrs.id && (n(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), n(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && n(
55
55
  this.formItemAttrs.id,
56
56
  "attributeChanged",
57
57
  this._formAttributeChanged
@@ -64,13 +64,13 @@ class A extends n {
64
64
  return this.name ? this.name : this.formItemAttrs.name;
65
65
  }
66
66
  _getForm() {
67
- let t = this.parentElement, e = {}, s = {};
67
+ let t = this.parentElement, e = {}, r = {};
68
68
  for (; t != null; ) {
69
69
  const i = t.tagName;
70
70
  if (i === "L-FORM") {
71
71
  const a = t.sharedAttrs;
72
- for (let r = 0; r < a.length; r++) {
73
- const h = a[r];
72
+ for (let s = 0; s < a.length; s++) {
73
+ const h = a[s];
74
74
  e[h] = t[h];
75
75
  }
76
76
  break;
@@ -78,30 +78,24 @@ class A extends n {
78
78
  if (i === "BODY") break;
79
79
  if (i === "L-FORM-ITEM") {
80
80
  const a = t.sharedAttrs;
81
- for (let r = 0; r < a.length; r++) {
82
- const h = a[r];
83
- s[h] = t[h];
81
+ for (let s = 0; s < a.length; s++) {
82
+ const h = a[s];
83
+ r[h] = t[h];
84
84
  }
85
85
  }
86
86
  t = t.parentElement;
87
87
  }
88
88
  return t = null, {
89
89
  formAttr: e,
90
- formItemAttr: s
90
+ formItemAttr: r
91
91
  };
92
92
  }
93
- _formAttributeChanged = (t, e, s) => {
94
- s === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && (this._changeDisabled(), this.disabledChange());
93
+ _formAttributeChanged = (t, e, r) => {
94
+ r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this._changeDisabled();
95
95
  };
96
- /** */
97
- /**
98
- * disable 属性改变时回调
99
- * @deprecated 使用 disabledChange 代替
100
- */
96
+ /** disable 属性改变时回调 */
101
97
  _changeDisabled() {
102
98
  }
103
- disabledChange() {
104
- }
105
99
  pushValueChange() {
106
100
  const t = this.getName();
107
101
  this.formAttrs.id && t && o(
@@ -120,5 +114,5 @@ class A extends n {
120
114
  }
121
115
  }
122
116
  export {
123
- A as default
117
+ b as default
124
118
  };
@@ -9,6 +9,7 @@ export default class FormItem extends BaseComponent {
9
9
  error?: string;
10
10
  /** 标签文本 */
11
11
  label?: string;
12
+ id: string;
12
13
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
13
14
  verify?: string;
14
15
  /** 验证失败错误信息 */
@@ -19,6 +20,7 @@ export default class FormItem extends BaseComponent {
19
20
  innerBlock: boolean;
20
21
  labelPosition?: "left" | "right" | "top";
21
22
  private formId?;
23
+ constructor();
22
24
  static get observedAttributes(): string[];
23
25
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
24
26
  connectedCallback(): void;
@@ -1,5 +1,5 @@
1
- import { formatClass as a, $one as i, addClass as m, removeClass as n } from "ph-utils/dom";
2
- import { parseAttrValue as d, initAttr as f } from "../utils/index.js";
1
+ import { formatClass as a, $one as i, addClass as n, removeClass as m } from "ph-utils/dom";
2
+ import { initAttr as d, parseAttrValue as f } from "../utils/index.js";
3
3
  import h from "../base.js";
4
4
  import { emit as o, add as c, clear as p, remove as b } from "../utils/event.js";
5
5
  import { random as s } from "ph-utils";
@@ -13,6 +13,7 @@ class $ extends h {
13
13
  error;
14
14
  /** 标签文本 */
15
15
  label;
16
+ id;
16
17
  /** 内置验证规则: required - 必填, same:password - 一般用于验证确认密码和密码, phone - 验证电话号码 */
17
18
  verify;
18
19
  /** 验证失败错误信息 */
@@ -23,6 +24,9 @@ class $ extends h {
23
24
  innerBlock = !1;
24
25
  labelPosition = "right";
25
26
  formId;
27
+ constructor() {
28
+ super(), d(this), this.id == null && (this.id = `l-fi${s(3)}-${s(6)}`);
29
+ }
26
30
  static get observedAttributes() {
27
31
  return ["error", "label", "disabled"];
28
32
  }
@@ -32,12 +36,12 @@ class $ extends h {
32
36
  else if (e === "label")
33
37
  this.label = r, this._updateLabel();
34
38
  else if (e === "disabled") {
35
- const l = d(r, !1, e);
39
+ const l = f(r, !1, e);
36
40
  l !== this.disabled && (o(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
37
41
  }
38
42
  }
39
43
  connectedCallback() {
40
- if (f(this), this.id == null && (this.id = `l-fi${s(3)}-${s(6)}`), this.loadStyleText([u]), super.connectedCallback(), this.formId = this._getFormId(), this.name && this.formId) {
44
+ if (super.connectedCallback(), this.loadStyleText([u]), this.formId = this._getFormId(), this.name && this.formId) {
41
45
  let e = this.verify?.split("|") || [];
42
46
  this.pattern && e.push(new RegExp(this.pattern));
43
47
  const t = {
@@ -87,7 +91,7 @@ class $ extends h {
87
91
  r && r.appendChild(e);
88
92
  }
89
93
  const t = i(".l-form-item", this.root);
90
- t && (this.error ? m(t, "is-error") : n(t, "is-error"));
94
+ t && (this.error ? n(t, "is-error") : m(t, "is-error"));
91
95
  }
92
96
  _updateLabel() {
93
97
  if (!this.rendered) return;
@@ -7,12 +7,14 @@ export default class Form extends BaseComponent {
7
7
  inline: boolean;
8
8
  labelPosition?: "left" | "right" | "top";
9
9
  labelWidth?: string;
10
+ id: string;
10
11
  disabled: boolean;
11
12
  sharedAttrs: string[];
12
13
  validator: Validator;
13
14
  innerBlock: boolean;
14
15
  novalidate: boolean;
15
16
  private _data?;
17
+ private emit;
16
18
  constructor();
17
19
  static get observedAttributes(): string[];
18
20
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
package/lib/form/index.js CHANGED
@@ -1,43 +1,45 @@
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
- import { parseAttrValue as c, initAttr as u } from "../utils/index.js";
3
+ import { initAttr as c, parseAttrValue 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";
6
- import b from "ph-utils/validator";
7
- const p = ":host{display:block}.l-form{display:grid;grid-template-columns:var(--l-form-label-width, auto) 1fr;row-gap:20px}.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}";
5
+ import { emit as l, add as h, clear as v } from "../utils/event.js";
6
+ import p from "ph-utils/validator";
7
+ const b = ":host{display:block}.l-form{display:grid;grid-template-columns:var(--l-form-label-width, auto) 1fr;row-gap:20px}.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 {
9
9
  static baseName = "form";
10
10
  /** 是否行内表单 */
11
11
  inline = !1;
12
12
  labelPosition = "right";
13
13
  labelWidth;
14
+ id;
14
15
  disabled = !1;
15
16
  sharedAttrs = ["disabled", "id", "innerBlock"];
16
17
  validator;
17
18
  innerBlock = !1;
18
19
  novalidate = !1;
19
20
  _data;
21
+ emit;
20
22
  constructor() {
21
- super(), this.validator = new b([]);
23
+ super(), c(this), this.id == null && (this.id = `l-f${d(3)}-${d(6)}`), this.validator = new p([]), this.emit = new CustomEvent("submit");
22
24
  }
23
25
  static get observedAttributes() {
24
26
  return ["disabled", "label-position"];
25
27
  }
26
- attributeChangedCallback(t, e, i) {
28
+ attributeChangedCallback(t, e, a) {
27
29
  if (t === "disabled") {
28
- const a = c(i, !1, t);
29
- a !== this.disabled && (l(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
30
+ const i = u(a, !1, t);
31
+ i !== this.disabled && (l(this.id, "attributeChanged", t, i, this.id), this.disabled = i);
30
32
  } else if (t === "label-position") {
31
- const a = h("form", this.root);
32
- a && (a.className = o([
33
+ const i = n("form", this.root);
34
+ i && (i.className = o([
33
35
  "l-form",
34
36
  this.inline ? "l-form-inline" : void 0,
35
- `l-form--${i}`
37
+ `l-form--${a}`
36
38
  ]));
37
39
  }
38
40
  }
39
41
  connectedCallback() {
40
- u(this), this.id == null && (this.id = `l-f${d(3)}-${d(6)}`), this.loadStyleText([p]), super.connectedCallback(), n(this.id, "ruleChange", this.ruleChange), n(this.id, "valueChange", this._valueChange);
42
+ this.loadStyleText([b]), super.connectedCallback(), h(this.id, "ruleChange", this.ruleChange), h(this.id, "valueChange", this._valueChange);
41
43
  }
42
44
  disconnectedCallback() {
43
45
  v(this.id), this.validator = void 0;
@@ -55,10 +57,10 @@ class $ extends m {
55
57
  ruleChange = (t) => {
56
58
  this.validator.addSchema(t);
57
59
  };
58
- _valueChange = (t, e, i = !0) => {
60
+ _valueChange = (t, e, a = !0) => {
59
61
  this._data == null && (this._data = {});
60
- const a = Object.hasOwn(this._data, t);
61
- this._data[t] = e, !this.novalidate && a && i && this.validator.validateKey(t, e, this._data).then(() => {
62
+ const i = Object.hasOwn(this._data, t);
63
+ this._data[t] = e, !this.novalidate && i && a && this.validator.validateKey(t, e, this._data).then(() => {
62
64
  l(this.id, "validateChange", !0, t);
63
65
  }).catch((s) => {
64
66
  l(this.id, "validateChange", s.detail, t);
@@ -68,17 +70,17 @@ class $ extends m {
68
70
  const e = [];
69
71
  if (this._data != null) {
70
72
  if (Array.isArray(t))
71
- for (let i = 0, a = t.length; i < a; i++) {
72
- const s = t[i];
73
+ for (let a = 0, i = t.length; a < i; a++) {
74
+ const s = t[a];
73
75
  e.push(this.validator.validateKey(s, this._data[s], this._data));
74
76
  }
75
77
  else
76
78
  e.push(
77
79
  this.validator.validateKey(t, this._data[t], this._data)
78
80
  );
79
- Promise.allSettled(e).then((i) => {
80
- for (let a = 0, s = i.length; a < s; a++) {
81
- const r = i[a];
81
+ Promise.allSettled(e).then((a) => {
82
+ for (let i = 0, s = a.length; i < s; i++) {
83
+ const r = a[i];
82
84
  r.status === "rejected" ? l(
83
85
  this.id,
84
86
  "validateChange",
@@ -96,8 +98,8 @@ class $ extends m {
96
98
  this.clearValidate(), l(this.id, "reset");
97
99
  }
98
100
  submit() {
99
- this.novalidate ? this.dispatchEvent(new CustomEvent("submit")) : this.validate().then((t) => {
100
- t && this.dispatchEvent(new CustomEvent("submit"));
101
+ this.novalidate ? this.dispatchEvent(this.emit) : this.validate().then((t) => {
102
+ t && this.dispatchEvent(this.emit);
101
103
  });
102
104
  }
103
105
  /**
@@ -3,6 +3,7 @@ export default class BaseIcon extends BaseComponent {
3
3
  static baseName: string;
4
4
  useLink: boolean;
5
5
  viewBox: string;
6
+ constructor();
6
7
  connectedCallback(): void;
7
8
  render(): void;
8
9
  renderChildren(): string;
package/lib/icon/base.js CHANGED
@@ -1,25 +1,27 @@
1
- import o from "../base.js";
2
- import { initAttr as c } from "../utils/index.js";
3
- const d = ":host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}";
4
- class f extends o {
1
+ import d from "../base.js";
2
+ const h = ":host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}";
3
+ class p extends d {
5
4
  static baseName = "base-icon";
6
- useLink = !1;
7
- viewBox = "0 0 1024 1024";
5
+ useLink;
6
+ viewBox;
7
+ constructor() {
8
+ super(), this.useLink = !1, this.viewBox = "0 0 1024 1024";
9
+ }
8
10
  connectedCallback() {
9
- c(this), this.loadStyleText([d]), this.render(), this.rendered = !0;
11
+ this.loadStyleText([h]), this.render(), this.rendered = !0;
10
12
  }
11
13
  render() {
12
- const e = this.createEl("svg");
13
- e.classList.add("l-icon"), this.useLink || e.setAttribute("viewBox", this.viewBox);
14
+ const e = this.createEl("svg"), r = this.getAttr("useLink", this.useLink), l = this.getAttr("viewBox", this.viewBox);
15
+ e.classList.add("l-icon"), r || e.setAttribute("viewBox", l);
14
16
  const t = this.renderChildren();
15
17
  if (typeof t == "string")
16
18
  if (t === "") {
17
- const n = this.children, s = [];
18
- for (let i = 0, r = n.length; i < r; i++) {
19
- const l = n[i];
20
- s.push(l.outerHTML);
19
+ const s = this.children, n = [];
20
+ for (let i = 0, o = s.length; i < o; i++) {
21
+ const c = s[i];
22
+ n.push(c.outerHTML);
21
23
  }
22
- e.innerHTML = s.join("");
24
+ e.innerHTML = n.join("");
23
25
  } else
24
26
  e.innerHTML = t;
25
27
  else
@@ -34,5 +36,5 @@ class f extends o {
34
36
  }
35
37
  }
36
38
  export {
37
- f as default
39
+ p as default
38
40
  };
package/lib/index.d.ts CHANGED
@@ -4,10 +4,6 @@ export { default as BaseComponent } from "./base";
4
4
  export { default as Message } from "./message";
5
5
  export { default as Popover } from "./popover";
6
6
  export { default as Popconfirm } from "./popconfirm";
7
- export { default as Dialog } from "./dialog";
8
- export { default as DialogContainer } from "./dialog/dialog_container";
9
- export { default as Loading } from "./loading";
10
- export { default as Modal } from "./modal";
11
7
  export { default as BaseIcon } from "./icon/base";
12
8
  export { default as ArrowDownIcon } from "./icon/arrow_down";
13
9
  export { default as ArrowLeftIcon } from "./icon/arrow_left";
@@ -25,10 +21,6 @@ export { default as RefreshLeftIcon } from "./icon/refresh_left";
25
21
  export { default as RefreshRightIcon } from "./icon/refresh_right";
26
22
  export { default as SortIcon } from "./icon/sort";
27
23
  export { default as ThemeDefaultIcon } from "./icon/theme_default";
28
- export { default as CloseIcon } from "./icon/close";
29
- export { default as InfoIcon } from "./icon/info";
30
- export { default as SuccessIcon } from "./icon/success";
31
- export { default as WarnIcon } from "./icon/warn";
32
24
  export { default as Form } from "./form";
33
25
  export { default as FormItem } from "./form/form_item";
34
26
  export { default as Radio } from "./radio";
@@ -37,27 +29,19 @@ export { default as Button } from "./button";
37
29
  export { default as Input } from "./input";
38
30
  export { default as SelectOri } from "./select_ori";
39
31
  export { default as Switch } from "./switch";
40
- export { default as MdInput } from "./md_input";
41
32
  export { default as List } from "./list";
42
33
  export { default as Polygon } from "./polygon";
43
34
  export { default as ColorPicker } from "./color_picker";
44
35
  export { default as Tabbar } from "./tabbar";
45
36
  export { default as Theme } from "./theme";
46
37
  export { default as ThemeColor } from "./theme/theme_color";
47
- export { default as DatePicker } from "./date_picker";
48
- export { default as Menu } from "./menu";
49
- export { default as MenuItem } from "./menu/menu_item";
50
- export { default as SubMenu } from "./menu/sub_menu";
38
+ export { default as MdInput } from "./md_input";
51
39
 
52
40
  declare global {
53
41
  interface HTMLElementTagNameMap {
54
42
  "l-base-component": import("./base").default
55
43
  "l-popover": import("./popover").default
56
44
  "l-popconfirm": import("./popconfirm").default
57
- "l-dialog": import("./dialog").default
58
- "l-dialog-container": import("./dialog/dialog_container").default
59
- "l-loading": import("./loading").default
60
- "l-modal": import("./modal").default
61
45
  "l-base-icon": import("./icon/base").default
62
46
  "l-arrow-down-icon": import("./icon/arrow_down").default
63
47
  "l-arrow-left-icon": import("./icon/arrow_left").default
@@ -75,10 +59,6 @@ declare global {
75
59
  "l-refresh-right-icon": import("./icon/refresh_right").default
76
60
  "l-sort-icon": import("./icon/sort").default
77
61
  "l-theme-default-icon": import("./icon/theme_default").default
78
- "l-close-icon": import("./icon/close").default
79
- "l-info-icon": import("./icon/info").default
80
- "l-success-icon": import("./icon/success").default
81
- "l-warn-icon": import("./icon/warn").default
82
62
  "l-form": import("./form").default
83
63
  "l-form-item": import("./form/form_item").default
84
64
  "l-radio": import("./radio").default
@@ -87,16 +67,12 @@ declare global {
87
67
  "l-input": import("./input").default
88
68
  "l-select-ori": import("./select_ori").default
89
69
  "l-switch": import("./switch").default
90
- "l-md-input": import("./md_input").default
91
70
  "l-list": import("./list").default
92
71
  "l-polygon": import("./polygon").default
93
72
  "l-color-picker": import("./color_picker").default
94
73
  "l-tabbar": import("./tabbar").default
95
74
  "l-theme": import("./theme").default
96
75
  "l-theme-color": import("./theme/theme_color").default
97
- "l-date-picker": import("./date_picker").default
98
- "l-menu": import("./menu").default
99
- "l-menu-item": import("./menu/menu_item").default
100
- "l-sub-menu": import("./menu/sub_menu").default
76
+ "l-md-input": import("./md_input").default
101
77
  }
102
78
  }