litos-ui 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,10 @@ export default class Button extends BaseComponent {
4
4
  htmlType: "submit" | "reset" | "button";
5
5
  /** 加载中文本 */
6
6
  loadingText: string;
7
- disabled: boolean;
7
+ _disabled: boolean;
8
+ get disabled(): boolean;
9
+ set disabled(value: boolean);
10
+ setDisabled(value: boolean): void;
8
11
  static get observedAttributes(): string[];
9
12
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
10
13
  connectedCallback(): void;
@@ -1,32 +1,47 @@
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 { parseAttrValue as b, initAttr as c } from "../utils/index.js";
2
+ import h from "../base.js";
3
+ import { $one as i, 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 s } from "ph-utils/color";
5
5
  import { a as x } from "../animation-DttknHkX.js";
6
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 {
7
+ class L extends h {
8
8
  static baseName = "button";
9
9
  htmlType = "button";
10
10
  /** 加载中文本 */
11
11
  loadingText = "";
12
- disabled = !1;
12
+ _disabled = !1;
13
+ get disabled() {
14
+ return this._disabled;
15
+ }
16
+ set disabled(r) {
17
+ this.setDisabled(r);
18
+ }
19
+ setDisabled(r) {
20
+ this._disabled = r;
21
+ const t = i(".l-btn", this.root);
22
+ t && (t.disabled = r);
23
+ }
13
24
  // 初始化属性观察器
14
25
  static get observedAttributes() {
15
26
  return ["loading", "color", "disabled"];
16
27
  }
17
28
  // 当属性发生变化时调用的回调函数
18
29
  attributeChangedCallback(r, t, o) {
19
- const l = h(".l-btn", this.root);
20
- if (l)
30
+ const l = i(".l-btn", this.root);
31
+ if (l) {
21
32
  if (r === "loading")
22
33
  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>");
23
34
  else if (r === "color") {
24
35
  const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
25
36
  l.style.cssText = this.applyColor(o, e, n);
26
- } else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
37
+ } else if (r === "disabled") {
38
+ const e = b(o, !1, "disabled");
39
+ this.setDisabled(e);
40
+ }
41
+ }
27
42
  }
28
43
  connectedCallback() {
29
- s(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
44
+ c(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
30
45
  }
31
46
  disconnectedCallback() {
32
47
  super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
@@ -41,7 +56,7 @@ class M extends c {
41
56
  e ? "l-btn-text" : "",
42
57
  o ? "l-btn-loading" : ""
43
58
  ];
44
- t.className = u(d), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
59
+ t.className = u(d), t.disabled = this.disabled || o, t.type = this.getAttr("html-type", "button");
45
60
  const a = this.applyColor(this.getAttr("color"), e, n);
46
61
  a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
47
62
  }
@@ -51,7 +66,7 @@ class M extends c {
51
66
  }
52
67
  applyColor(r, t = !1, o = !1) {
53
68
  if (!r) return "";
54
- const l = i(r, 1, !0), e = i(r, 3, !1);
69
+ const l = s(r, 1, !0), e = s(r, 3, !1);
55
70
  return m({
56
71
  "--l-btn-border-color": t ? "transparent" : r,
57
72
  "--l-btn-text-color": o || t ? r : "#ffffff",
@@ -86,5 +101,5 @@ class M extends c {
86
101
  }
87
102
  }
88
103
  export {
89
- M as default
104
+ L as default
90
105
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "litos-ui",
3
3
  "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.14.0",
4
+ "version": "0.14.1",
5
5
  "type": "module",
6
6
  "devDependencies": {
7
7
  "@eslint/js": "^9.25.0",