litos-ui 0.16.1 → 0.16.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.
@@ -78,7 +78,6 @@ class H extends h {
78
78
  }
79
79
  loadingBody() {
80
80
  const t = this.getAttr("loading-text", "加载中……"), r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
81
- console.log(t);
82
81
  return t ? r.push(`<span>${t}</span>`) : r.push("<slot></slot>"), r.join("");
83
82
  }
84
83
  applyColor(t, r = !1, o = !1) {
@@ -18,5 +18,6 @@ export default class Check extends FormInner {
18
18
  protected attributeChange(name: string, _oldValue: string, newValue: string): void;
19
19
  protected checkedChange(): void;
20
20
  protected disabledChange(): void;
21
+ emitChange(): void;
21
22
  _doChangeAction(): void;
22
23
  }
@@ -1,7 +1,7 @@
1
- import d from "../form/form_inner.js";
2
- import { initAttr as n, parseAttrValue as l } from "../utils/index.js";
3
- import { addClass as h, on as r, off as o, $$ as i, removeClass as k, $one as u, toggleClass as p } from "ph-utils/dom";
4
- class m extends d {
1
+ import n from "../form/form_inner.js";
2
+ import { initAttr as l, parseAttrValue as d } from "../utils/index.js";
3
+ import { addClass as h, on as r, off as o, $$ as s, removeClass as k, $one as u, toggleClass as C } from "ph-utils/dom";
4
+ class m extends n {
5
5
  /** 是否选中 */
6
6
  _checked = !1;
7
7
  label;
@@ -24,19 +24,19 @@ class m extends d {
24
24
  });
25
25
  }
26
26
  static get observedAttributes() {
27
- return ["disabled", "checked"];
27
+ return ["disabled", "checked", "value", "name"];
28
28
  }
29
29
  connectedCallback() {
30
- n(this), super.connectedCallback(), this.getChecked() && h(this, "is-checked"), this.isDisabled() && h(this, "is-disabled");
30
+ l(this), super.connectedCallback(), this.getChecked() && h(this, "is-checked"), this.isDisabled() && h(this, "is-disabled");
31
31
  }
32
32
  afterInit() {
33
- r(this, "click", this.#e);
33
+ r(this, "click", this.#e), console.log("inner value: " + this.value);
34
34
  }
35
35
  beforeDestroy() {
36
36
  o(this, "click", this.#e);
37
37
  }
38
38
  render() {
39
- const e = document.createDocumentFragment(), c = i("input", {
39
+ const e = document.createDocumentFragment(), c = s("input", {
40
40
  type: this._inputType,
41
41
  class: "l-check__input",
42
42
  name: this.getName(),
@@ -44,34 +44,44 @@ class m extends d {
44
44
  checked: this.getChecked()
45
45
  });
46
46
  if (this.isDisabled() && (c.disabled = !0), e.appendChild(c), !this.button) {
47
- const a = i("span", { class: "l-check__inner" });
47
+ const a = s("span", { class: "l-check__inner" });
48
48
  e.appendChild(a);
49
49
  }
50
- const t = i("label", {
50
+ const t = s("label", {
51
51
  class: "l-check__label",
52
52
  part: "label"
53
- }), s = i("slot", {
53
+ }), i = s("slot", {
54
54
  textContent: this.label
55
55
  });
56
- return t.appendChild(s), e.appendChild(t), e;
56
+ return t.appendChild(i), e.appendChild(t), e;
57
57
  }
58
58
  attributeChange(e, c, t) {
59
59
  if (e === "checked") {
60
- const s = l(t, !1, "checked");
61
- s !== this.getChecked() && this.setChecked(s);
60
+ const i = d(t, !1, "checked");
61
+ i !== this.getChecked() && this.setChecked(i);
62
62
  }
63
63
  }
64
64
  checkedChange() {
65
65
  this.getChecked() ? h(this, "is-checked") : k(this, "is-checked");
66
66
  const e = u("input", this.root);
67
- e && (e.checked = this._checked);
67
+ e && (e.checked = this.getChecked());
68
68
  }
69
69
  disabledChange() {
70
- p(this, "is-disabled");
70
+ C(this, "is-disabled");
71
71
  }
72
72
  #e = () => {
73
73
  this.isDisabled() || this._doChangeAction();
74
74
  };
75
+ emitChange() {
76
+ this.emit("change", {
77
+ detail: {
78
+ value: this.value,
79
+ name: this.getName(),
80
+ checked: this.getChecked()
81
+ },
82
+ composed: !0
83
+ });
84
+ }
75
85
  _doChangeAction() {
76
86
  }
77
87
  }
@@ -1,7 +1,7 @@
1
1
  import e from "./check.js";
2
- import { c as r } from "../check-C7YSuH60.js";
2
+ import { c as r } from "../check-D-KVLA1z.js";
3
3
  const o = '.l-check__inner:after{content:"";width:calc(var(--l-check-size) * .6);height:calc(var(--l-check-size) * .3);display:block;border:solid 1px transparent;border-right:none;border-top:none;transform:rotate(-45deg);transition:border-color .2s ease-in-out;margin-top:-3px}:host([indeterminate]) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host([indeterminate]) .l-check__inner:after{content:"";width:calc(var(--l-check-size) * .4);height:1px;display:block;border:1px solid #fff;border-right:none;border-top:none;border-left:none;transform:rotate(0);margin-top:0}:host(.is-checked) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner:after{border-color:#fff}:host(.is-disabled) .l-check__inner{background-color:var(--l-disabled-color, #e6e6e6);border-color:var(--l-disabled-color, #e6e6e6)}';
4
- class a extends e {
4
+ class i extends e {
5
5
  static baseName = "checkbox";
6
6
  constructor() {
7
7
  super(), this._inputType = "checkbox";
@@ -10,16 +10,9 @@ class a extends e {
10
10
  this.loadStyleText([r, o]), super.connectedCallback();
11
11
  }
12
12
  _doChangeAction() {
13
- this.getChecked() ? this.removeAttribute("checked") : this.setAttribute("checked", ""), this.emit("change", {
14
- detail: {
15
- value: this.value,
16
- name: this.getName(),
17
- checked: this.getChecked()
18
- },
19
- composed: !0
20
- });
13
+ this.getChecked() ? this.removeAttribute("checked") : this.setAttribute("checked", ""), this.emitChange();
21
14
  }
22
15
  }
23
16
  export {
24
- a as default
17
+ i as default
25
18
  };
@@ -1,9 +1,5 @@
1
1
  import CheckGroup from ".";
2
2
  export default class CheckboxGroup extends CheckGroup {
3
3
  static baseName: string;
4
- set value(value: string);
5
- get value(): string;
6
- afterInit(): void;
7
- protected updateChangedStatus(): void;
8
- valueChange(value: string): void;
4
+ setValue(value: string): void;
9
5
  }
@@ -1,33 +1,11 @@
1
- import a from "./index.js";
2
- import { $ as u, iterate as i } from "ph-utils/dom";
3
- class d extends a {
1
+ import c from "./index.js";
2
+ class a extends c {
4
3
  static baseName = "checkbox-group";
5
- set value(t) {
6
- super.setValue(t), this.rendered && this.updateChangedStatus();
7
- }
8
- get value() {
9
- return this._value;
10
- }
11
- afterInit() {
12
- super.afterInit(), this.updateChangedStatus();
13
- }
14
- updateChangedStatus() {
15
- if (this.value) {
16
- const e = this.value.split("&");
17
- this.checkedValues.push(...e.map((s) => decodeURIComponent(s)));
18
- } else
19
- this.checkedValues = [];
20
- const t = u("l-checkbox[value]", this);
21
- i(t, (e) => {
22
- let s = e.value;
23
- s || (s = e.getAttribute("value")), s && (this.checkedValues.includes(s) ? e.setAttribute("checked", "") : e.removeAttribute("checked"));
24
- });
25
- }
26
- valueChange(t) {
27
- let e = this.checkedValues.indexOf(t);
28
- e >= 0 ? this.checkedValues.splice(e, 1) : this.checkedValues.push(t), this.setValue(this.checkedValues.join("&"));
4
+ setValue(e) {
5
+ let s = this.checkedValues.indexOf(e);
6
+ s >= 0 ? this.checkedValues.splice(s, 1) : this.checkedValues.push(e), super.setValue(this.checkedValues.join("&"));
29
7
  }
30
8
  }
31
9
  export {
32
- d as default
10
+ a as default
33
11
  };
@@ -2,6 +2,9 @@ import FormInner from "../form/form_inner";
2
2
  export default class CheckGroup extends FormInner {
3
3
  #private;
4
4
  checkedValues: string[];
5
+ multiple: boolean;
6
+ set value(value: string);
7
+ get value(): string;
5
8
  constructor();
6
9
  static get observedAttributes(): string[];
7
10
  attributeChange(name: string, oldValue: any, newValue: any): void;
@@ -9,5 +12,8 @@ export default class CheckGroup extends FormInner {
9
12
  afterInit(): void;
10
13
  beforeDestroy(): void;
11
14
  render(): HTMLElement;
12
- valueChange(_value: string): void;
15
+ protected updatePartChild(value: string): void;
16
+ protected updateChecked(): void;
17
+ protected updateChangedStatus(): void;
18
+ protected updateChildren(): void;
13
19
  }
@@ -1,48 +1,75 @@
1
- import r from "../form/form_inner.js";
2
- import { on as o, off as l, $$ as c } from "ph-utils/dom";
3
- import { initAttr as i, parseAttrValue as h } from "../utils/index.js";
4
- import { isNumeric as n } from "ph-utils";
5
- const p = ":host{display:flex;align-items:center;gap:var(--l-check-gap, 0px)}";
6
- class v extends r {
1
+ import l from "../form/form_inner.js";
2
+ import { on as u, off as r, $$ as h, iterate as d } from "ph-utils/dom";
3
+ import { initAttr as c, parseAttrValue as o } from "../utils/index.js";
4
+ import { isNumeric as p } from "ph-utils";
5
+ const n = ":host{display:flex;align-items:center;gap:var(--l-check-gap, 0px)}";
6
+ class C extends l {
7
7
  checkedValues;
8
+ multiple;
9
+ set value(e) {
10
+ super.setValue(e), this.rendered && this.updateChangedStatus();
11
+ }
12
+ get value() {
13
+ return this._value;
14
+ }
8
15
  constructor() {
9
- super(!1), this.checkedValues = [];
16
+ super(!1), this.multiple = !0, this.checkedValues = [];
10
17
  }
11
18
  static get observedAttributes() {
12
19
  return ["gap", "value"];
13
20
  }
14
- attributeChange(e, g, a) {
15
- if (console.log(e), e === "gap") {
16
- const t = h(a, void 0);
17
- if (t) {
18
- const s = n(t) ? `${t}px` : t;
19
- this.style.setProperty("--l-check-gap", s);
21
+ attributeChange(e, t, s) {
22
+ if (e === "gap") {
23
+ const a = o(s, void 0);
24
+ if (a) {
25
+ const i = p(a) ? `${a}px` : a;
26
+ this.style.setProperty("--l-check-gap", i);
20
27
  } else
21
28
  this.style.removeProperty("--l-check-gap");
22
29
  return;
23
30
  }
24
31
  }
25
32
  connectedCallback() {
26
- i(this), this.loadStyleText([p]), super.connectedCallback();
33
+ c(this), this.loadStyleText([n]), super.connectedCallback();
27
34
  }
28
35
  afterInit() {
29
- o(this.root, "change", this.#e);
36
+ u(this.root, "change", this.#e), this.updateChangedStatus();
30
37
  }
31
38
  beforeDestroy() {
32
- l(this.root, "change", this.#e), this.checkedValues = [];
39
+ r(this.root, "change", this.#e), this.checkedValues = [];
33
40
  }
34
41
  render() {
35
- return c("slot");
42
+ return h("slot");
36
43
  }
37
44
  #e = (e) => {
38
- this.valueChange(e.detail.value), e.stopPropagation(), this.emit("change", {
45
+ e.stopPropagation(), this.updatePartChild(e.detail.value), this.setValue(e.detail.value), this.emit("change", {
39
46
  detail: { value: [...this.checkedValues] },
40
47
  composed: !0
41
48
  });
42
49
  };
43
- valueChange(e) {
50
+ updatePartChild(e) {
51
+ }
52
+ updateChecked() {
53
+ if (this.value)
54
+ if (this.multiple) {
55
+ const e = this.value.split("&");
56
+ this.checkedValues.push(...e.map((t) => decodeURIComponent(t)));
57
+ } else
58
+ this.checkedValues = [this.value];
59
+ else
60
+ this.checkedValues = [];
61
+ }
62
+ updateChangedStatus() {
63
+ this.updateChecked(), this.updateChildren();
64
+ }
65
+ updateChildren() {
66
+ const e = this.children;
67
+ d(e, (t) => {
68
+ let s = t.value || t.getAttribute("value");
69
+ s && (this.checkedValues.includes(s) ? t.setAttribute("checked", "") : t.removeAttribute("checked"));
70
+ });
44
71
  }
45
72
  }
46
73
  export {
47
- v as default
74
+ C as default
48
75
  };
@@ -1,23 +1,15 @@
1
1
  import e from "./check.js";
2
- import { c as o } from "../check-C7YSuH60.js";
3
- import { $one as c } from "ph-utils/dom";
4
- const t = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
5
- class n extends e {
2
+ import { c as r } from "../check-D-KVLA1z.js";
3
+ const c = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
4
+ class s extends e {
6
5
  static baseName = "radio";
7
6
  connectedCallback() {
8
- this.loadStyleText([o, t]), super.connectedCallback();
7
+ this.loadStyleText([r, c]), super.connectedCallback();
9
8
  }
10
9
  _doChangeAction() {
11
- c("input", this.root).checked || (this.setAttribute("checked", ""), this.emit("change", {
12
- detail: {
13
- value: this.value,
14
- name: this.getName(),
15
- checked: this.getChecked()
16
- },
17
- composed: !0
18
- }));
10
+ this.setAttribute("checked", "checked"), this.emitChange();
19
11
  }
20
12
  }
21
13
  export {
22
- n as default
14
+ s as default
23
15
  };
@@ -1,6 +1,7 @@
1
1
  import CheckGroup from ".";
2
2
  export default class RadioGroup extends CheckGroup {
3
3
  static baseName: string;
4
- afterInit(): void;
5
- valueChange(value: string): void;
4
+ constructor();
5
+ setValue(value: string): void;
6
+ protected updatePartChild(): void;
6
7
  }
@@ -1,22 +1,15 @@
1
- import a from "./index.js";
2
- import { $one as i } from "ph-utils/dom";
3
- class u extends a {
1
+ import t from "./index.js";
2
+ import { $one as s } from "ph-utils/dom";
3
+ class u extends t {
4
4
  static baseName = "radio-group";
5
- afterInit() {
6
- if (super.afterInit(), this.value) {
7
- const e = i(`l-radio[value="${this.value}"]`, this);
8
- e && e.setAttribute("checked", "");
9
- }
5
+ constructor() {
6
+ super(), this.multiple = !1;
10
7
  }
11
- valueChange(e) {
12
- if (this.value) {
13
- const t = i(
14
- `l-radio[value="${this.value}"]`,
15
- this
16
- );
17
- t && t.removeAttribute("checked");
18
- }
19
- this.value = e;
8
+ setValue(e) {
9
+ this.checkedValues = [e], super.setValue(e);
10
+ }
11
+ updatePartChild() {
12
+ s(`[value="${this.value}"]`, this)?.removeAttribute("checked");
20
13
  }
21
14
  }
22
15
  export {
@@ -0,0 +1,4 @@
1
+ const r = ":host{--l-check-size: 14px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;transition:color .3s,border-color .3s,background-color .3s}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size, 14px);height:var(--l-check-size, 14px);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:border-color .3s ease-in-out;position:relative;margin-right:5px;flex-shrink:0}.l-check__label{transition:color .3s;cursor:inherit;line-height:1}:host(.is-checked){color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color, #722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color, #e6e6e6)}:host([button]){height:var(--l-form-control-height, 32px);justify-content:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0;border-radius:inherit}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color, #722ed1);color:#fff;border-color:var(--l-primary-color, #722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color, #722ed1)}";
2
+ export {
3
+ r as c
4
+ };
@@ -49,24 +49,16 @@ class b extends n {
49
49
  }
50
50
  connectedCallback() {
51
51
  const t = this._getForm();
52
- this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (l(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), l(this.formAttrs.id, "reset", this._resetFieldValue), this._firstPushValue && this.pushValueChange()), this.formItemAttrs.id && l(
53
- this.formItemAttrs.id,
54
- "attributeChanged",
55
- this._formAttributeChanged
56
- ), super.connectedCallback();
52
+ this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (l(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), l(this.formAttrs.id, "reset", this._resetFieldValue), this._firstPushValue && this.pushValueChange()), this.formItemAttrs.id && l(this.formItemAttrs.id, "attributeChanged", this._formAttributeChanged), super.connectedCallback();
57
53
  }
58
54
  disconnectedCallback() {
59
- this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(
60
- this.formItemAttrs.id,
61
- "attributeChanged",
62
- this._formAttributeChanged
63
- ), super.disconnectedCallback();
55
+ this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(this.formItemAttrs.id, "attributeChanged", this._formAttributeChanged), super.disconnectedCallback();
64
56
  }
65
57
  isDisabled() {
66
58
  return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
67
59
  }
68
60
  getName() {
69
- return this.name ? this.name : this.formItemAttrs.name;
61
+ return this.name ? this.name : this.formItemAttrs.name || "";
70
62
  }
71
63
  _getForm() {
72
64
  let t = this.parentElement, e = {}, s = {};
@@ -102,13 +94,7 @@ class b extends n {
102
94
  }
103
95
  pushValueChange() {
104
96
  const t = this.getName();
105
- this.formAttrs.id && t && d(
106
- this.formAttrs.id,
107
- "valueChange",
108
- t,
109
- this._value,
110
- !this._reseting
111
- ), this._reseting = !1;
97
+ this.formAttrs.id && t && d(this.formAttrs.id, "valueChange", t, this._value, !this._reseting), this._reseting = !1;
112
98
  }
113
99
  _resetFieldValue = () => {
114
100
  this._reseting = !0, this.reset();
@@ -16,9 +16,9 @@ export default class FormItem extends BaseComponent {
16
16
  /** 自定义验证的正则 */
17
17
  pattern?: string;
18
18
  name?: string;
19
- innerBlock: boolean;
20
19
  labelPosition?: "left" | "right" | "top";
21
20
  private formId?;
21
+ innerBlock?: boolean;
22
22
  static get observedAttributes(): string[];
23
23
  get error(): string | undefined;
24
24
  set error(error: string | undefined);
@@ -1,10 +1,10 @@
1
- import { $$ as i, $one as o, addClass as n, removeClass as d } from "ph-utils/dom";
2
- import { initAttr as h, parseAttrValue as m } from "../utils/index.js";
1
+ import { $$ as i, $one as o, addClass as d, removeClass as h } from "ph-utils/dom";
2
+ import { parseAttrValue as a, initAttr as m } from "../utils/index.js";
3
3
  import f from "../base.js";
4
4
  import { emit as s, add as c, clear as p, remove as b } from "../utils/event.js";
5
- import { random as a } from "ph-utils";
5
+ import { random as n } 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-control-height, 32px);line-height:var(--l-form-control-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
- class I extends f {
7
+ class k extends f {
8
8
  static baseName = "form-item";
9
9
  disabled = !1;
10
10
  sharedAttrs = ["disabled", "id", "name", "innerBlock"];
@@ -19,12 +19,12 @@ class I extends f {
19
19
  /** 自定义验证的正则 */
20
20
  pattern;
21
21
  name;
22
- innerBlock = !1;
23
22
  labelPosition = "right";
24
23
  formId;
24
+ innerBlock;
25
25
  #e;
26
26
  static get observedAttributes() {
27
- return ["error", "label", "disabled"];
27
+ return ["error", "label", "disabled", "inner-block"];
28
28
  }
29
29
  get error() {
30
30
  return this.#e;
@@ -38,12 +38,12 @@ class I extends f {
38
38
  else if (e === "label")
39
39
  this.label = r, this._updateLabel();
40
40
  else if (e === "disabled") {
41
- const l = m(r, !1, e);
41
+ const l = a(r, !1, e);
42
42
  l !== this.disabled && (s(this.id, "attributeChanged", e, l, this.id), this.disabled = l);
43
- }
43
+ } else e === "inner-block" && (this.innerBlock = a(r, !1, e));
44
44
  }
45
45
  connectedCallback() {
46
- if (h(this), this.id == null && (this.id = `l-fi${a(3)}-${a(6)}`), this.loadStyleText([u]), super.connectedCallback(), this.formId = this._getFormId(), this.name && this.formId) {
46
+ if (m(this), this.id == null && (this.id = `l-fi${n(3)}-${n(6)}`), this.loadStyleText([u]), super.connectedCallback(), this.formId = this._getFormId(), this.name && this.formId) {
47
47
  let e = this.verify?.split("|") || [];
48
48
  this.pattern && e.push(new RegExp(this.pattern));
49
49
  const t = {
@@ -75,9 +75,7 @@ class I extends f {
75
75
  })
76
76
  );
77
77
  const t = i("div", { class: "l-form-item__content" }), r = i("slot");
78
- return t.appendChild(r), this.error && t.appendChild(
79
- i("div", { class: "l-form-item__error", textContent: this.error })
80
- ), e.appendChild(t), e;
78
+ return t.appendChild(r), this.error && t.appendChild(i("div", { class: "l-form-item__error", textContent: this.error })), e.appendChild(t), e;
81
79
  }
82
80
  _validateChange = (e, t) => {
83
81
  const r = e === !0 ? void 0 : e[this.name];
@@ -93,7 +91,7 @@ class I extends f {
93
91
  const t = o(".l-form-item__content", this.root);
94
92
  t && t.appendChild(e);
95
93
  }
96
- this.error ? n(this, "is-error") : d(this, "is-error");
94
+ this.error ? d(this, "is-error") : h(this, "is-error");
97
95
  }
98
96
  _updateLabel() {
99
97
  if (!this.rendered) return;
@@ -115,5 +113,5 @@ class I extends f {
115
113
  }
116
114
  }
117
115
  export {
118
- I as default
116
+ k as default
119
117
  };
@@ -1,9 +1,9 @@
1
- import { addClass as h, removeClass as u, $one as d, on as o, formatStyle as c, off as p, $ as f, $$ as n } from "ph-utils/dom";
2
- import { initAttr as g, parseAttrValue as a } from "../utils/index.js";
3
- import m from "../form/form_inner.js";
4
- import { add as b, remove as x } from "../utils/event.js";
5
- import { i as v } from "../index-DvcllHRh.js";
6
- class I extends m {
1
+ import { addClass as d, removeClass as p, $one as f, on as c, formatStyle as x, off as g, $ as m, $$ as a } from "ph-utils/dom";
2
+ import { initAttr as C, parseAttrValue as o } from "../utils/index.js";
3
+ import v from "../form/form_inner.js";
4
+ import { add as $, remove as _ } from "../utils/event.js";
5
+ import { i as w } from "../index-DvcllHRh.js";
6
+ class j extends v {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
9
9
  type = "text";
@@ -33,54 +33,42 @@ class I extends m {
33
33
  return this.#t;
34
34
  }
35
35
  set clearable(t) {
36
- this.#t = t, t ? h(this, "l-input--clearable") : u(this, "l-input--clearable");
36
+ this.#t = t, t ? d(this, "l-input--clearable") : p(this, "l-input--clearable");
37
37
  }
38
38
  static get observedAttributes() {
39
- return [
40
- "disabled",
41
- "value",
42
- "name",
43
- "error",
44
- "clearable",
45
- "maxlength",
46
- "inputmode"
47
- ];
39
+ return ["disabled", "value", "name", "error", "clearable", "maxlength", "inputmode"];
48
40
  }
49
41
  connectedCallback() {
50
- 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 = c(this._getStyleObj()) + this.getAttr("style", ""), this.error && h(this, "is-error"), this.getName() && this.formAttrs.id && b(this.formAttrs.id, "validateChange", this._validateChange);
42
+ C(this), this.loadStyleText([w]), super.connectedCallback(), this.$inner = f(".l-input__inner", this.root), c(this.$inner, "input", this._input), c(this.$inner, "change", this.#s), this.style.cssText = x(this._getStyleObj()) + this.getAttr("style", ""), this.error && d(this, "is-error"), this.getName() && this.formAttrs.id && $(this.formAttrs.id, "validateChange", this._validateChange);
51
43
  }
52
44
  disconnectedCallback() {
53
- super.disconnectedCallback(), this.formAttrs.id && x(this.formAttrs.id, "validateChange", this._validateChange), p(this.$inner, "input", this._input);
45
+ super.disconnectedCallback(), this.formAttrs.id && _(this.formAttrs.id, "validateChange", this._validateChange), g(this.$inner, "input", this._input);
54
46
  }
55
- attributeChange(t, s, e) {
56
- const r = a(
57
- e,
58
- this[t],
59
- t
60
- );
61
- if (r !== this[t] && (this[t] = r), t === "error") {
62
- const i = a(e, !1, t);
47
+ attributeChange(t, l, e) {
48
+ const s = o(e, this[t], t);
49
+ if (s !== this[t] && (this[t] = s), t === "error") {
50
+ const i = o(e, !1, t);
63
51
  i !== this.error && (this.error = i, this._updateError());
64
52
  } else if (t === "clearable") {
65
- const i = a(e, !1, t);
53
+ const i = o(e, !1, t);
66
54
  i !== this.clearable && (this.clearable = i);
67
55
  } else if (t === "maxlength") {
68
- const i = a(e, this.maxlength);
56
+ const i = o(e, this.maxlength);
69
57
  i !== this.maxlength && (this.maxlength = i);
70
58
  }
71
59
  }
72
60
  render() {
73
61
  const t = document.createDocumentFragment();
74
- if (f('[slot="prefix"]', this).length > 0) {
75
- const i = n("slot", {
62
+ if (m('[slot="prefix"]', this).length > 0) {
63
+ const i = a("slot", {
76
64
  name: "prefix"
77
- }), l = n("span", {
65
+ }), r = a("span", {
78
66
  class: "l-input__prefix",
79
67
  part: "prefix"
80
68
  });
81
- l.appendChild(i), t.appendChild(l);
69
+ r.appendChild(i), t.appendChild(r);
82
70
  }
83
- const e = n("input", {
71
+ const e = a("input", {
84
72
  class: "l-input__inner",
85
73
  value: this.value,
86
74
  name: this.getName() || "",
@@ -89,14 +77,14 @@ class I extends m {
89
77
  type: this.type,
90
78
  inputmode: this.inputmode
91
79
  });
92
- if (this.isDisabled() && (e.disabled = !0), this.maxlength && e.setAttribute("maxlength", this.maxlength), this.minlength && e.setAttribute("minlength", this.minlength), t.appendChild(e), f('[slot="suffix"]', this).length > 0) {
93
- const i = n("slot", {
80
+ if (this.isDisabled() && (e.disabled = !0), this.maxlength && e.setAttribute("maxlength", this.maxlength), this.minlength && e.setAttribute("minlength", this.minlength), t.appendChild(e), m('[slot="suffix"]', this).length > 0) {
81
+ const i = a("slot", {
94
82
  name: "suffix"
95
- }), l = n("span", {
83
+ }), r = a("span", {
96
84
  class: "l-input__suffix",
97
85
  part: "suffix"
98
86
  });
99
- l.appendChild(i), t.appendChild(l);
87
+ r.appendChild(i), t.appendChild(r);
100
88
  }
101
89
  return t;
102
90
  }
@@ -108,31 +96,34 @@ class I extends m {
108
96
  this.parser = t;
109
97
  }
110
98
  _input = (t) => {
111
- const s = t.target;
112
- let e = s.value;
99
+ const l = t.target;
100
+ let e = l.value, s = "";
113
101
  if (this.allowInput != null) {
114
- let r = this.allowInput.indexOf("."), i = r === -1 ? r : parseInt(this.allowInput.substring(r + 1));
115
- e = this._numberInputParse(e, {
102
+ let u = this.allowInput.indexOf("."), b = u === -1 ? u : parseInt(this.allowInput.substring(u + 1));
103
+ s = this._numberInputParse(e, {
116
104
  integer: this.allowInput.includes("integer"),
117
105
  negative: this.allowInput.startsWith("-"),
118
- precition: i
119
- }), e = String(e);
106
+ precision: b
107
+ }), s = String(s);
120
108
  }
121
- this.parser != null && (e = this.parser(e)), s.value = e, this.setValue(e), this.#e();
109
+ this.parser != null && (s = this.parser(s));
110
+ const i = l.selectionStart || 0, r = l.selectionEnd;
111
+ let n = i, h = r;
112
+ s.length < e.length ? (n = Math.max(0, i - (e.length - s.length)), h = n) : s.length > e.length ? (n = Math.min(s.length, i + (s.length - e.length)), h = n) : (n = Math.min(s.length, i), h = n), l.value = s, l.setSelectionRange(n, h), this.setValue(s), this.#e();
122
113
  };
123
114
  #e() {
124
115
  if (this.clearable) {
125
- let t = d(".l-clearable", this.root);
116
+ let t = f(".l-clearable", this.root);
126
117
  if (this.value.length > 0) {
127
118
  if (t == null) {
128
- t = n("span", {
119
+ t = a("span", {
129
120
  class: "l-input__suffix l-clearable"
130
121
  });
131
- const s = n("l-close-filled-icon");
132
- t.appendChild(s), this.root.appendChild(t), o(t, "click", this.#i);
122
+ const l = a("l-close-filled-icon");
123
+ t.appendChild(l), this.root.appendChild(t), c(t, "click", this.#i);
133
124
  }
134
125
  } else
135
- t && (p(t, "click", this.#i), t.remove());
126
+ t && (g(t, "click", this.#i), t.remove());
136
127
  }
137
128
  }
138
129
  #i = () => {
@@ -146,18 +137,23 @@ class I extends m {
146
137
  disabledChange() {
147
138
  this.isDisabled() ? this.classList.add("is-disabled") : this.classList.remove("is-disabled"), this.$inner && (this.$inner.disabled = this.isDisabled());
148
139
  }
149
- _numberInputParse(t, s) {
150
- let e = t, r = s.negative ? "-?" : "";
151
- if (s.integer) {
152
- const l = e.match(new RegExp(`^(${r}\\d*)`));
153
- return l != null ? l[1] : e.substring(0, e.length - 1);
140
+ _numberInputParse(t, l) {
141
+ let e = t.trim();
142
+ if (e === "") return "";
143
+ let s = e.startsWith("-");
144
+ if (s && (l.negative || (e = e.slice(1), s = !1)), l.integer)
145
+ e = e.replace(/[^\d]/g, "");
146
+ else {
147
+ const i = e.split(".");
148
+ if (i.length > 2)
149
+ e = i[0] + "." + i.slice(1).join("").substring(0, l.precision);
150
+ else if (i.length === 2) {
151
+ const r = i[0].replace(/[^\d]/g, ""), n = i[1].replace(/[^\d]/g, "").substring(0, l.precision);
152
+ e = `${r}.${n}`;
153
+ } else
154
+ e = e.replace(/[^\d]/g, "");
154
155
  }
155
- const i = e.match(
156
- new RegExp(
157
- `(${r}\\d+\\.\\d{0,${s.precition}})|(${r}\\d*)`
158
- )
159
- );
160
- return i != null ? e = i[1] || i[2] : e = "", i != null ? i[1] || i[2] : "";
156
+ return e.length > 1 && (e = e.replace(/^0+(\d)/, "$1")), s ? "-" + e : e;
161
157
  }
162
158
  _getStyleObj() {
163
159
  const t = {};
@@ -167,26 +163,26 @@ class I extends m {
167
163
  return this.block === !0 || this.formItemAttrs.innerBlock === !0 || this.formAttrs.innerBlock === !0;
168
164
  }
169
165
  _updateError() {
170
- this.error ? h(this, "is-error") : u(this, "is-error");
166
+ this.error ? d(this, "is-error") : p(this, "is-error");
171
167
  }
172
- _validateChange = (t, s) => {
168
+ _validateChange = (t, l) => {
173
169
  const e = this.getName();
174
170
  if (e) {
175
- const r = t === !0 ? !1 : t[e] != null;
176
- (s == null || s === e && this.error != r) && (this.error = r, this._updateError()), Object.keys(t)[0] === e && this.focus();
171
+ const s = t === !0 ? !1 : t[e] != null;
172
+ (l == null || l === e && this.error != s) && (this.error = s, this._updateError()), Object.keys(t)[0] === e && this.focus();
177
173
  }
178
174
  };
179
175
  #s = (t) => {
180
- const s = t.target;
176
+ const l = t.target;
181
177
  this.dispatchEvent(
182
178
  new CustomEvent("change", {
183
179
  bubbles: !0,
184
180
  composed: !0,
185
- detail: { value: s.value }
181
+ detail: { value: l.value }
186
182
  })
187
183
  );
188
184
  };
189
185
  }
190
186
  export {
191
- I as default
187
+ j as default
192
188
  };
@@ -21,11 +21,13 @@ declare class LoadingInstance {
21
21
  /** 加载容器 */
22
22
  el: HTMLElement;
23
23
  option: Required<Omit<LoadingInstanceParams, "to" | "zindex">>;
24
+ isLoading: boolean;
24
25
  constructor(option?: LoadingInstanceParams);
25
26
  /** 显示进度条 */
26
27
  show(): void;
27
28
  /** 隐藏进度条 */
28
29
  hide(): void;
30
+ destroy(): void;
29
31
  }
30
32
  declare const _default: {
31
33
  /** 创建并显示进度条 */
@@ -1,70 +1,59 @@
1
- import { $ as u, iterate as g, $one as c, addClass as d, hasClass as m, $$ as o } from "ph-utils/dom";
1
+ import { $ as c, iterate as d, $one as r, addClass as g, hasClass as m, $$ as o } from "ph-utils/dom";
2
2
  function f(t, e) {
3
3
  if (m(t, "l-loading")) return;
4
- let n;
5
- if (e.fullscreen && c("#l-loading") != null)
4
+ let l;
5
+ if (e.fullscreen && r("#l-loading") != null)
6
6
  return;
7
- d(t, "l-loading"), (e.mask === 1 || e.mask === 2 && e.shape === "circle") && (n = o("div", {
7
+ const s = ["l-loading"];
8
+ (e.mask === 1 || e.mask === 2 && e.shape === "circle") && (l = o("div", {
8
9
  class: "l-loading-mask",
9
10
  style: {
10
11
  "background-color": e.background,
11
12
  "--l-loading-zindex": e.zindex
12
13
  }
13
- }), t.appendChild(n));
14
- const l = o("div", {
14
+ }), t.appendChild(l));
15
+ const n = o("div", {
15
16
  class: `l-loading-spinner l-loading--${e.shape}`,
16
17
  style: {
17
18
  "--l-loading-color": e.color
18
19
  }
19
20
  });
20
21
  if (e.shape === "bar") {
21
- const s = o("div", { class: "l-loading-progress" });
22
- l.style.setProperty(
23
- "top",
24
- `-${getComputedStyle(t).borderTopWidth}`
25
- ), l.appendChild(s);
22
+ const i = o("div", { class: "l-loading-progress" });
23
+ n.appendChild(i);
26
24
  } else if (e.shape === "circle") {
27
- const s = document.createElementNS(
28
- "http://www.w3.org/2000/svg",
29
- "svg"
30
- );
31
- s.setAttribute("viewBox", "0 0 50 50"), s.classList.add("circle");
32
- const a = document.createElementNS(
33
- "http://www.w3.org/2000/svg",
34
- "circle"
35
- );
36
- if (a.classList.add("path"), a.setAttribute("cx", "25"), a.setAttribute("cy", "25"), a.setAttribute("r", "23"), a.setAttribute("fill", "none"), s.appendChild(a), l.appendChild(s), e.text) {
37
- const i = o("p", {
25
+ const i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
26
+ i.setAttribute("viewBox", "0 0 50 50"), i.classList.add("circle");
27
+ const a = document.createElementNS("http://www.w3.org/2000/svg", "circle");
28
+ if (a.classList.add("path"), a.setAttribute("cx", "25"), a.setAttribute("cy", "25"), a.setAttribute("r", "23"), a.setAttribute("fill", "none"), i.appendChild(a), n.appendChild(i), e.text) {
29
+ const p = o("p", {
38
30
  class: "l-loading-text",
39
31
  textContent: e.text
40
32
  });
41
- l.appendChild(i);
33
+ n.appendChild(p);
42
34
  }
43
35
  }
44
- if (t.appendChild(l), e.fullscreen) {
45
- const s = ["l-loading-fullscreen"];
46
- e.lock && s.push("l-loading-lock"), t.classList.add(...s), l.id = "l-loading";
47
- }
48
- requestAnimationFrame(() => {
49
- n && (n.style.opacity = "1"), l.style.opacity = "1", d(l, "l-loading-bar--start");
36
+ t.appendChild(n), e.lock && s.push("l-loading-lock"), e.fullscreen && (s.push("l-loading-fullscreen"), n.id = "l-loading"), t.classList.add(...s), requestAnimationFrame(() => {
37
+ l && (l.style.opacity = "1"), n.style.opacity = "1", g(n, "l-loading-bar--start");
50
38
  });
51
39
  }
52
- function p(t, e) {
53
- const n = t.tagName === "BODY" ? "body" : ".l-loading", l = c(`${n} > .l-loading-mask`, t), s = c(`${n} > .l-loading-spinner`, t);
54
- if (!s) return;
55
- function a() {
56
- l && l.remove(), s.remove();
57
- const i = ["l-loading"];
58
- t.tagName === "BODY" && i.push("l-loading-fullscreen", "l-loading-lock"), t.classList.remove(...i);
40
+ function h(t, e) {
41
+ const l = t.tagName === "BODY" ? "body" : ".l-loading", s = r(`${l} > .l-loading-mask`, t), n = r(`${l} > .l-loading-spinner`, t);
42
+ if (!n) return;
43
+ function i() {
44
+ s && s.remove(), n.remove();
45
+ const a = ["l-loading"];
46
+ t.tagName === "BODY" && a.push("l-loading-fullscreen", "l-loading-lock"), t.classList.remove(...a);
59
47
  }
60
- s.addEventListener("transitionend", a, { once: !0 }), requestAnimationFrame(() => {
61
- l && (l.style.opacity = "0"), d(s, "l-loading-bar--finish"), s.style.opacity = "0";
48
+ n.addEventListener("transitionend", i, { once: !0 }), requestAnimationFrame(() => {
49
+ s && (s.style.opacity = "0"), g(n, "l-loading-bar--finish"), n.style.opacity = "0";
62
50
  });
63
51
  }
64
- class h {
52
+ class b {
65
53
  /** 加载容器 */
66
54
  el;
67
55
  option;
56
+ isLoading = !1;
68
57
  constructor(e) {
69
58
  this.option = {
70
59
  fullscreen: !0,
@@ -76,45 +65,45 @@ class h {
76
65
  mask: 2,
77
66
  ...e
78
67
  };
79
- const n = (e || {}).to;
80
- let l = null;
81
- n != null && (typeof n == "string" ? l = document.querySelector(n) : l = n), (l == null || this.option.fullscreen) && (l = document.body), this.el = l, this.show();
68
+ const l = (e || {}).to;
69
+ let s = null;
70
+ l != null && (typeof l == "string" ? s = document.querySelector(l) : s = l), (s == null || this.option.fullscreen) && (s = document.body), this.el = s, this.show();
82
71
  }
83
72
  /** 显示进度条 */
84
73
  show() {
85
- f(this.el, this.option);
74
+ this.isLoading = !0, f(this.el, this.option);
86
75
  }
87
76
  /** 隐藏进度条 */
88
77
  hide() {
89
- p(this.el, this.option);
78
+ this.isLoading = !1, h(this.el, this.option);
79
+ }
80
+ destroy() {
81
+ this.hide(), this.el = void 0;
90
82
  }
91
83
  }
92
- function r(t) {
93
- const e = t.getAttribute("l-loading-text"), n = t.getAttribute("l-loading-lock");
84
+ function u(t) {
85
+ const e = t.getAttribute("l-loading-text"), l = t.getAttribute("l-loading-lock");
94
86
  return {
95
87
  background: t.getAttribute("l-loading-background"),
96
88
  text: e ? e === "0" || e === "false" ? void 0 : e : "加载中……",
97
89
  fullscreen: t.hasAttribute("l-loading-fullscreen"),
98
- lock: !(n === "0" || n === "false"),
90
+ lock: !(l === "0" || l === "false"),
99
91
  mask: Number(t.hasAttribute("l-loading-mask") || 2),
100
92
  shape: t.getAttribute("l-loading-shape") || "circle",
101
93
  color: t.getAttribute("l-loading-color")
102
94
  };
103
95
  }
104
- const $ = {
96
+ const k = {
105
97
  /** 创建并显示进度条 */
106
98
  create(t) {
107
- return new h(t);
99
+ return new b(t);
108
100
  },
109
101
  /** 根据指令参数初始化进度条 */
110
102
  init(t) {
111
- const e = t ? `[l-loading="${t}"]` : "[l-loading]", n = u(e);
112
- g(n, (l) => {
113
- const s = r(l);
114
- f(
115
- s.fullscreen ? document.body : l,
116
- r(l)
117
- );
103
+ const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = c(e);
104
+ d(l, (s) => {
105
+ const n = u(s);
106
+ f(n.fullscreen ? document.body : s, n);
118
107
  });
119
108
  },
120
109
  /**
@@ -126,16 +115,13 @@ const $ = {
126
115
  * @param id 可选参数,指定特定的加载元素 l-loading 对应的值,如果提供,则只关闭匹配该 id 的元素
127
116
  */
128
117
  close(t) {
129
- const e = t ? `[l-loading="${t}"]` : "[l-loading]", n = u(e);
130
- g(n, (l) => {
131
- const s = r(l);
132
- p(
133
- s.fullscreen ? document.body : l,
134
- r(l)
135
- );
118
+ const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = c(e);
119
+ d(l, (s) => {
120
+ const n = u(s);
121
+ h(n.fullscreen ? document.body : s);
136
122
  });
137
123
  }
138
124
  };
139
125
  export {
140
- $ as default
126
+ k as default
141
127
  };
@@ -1,9 +1,9 @@
1
1
  import { regist as g, useId as y } from "../utils/index.js";
2
2
  import { transition as m } from "ph-utils/dom";
3
- import p from "../icon/close_filled.js";
4
- import h from "../icon/success.js";
5
- import $ from "../icon/warn.js";
6
- import x from "../icon/info.js";
3
+ import h from "../icon/close_filled.js";
4
+ import p from "../icon/success.js";
5
+ import x from "../icon/warn.js";
6
+ import $ from "../icon/info.js";
7
7
  const r = [], d = [
8
8
  ["opacity", "0", "0.3s"],
9
9
  ["transform", "translate3d(-50%, -100%, 0)", "0.3s"]
@@ -20,8 +20,8 @@ function u(e) {
20
20
  const i = 15 + s.offsetHeight, n = r.length;
21
21
  if (n !== 0)
22
22
  for (let o = t; o < n; o++) {
23
- const a = r[o], f = parseInt(a.style.top, 10) - i;
24
- a.style.setProperty("top", `${f}px`);
23
+ const f = r[o], a = parseInt(f.style.top, 10) - i;
24
+ f.style.setProperty("top", `${a}px`);
25
25
  }
26
26
  }
27
27
  function v(e) {
@@ -29,7 +29,7 @@ function v(e) {
29
29
  t.id = e.id;
30
30
  const s = e.type || "info";
31
31
  let i = `l-message l-message-${s}`;
32
- e.customClass && (i += " " + e.customClass), t.className = i, t.style.setProperty("top", `${e.offset}px`), t.style.setProperty("z-index", `${e.zindex || 1e3}`), e.width && t.style.setProperty("width", e.width);
32
+ e.customClass && (i += " " + e.customClass), t.className = i, t.style.setProperty("top", `${e.offset}px`), e.zindex && t.style.setProperty("z-index", `${e.zindex}`), e.width && t.style.setProperty("width", e.width);
33
33
  let n = s;
34
34
  return n === "error" && (n = "close-filled"), t.innerHTML = [
35
35
  '<div class="l-message-container">',
@@ -39,8 +39,8 @@ function v(e) {
39
39
  ].join(""), t;
40
40
  }
41
41
  const w = ((e) => {
42
- l && (g([p, h, $, x]), l = !1);
43
- const t = r.reduce((a, f) => a + f.offsetHeight + 15, 15), s = y(), i = typeof e == "string" ? { message: e } : e;
42
+ l && (g([h, p, x, $]), l = !1);
43
+ const t = r.reduce((f, a) => f + a.offsetHeight + 15, 15), s = y(), i = typeof e == "string" ? { message: e } : e;
44
44
  i.id = s, i.offset = t;
45
45
  const n = v(i);
46
46
  r.push(n), document.body.appendChild(n), m(n, d, "enter");
@@ -2,18 +2,12 @@ import BaseComponent from "../base";
2
2
  export default class Modal extends BaseComponent {
3
3
  #private;
4
4
  static baseName: string;
5
- /** 是否显示对话框 */
6
- show: boolean;
7
5
  /** 关闭时销毁 Modal 里的子元素 */
8
6
  destroyOnClose: boolean;
9
7
  /** 点击蒙层是否允许关闭 */
10
8
  maskClosable: boolean;
11
9
  /** 是否展示遮罩 */
12
10
  mask: boolean;
13
- /** 标题 */
14
- title: string;
15
- /** 是否展示底部 */
16
- footer: boolean;
17
11
  /** 是否显示取消按钮 */
18
12
  cancel: boolean;
19
13
  /** 取消按钮文本 */
@@ -32,6 +26,7 @@ export default class Modal extends BaseComponent {
32
26
  mobile: boolean;
33
27
  /** 设置 Modal 的 z-index */
34
28
  zIndex?: string;
29
+ _bodyOverflow: string;
35
30
  static get observedAttributes(): string[];
36
31
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
37
32
  connectedCallback(): void;
@@ -2,20 +2,14 @@ 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
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
- class L extends x {
5
+ class S extends x {
6
6
  static baseName = "modal";
7
- /** 是否显示对话框 */
8
- show = !1;
9
7
  /** 关闭时销毁 Modal 里的子元素 */
10
8
  destroyOnClose = !1;
11
9
  /** 点击蒙层是否允许关闭 */
12
10
  maskClosable = !0;
13
11
  /** 是否展示遮罩 */
14
12
  mask = !0;
15
- /** 标题 */
16
- title = "";
17
- /** 是否展示底部 */
18
- footer = !0;
19
13
  /** 是否显示取消按钮 */
20
14
  cancel = !0;
21
15
  /** 取消按钮文本 */
@@ -34,45 +28,45 @@ class L extends x {
34
28
  mobile = !1;
35
29
  /** 设置 Modal 的 z-index */
36
30
  zIndex;
37
- #t = "";
31
+ _bodyOverflow = "";
38
32
  static get observedAttributes() {
39
33
  return ["show", "width", "confirm-loading"];
40
34
  }
41
- attributeChangedCallback(t, e, o) {
35
+ attributeChangedCallback(t, l, o) {
42
36
  if (this.rendered) {
43
37
  if (t === "show")
44
- this.show = c(o, !1), this.show ? this.#e() : this.#i();
38
+ c(o, !1, "show") ? this.#o() : this.#a();
45
39
  else if (t === "width")
46
- this.width = c(o, void 0), this.#o();
40
+ this.width = c(o, void 0), this.#t();
47
41
  else if (t === "confirm-loading") {
48
42
  this.confirmLoading = c(o, !1, "confirm-loading");
49
- const l = i('l-button[modal-action="ok"]', this.root);
50
- l && l.setAttribute("loading", this.confirmLoading.toString());
43
+ const e = i('l-button[modal-action="ok"]', this.root);
44
+ e && e.setAttribute("loading", this.confirmLoading.toString());
51
45
  }
52
46
  }
53
47
  }
54
48
  connectedCallback() {
55
- g(this), this.loadStyleText([w, v]), super.connectedCallback(), this.#o(), this.zIndex && this.style.setProperty("--l-modal-zindex", this.zIndex);
49
+ g(this), this.loadStyleText([w, v]), super.connectedCallback(), this.#t(), this.zIndex && this.style.setProperty("--l-modal-zindex", this.zIndex);
56
50
  }
57
51
  render() {
58
- this.show && this.#e();
52
+ this.getAttr("show", !1) && this.#o();
59
53
  }
60
- #o() {
54
+ #t() {
61
55
  this.width ? this.style.setProperty("--l-modal-width", this.width) : this.style.removeProperty("--l-modal-width");
62
56
  }
63
- #e() {
64
- this.#t = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
57
+ #o() {
58
+ this._bodyOverflow = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
65
59
  let t = i(".l-modal-wrapper", this.root);
66
60
  if (t) {
67
- const e = i(".l-mask", this.root);
68
- e && s(e, "mask-transition");
61
+ const l = i(".l-mask", this.root);
62
+ l && s(l, "mask-transition");
69
63
  const o = i(".l-modal", this.root);
70
64
  s(o, "modal-transition");
71
65
  } else {
72
- const e = document.createDocumentFragment();
66
+ const l = document.createDocumentFragment();
73
67
  let o = null;
74
- this.mask && (o = a("div", { class: "l-mask l-modal-mask", part: "mask" }), e.appendChild(o)), t = a("div", { class: "l-modal-wrapper", part: "wrapper" });
75
- const l = a("div", {
68
+ this.mask && (o = a("div", { class: "l-mask l-modal-mask", part: "mask" }), l.appendChild(o)), t = a("div", { class: "l-modal-wrapper", part: "wrapper" });
69
+ const e = a("div", {
76
70
  class: [
77
71
  "l-modal",
78
72
  `l-modal--${this.mobile ? "mobile" : "pc"}`,
@@ -80,22 +74,22 @@ class L extends x {
80
74
  ],
81
75
  part: "default"
82
76
  });
83
- if (l.setAttribute("modal-action", "modal"), this.close !== 0) {
77
+ if (e.setAttribute("modal-action", "modal"), this.close !== 0) {
84
78
  const d = a("l-button", {
85
79
  shape: "circle",
86
80
  type: "normal",
87
81
  class: `l-btn-modal-close l-modal-close${this.close}`,
88
82
  "modal-action": "close"
89
83
  }), n = a("l-close-icon");
90
- d.appendChild(n), l.appendChild(d);
84
+ d.appendChild(n), e.appendChild(d);
91
85
  }
92
86
  const p = a("header", { class: "l-modal-header", part: "header" }), h = a("slot", { name: "header" });
93
- h.textContent = this.title || "", p.appendChild(h), l.appendChild(p);
87
+ h.textContent = this.getAttr("header", ""), p.appendChild(h), e.appendChild(p);
94
88
  const f = a("div", {
95
89
  class: "l-modal-container",
96
90
  part: "container"
97
91
  }), b = a("slot");
98
- if (f.appendChild(b), l.appendChild(f), this.footer) {
92
+ if (f.appendChild(b), e.appendChild(f), this.getAttr("footer", !1)) {
99
93
  const d = a("footer", {
100
94
  class: "l-modal-footer",
101
95
  part: "footer"
@@ -113,35 +107,35 @@ class L extends x {
113
107
  loading: this.confirmLoading,
114
108
  text: this.mobile
115
109
  });
116
- r.textContent = this.okText, r.setAttribute("modal-action", "ok"), n.appendChild(r), d.appendChild(n), l.appendChild(d);
110
+ r.textContent = this.okText, r.setAttribute("modal-action", "ok"), n.appendChild(r), d.appendChild(n), e.appendChild(d);
117
111
  }
118
- t.appendChild(l), t.setAttribute("role", "dialog"), t.setAttribute("modal-action", "mask"), u(t, "click", this.#a), e.appendChild(t), this.appendToRoot(e), s(l, "modal-transition"), o && s(o, "mask-transition");
112
+ t.appendChild(e), t.setAttribute("role", "dialog"), t.setAttribute("modal-action", "mask"), u(t, "click", this.#l), l.appendChild(t), this.appendToRoot(l), s(e, "modal-transition"), o && s(o, "mask-transition");
119
113
  }
120
114
  }
121
- #i() {
122
- document.body.style.setProperty("overflow", this.#t);
115
+ #a() {
116
+ document.body.style.setProperty("overflow", this._bodyOverflow);
123
117
  const t = i(".l-modal", this.root);
124
118
  s(t, "modal-transition", "leave", () => {
125
- this.destroyOnClose && this.#l(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
119
+ this.destroyOnClose && this.#e(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
126
120
  });
127
- const e = i(".l-mask", this.root);
128
- e && s(e, "mask-transition", "leave");
121
+ const l = i(".l-mask", this.root);
122
+ l && s(l, "mask-transition", "leave");
129
123
  }
130
124
  disconnectedCallback() {
131
- this.#l(), super.disconnectedCallback();
125
+ this.#e(), super.disconnectedCallback();
132
126
  }
133
- #l() {
127
+ #e() {
134
128
  const t = i(".l-modal-wrapper", this.root);
135
- t && (k(t, "click", this.#a), this.root.removeChild(t));
136
- const e = i(".l-mask", this.root);
137
- e && this.root.removeChild(e);
129
+ t && (k(t, "click", this.#l), this.root.removeChild(t));
130
+ const l = i(".l-mask", this.root);
131
+ l && this.root.removeChild(l);
138
132
  }
139
- #a = (t) => {
140
- const [e, o] = y(t, "modal-action", this.root);
141
- if (e) {
142
- let l = "";
143
- this.maskClosable && o === "mask" || o === "cancel" || o === "close" ? l = "cancel" : o === "ok" && (l = "ok"), l && this.dispatchEvent(
144
- new CustomEvent(l, {
133
+ #l = (t) => {
134
+ const [l, o] = y(t, "modal-action", this.root);
135
+ if (l) {
136
+ let e = "";
137
+ this.maskClosable && o === "mask" || o === "cancel" || o === "close" ? e = "cancel" : o === "ok" && (e = "ok"), e && this.dispatchEvent(
138
+ new CustomEvent(e, {
145
139
  detail: { action: o }
146
140
  })
147
141
  );
@@ -149,5 +143,5 @@ class L extends x {
149
143
  };
150
144
  }
151
145
  export {
152
- L as default
146
+ S as default
153
147
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "litos-ui",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "基于 Web Component 的 UI 组件库",
5
5
  "keywords": [
6
6
  "component library",
@@ -57,8 +57,8 @@
57
57
  "@types/node": "^25.0.10",
58
58
  "less": "^4.5.1",
59
59
  "lightningcss": "^1.31.1",
60
- "oxfmt": "^0.26.0",
61
- "oxlint": "^1.41.0",
60
+ "oxfmt": "^0.27.0",
61
+ "oxlint": "^1.42.0",
62
62
  "typescript": "^5.9.3",
63
63
  "vite": "^7.3.1",
64
64
  "vite-plugin-dts": "^4.5.4",
@@ -8,7 +8,7 @@
8
8
  bottom: 0;
9
9
  left: 0;
10
10
  z-index: var(--l-loading-zindex, 10);
11
- background: rgba(0, 0, 0, 0.4);
11
+ background: rgba(0, 0, 0, 0.7);
12
12
  border-radius: inherit;
13
13
  transition: opacity 0.3s;
14
14
  opacity: 0;
@@ -50,10 +50,12 @@
50
50
  margin: 0;
51
51
  font-size: 14px;
52
52
  }
53
+ .l-loading.l-loading-lock {
54
+ overflow: hidden;
55
+ }
53
56
 
54
57
  /* 全屏组件 */
55
- .l-loading-fullscreen.l-loading-lock {
56
- overflow: hidden;
58
+ .l-loading-fullscreen {
57
59
  --l-loading-zindex: 50;
58
60
  }
59
61
  .l-loading-fullscreen > .l-loading-mask {
@@ -1,4 +0,0 @@
1
- const r = ":host{--l-check-size: 16px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;transition:color .3s,border-color .3s,background-color .3s}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size);height:var(--l-check-size);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:border-color .3s ease-in-out;position:relative;margin-right:5px}.l-check__label{transition:color .3s;cursor:inherit;line-height:1}:host(.is-checked){color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color, #722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color, #e6e6e6)}:host([button]){height:var(--l-form-control-height, 32px);justify-content:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0;border-radius:inherit}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color, #722ed1);color:#fff;border-color:var(--l-primary-color, #722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color, #722ed1)}";
2
- export {
3
- r as c
4
- };