litos-ui 0.15.7 → 0.15.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import { parseAttrValue as i, initAttr as c } from "../utils/index.js";
2
2
  import h from "../base.js";
3
- import { $one as s, addClass as g, removeClass as p, on as f, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
3
+ import { $one as s, 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
4
  import { adjust as d } from "ph-utils/color";
5
5
  import { a as x } from "../animation-DttknHkX.js";
6
6
  const y = ":host{--l-btn-padding: 0 15px;--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;--l-btn-height: var(--l-form-control-height, 32px);display:inline-flex;width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius, 3px)}: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:var(--l-btn-padding);line-height:1;height:100%;border-radius:inherit;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:var(--l-btn-gap, 5px);font-size:inherit;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;--l-btn-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-control-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-control-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)}";
@@ -33,24 +33,24 @@ class B extends h {
33
33
  return ["loading", "color", "disabled", "height"];
34
34
  }
35
35
  // 当属性发生变化时调用的回调函数
36
- attributeChangedCallback(t, r, o) {
37
- const e = s(".l-btn", this.root);
38
- if (e) {
36
+ attributeChangedCallback(t, r, e) {
37
+ const o = s(".l-btn", this.root);
38
+ if (o) {
39
39
  if (t === "loading") {
40
- i(o, !1, t) ? (g(e, "l-btn-loading"), e.disabled = !0, e.innerHTML = this.loadingBody()) : (p(e, "l-btn-loading"), e.disabled = this.disabled, e.innerHTML = "<slot></slot>");
40
+ i(e, !1, t) ? (g(o, "l-btn-loading"), o.disabled = !0, o.innerHTML = this.loadingBody()) : (f(o, "l-btn-loading"), o.disabled = this.disabled, o.innerHTML = "<slot></slot>");
41
41
  return;
42
42
  } else if (t === "color") {
43
43
  const n = this.getAttr("text", !1), a = this.getAttr("ghost", !1);
44
- e.style.cssText = this.applyColor(o, n, a);
44
+ o.style.cssText = this.applyColor(e, n, a);
45
45
  return;
46
46
  } else if (t === "disabled") {
47
- const n = i(o, !1, "disabled");
47
+ const n = i(e, !1, "disabled");
48
48
  this.setDisabled(n);
49
49
  return;
50
50
  }
51
51
  }
52
52
  const l = i(
53
- o,
53
+ e,
54
54
  this[t],
55
55
  t
56
56
  );
@@ -62,41 +62,41 @@ class B extends h {
62
62
  }
63
63
  }
64
64
  connectedCallback() {
65
- c(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && f(this, "click", this._handleClick), this._updateHeight();
65
+ c(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick), this._updateHeight();
66
66
  }
67
67
  disconnectedCallback() {
68
68
  super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
69
69
  }
70
70
  render() {
71
- const t = this.getAttr("type", "normal"), r = document.createElement("button"), o = this.getAttr("loading", !1), e = this.getAttr("shape", "default"), l = this.getAttr("text", !1), n = this.getAttr("ghost", !1), a = [
71
+ const t = this.getAttr("type", "normal"), r = document.createElement("button"), e = this.getAttr("loading", !1), o = this.getAttr("shape", "default"), l = this.getAttr("text", !1), n = this.getAttr("ghost", !1), a = [
72
72
  "l-btn",
73
73
  `l-btn-${t}`,
74
- e === "round" ? "l-btn-round" : "",
75
- e === "circle" ? "l-btn-circle" : "",
74
+ o === "round" ? "l-btn-round" : "",
75
+ o === "circle" ? "l-btn-circle" : "",
76
76
  n ? "l-btn-ghost" : "",
77
77
  l ? "l-btn-text" : "",
78
- o ? "l-btn-loading" : ""
78
+ e ? "l-btn-loading" : ""
79
79
  ];
80
- r.className = u(a), r.disabled = this.disabled || o, r.type = this.getAttr("html-type", "button");
80
+ r.className = u(a), (this.disabled || e) && (r.disabled = !0), r.type = this.getAttr("html-type", "button");
81
81
  const b = this.applyColor(this.getAttr("color"), l, n);
82
- b && (r.style.cssText = b), o ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.root.appendChild(r);
82
+ b && (r.style.cssText = b), e ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.root.appendChild(r);
83
83
  }
84
84
  loadingBody() {
85
85
  const t = this.getAttr("loading-text", ""), r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
86
86
  return t ? r.push(`<span>${t}</span>`) : r.push("<slot></slot>"), r.join("");
87
87
  }
88
- applyColor(t, r = !1, o = !1) {
88
+ applyColor(t, r = !1, e = !1) {
89
89
  if (!t) return "";
90
- const e = d(t, 1, !0), l = d(t, 3, !1);
90
+ const o = d(t, 1, !0), l = d(t, 3, !1);
91
91
  return m({
92
92
  "--l-btn-border-color": r ? "transparent" : t,
93
- "--l-btn-text-color": o || r ? t : "#ffffff",
94
- "--l-btn-hover-text-color": o || r ? e : "#ffffff",
95
- "--l-btn-background": o || r ? "transparent" : t,
96
- "--l-btn-active-text-color": o || r ? l : "#ffffff",
97
- "--l-btn-hover-border-color": r ? "transparent" : e,
98
- "--l-btn-hover-background": o || r ? "transparent" : e,
99
- "--l-btn-active-background": o || r ? "transparent" : l,
93
+ "--l-btn-text-color": e || r ? t : "#ffffff",
94
+ "--l-btn-hover-text-color": e || r ? o : "#ffffff",
95
+ "--l-btn-background": e || r ? "transparent" : t,
96
+ "--l-btn-active-text-color": e || r ? l : "#ffffff",
97
+ "--l-btn-hover-border-color": r ? "transparent" : o,
98
+ "--l-btn-hover-background": e || r ? "transparent" : o,
99
+ "--l-btn-active-background": e || r ? "transparent" : l,
100
100
  "--l-btn-active-border-color": r ? "transparent" : l
101
101
  });
102
102
  }
@@ -107,21 +107,21 @@ class B extends h {
107
107
  }
108
108
  }
109
109
  _handleClick = (t) => {
110
- const r = t.target, o = k(r, "html-type");
111
- if (o === "reset" || o === "submit") {
112
- const e = this._getForm();
113
- e && (o === "reset" ? e.reset() : o === "submit" && e.submit());
110
+ const r = t.target, e = k(r, "html-type");
111
+ if (e === "reset" || e === "submit") {
112
+ const o = this._getForm();
113
+ o && (e === "reset" ? o.reset() : e === "submit" && o.submit());
114
114
  }
115
115
  };
116
116
  _getForm() {
117
117
  let t = this.parentElement, r;
118
118
  for (; t != null; ) {
119
- const o = t.tagName;
120
- if (o === "L-FORM") {
119
+ const e = t.tagName;
120
+ if (e === "L-FORM") {
121
121
  r = t;
122
122
  break;
123
123
  }
124
- if (o === "BODY") break;
124
+ if (e === "BODY") break;
125
125
  t = t.parentElement;
126
126
  }
127
127
  return t = null, r;
@@ -1,6 +1,6 @@
1
1
  import d from "../form/form_inner.js";
2
2
  import { initAttr as n, parseAttrValue as l } from "../utils/index.js";
3
- import { addClass as c, on as r, off as o, $$ as i, removeClass as k, $one as u, toggleClass as p } from "ph-utils/dom";
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
4
  class m extends d {
5
5
  /** 是否选中 */
6
6
  _checked = !1;
@@ -27,7 +27,7 @@ class m extends d {
27
27
  return ["disabled", "checked"];
28
28
  }
29
29
  connectedCallback() {
30
- n(this), super.connectedCallback(), this.getChecked() && c(this, "is-checked"), this.isDisabled() && c(this, "is-disabled");
30
+ n(this), super.connectedCallback(), this.getChecked() && h(this, "is-checked"), this.isDisabled() && h(this, "is-disabled");
31
31
  }
32
32
  afterInit() {
33
33
  r(this, "click", this.#e);
@@ -36,15 +36,14 @@ class m extends d {
36
36
  o(this, "click", this.#e);
37
37
  }
38
38
  render() {
39
- const e = document.createDocumentFragment(), h = i("input", {
39
+ const e = document.createDocumentFragment(), c = i("input", {
40
40
  type: this._inputType,
41
41
  class: "l-check__input",
42
42
  name: this.getName(),
43
43
  value: this.value,
44
- disabled: this.isDisabled(),
45
44
  checked: this.getChecked()
46
45
  });
47
- if (e.appendChild(h), !this.button) {
46
+ if (this.isDisabled() && (c.disabled = !0), e.appendChild(c), !this.button) {
48
47
  const a = i("span", { class: "l-check__inner" });
49
48
  e.appendChild(a);
50
49
  }
@@ -56,14 +55,14 @@ class m extends d {
56
55
  });
57
56
  return t.appendChild(s), e.appendChild(t), e;
58
57
  }
59
- attributeChange(e, h, t) {
58
+ attributeChange(e, c, t) {
60
59
  if (e === "checked") {
61
60
  const s = l(t, !1, "checked");
62
61
  s !== this.getChecked() && this.setChecked(s);
63
62
  }
64
63
  }
65
64
  checkedChange() {
66
- this.getChecked() ? c(this, "is-checked") : k(this, "is-checked");
65
+ this.getChecked() ? h(this, "is-checked") : k(this, "is-checked");
67
66
  const e = u("input", this.root);
68
67
  e && (e.checked = this._checked);
69
68
  }
@@ -1,19 +1,23 @@
1
1
  import e from "./check.js";
2
2
  import { c as o } from "../check-A86JxUfd.js";
3
- import { $one as r } from "ph-utils/dom";
3
+ import { $one as c } from "ph-utils/dom";
4
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 d extends e {
5
+ class n extends e {
6
6
  static baseName = "radio";
7
7
  connectedCallback() {
8
8
  this.loadStyleText([o, t]), super.connectedCallback();
9
9
  }
10
10
  _doChangeAction() {
11
- r("input", this.root).checked || (this.setAttribute("checked", ""), this.emit("change", {
12
- detail: { value: this.value, name: this.getName() },
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
+ },
13
17
  composed: !0
14
18
  }));
15
19
  }
16
20
  }
17
21
  export {
18
- d as default
22
+ n as default
19
23
  };
@@ -7,12 +7,15 @@ export default class FormInner extends BaseComponent {
7
7
  _resetValue?: any;
8
8
  protected _firstPushValue: boolean;
9
9
  private _reseting;
10
+ private _name?;
10
11
  /**
11
12
  *
12
13
  * @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
13
14
  * @param delegatesFocus 是否委托焦点, 默认: true
14
15
  */
15
16
  constructor(firstPushValue?: boolean, delegatesFocus?: boolean);
17
+ get name(): string | undefined;
18
+ set name(value: string | undefined);
16
19
  get value(): any;
17
20
  set value(value: any);
18
21
  setValue(value: any): void;
@@ -1,8 +1,7 @@
1
- import o from "../base.js";
2
- import { parseAttrValue as d } from "../utils/index.js";
3
- import { add as l, remove as u, emit as f } from "../utils/event.js";
4
- import { getAttr as m } from "ph-utils/dom";
5
- class c extends o {
1
+ import n from "../base.js";
2
+ import { parseAttrValue as m } from "../utils/index.js";
3
+ import { add as l, remove as u, emit as d } from "../utils/event.js";
4
+ class b extends n {
6
5
  disabled = !1;
7
6
  formAttrs = {};
8
7
  formItemAttrs = {};
@@ -10,6 +9,7 @@ class c extends o {
10
9
  _resetValue;
11
10
  _firstPushValue = !0;
12
11
  _reseting = !1;
12
+ _name;
13
13
  /**
14
14
  *
15
15
  * @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
@@ -18,6 +18,12 @@ class c extends o {
18
18
  constructor(t = !0, e = !0) {
19
19
  super(!0, { delegatesFocus: e }), this._firstPushValue = t;
20
20
  }
21
+ get name() {
22
+ return this._name;
23
+ }
24
+ set name(t) {
25
+ this._name = t;
26
+ }
21
27
  get value() {
22
28
  return this._value;
23
29
  }
@@ -31,15 +37,15 @@ class c extends o {
31
37
  return this._value;
32
38
  }
33
39
  static get observedAttributes() {
34
- return ["disabled", "value"];
40
+ return ["disabled", "value", "name"];
35
41
  }
36
- attributeChangedCallback(t, e, r) {
42
+ attributeChangedCallback(t, e, s) {
37
43
  if (t === "disabled") {
38
- const i = d(r, !1, t);
44
+ const i = m(s, !1, t);
39
45
  i !== this.disabled && (this.disabled = i, this.disabledChange());
40
- } else t === "value" ? this.value = r : this.attributeChange(t, e, r);
46
+ } else t === "value" || t === "name" ? this.value = s : this.attributeChange(t, e, s);
41
47
  }
42
- attributeChange(t, e, r) {
48
+ attributeChange(t, e, s) {
43
49
  }
44
50
  connectedCallback() {
45
51
  const t = this._getForm();
@@ -60,17 +66,16 @@ class c extends o {
60
66
  return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
61
67
  }
62
68
  getName() {
63
- const t = m(this, "name");
64
- return t || this.formItemAttrs.name;
69
+ return this.name ? this.name : this.formItemAttrs.name;
65
70
  }
66
71
  _getForm() {
67
- let t = this.parentElement, e = {}, r = {};
72
+ let t = this.parentElement, e = {}, s = {};
68
73
  for (; t != null; ) {
69
74
  const i = t.tagName;
70
75
  if (i === "L-FORM") {
71
76
  const a = t.sharedAttrs;
72
- for (let s = 0; s < a.length; s++) {
73
- const h = a[s];
77
+ for (let r = 0; r < a.length; r++) {
78
+ const h = a[r];
74
79
  e[h] = t[h];
75
80
  }
76
81
  break;
@@ -78,26 +83,26 @@ class c extends o {
78
83
  if (i === "BODY") break;
79
84
  if (i === "L-FORM-ITEM") {
80
85
  const a = t.sharedAttrs;
81
- for (let s = 0; s < a.length; s++) {
82
- const h = a[s];
83
- r[h] = t[h];
86
+ for (let r = 0; r < a.length; r++) {
87
+ const h = a[r];
88
+ s[h] = t[h];
84
89
  }
85
90
  }
86
91
  t = t.parentElement;
87
92
  }
88
93
  return t = null, {
89
94
  formAttr: e,
90
- formItemAttr: r
95
+ formItemAttr: s
91
96
  };
92
97
  }
93
- _formAttributeChanged = (t, e, r) => {
94
- r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
98
+ _formAttributeChanged = (t, e, s) => {
99
+ s === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this.disabledChange();
95
100
  };
96
101
  disabledChange() {
97
102
  }
98
103
  pushValueChange() {
99
104
  const t = this.getName();
100
- this.formAttrs.id && t && f(
105
+ this.formAttrs.id && t && d(
101
106
  this.formAttrs.id,
102
107
  "valueChange",
103
108
  t,
@@ -113,5 +118,5 @@ class c extends o {
113
118
  }
114
119
  }
115
120
  export {
116
- c as default
121
+ b as default
117
122
  };
@@ -1,7 +1,7 @@
1
1
  import s from "../mask/index.js";
2
2
  import { $$ as n, $one as r, on as a, off as o } from "ph-utils/dom";
3
3
  const l = ".l-image-preview--container{position:relative;width:100%;height:100%;display:flex;justify-content:center;align-items:center}.l-image-preview__btn,.l-image-preview-operations{display:flex;justify-content:center;align-items:center;background-color:#606666}.l-image-preview__btn{z-index:1;position:absolute;border-radius:50%;opacity:.8;cursor:pointer;background-color:#606666;color:#fff;width:40px;height:40px;font-size:20px;display:flex;justify-content:center;align-items:center;transition:color .3s ease-in-out;outline:none;border:none}.l-image-preview__btn:hover{color:var(--l-primary-color, #4998f6)}.l-image-preview__close{right:30px;top:30px}.l-image-preview__prev,.l-image-preview__next{top:50%;transform:translateY(-50%)}.l-image-preview__prev{left:30px}.l-image-preview__next{right:30px}.l-image-preview-footer{position:absolute;bottom:30px;left:50%;transform:translate(-50%);display:flex;align-items:center;flex-direction:column;z-index:1}.l-image-preview-progress{color:#fff;margin-bottom:10px}.l-image-preview-operations{cursor:default;padding:0 25px;border-radius:20px}.l-image-preview-operations .l-image-preview__btn{position:static;width:40px}.l-image-preview-img{max-width:calc(100vw - 40px);max-height:calc(100vh - 200px);vertical-align:middle;transform-origin:center center;transition:transform .25s;user-select:none;z-index:0}";
4
- class g extends s {
4
+ class p extends s {
5
5
  static baseName = "image-preview";
6
6
  urlList = [];
7
7
  currentIndex = 0;
@@ -87,7 +87,7 @@ class g extends s {
87
87
  return !0;
88
88
  }
89
89
  _handleWhell = (e) => {
90
- e.preventDefault(), e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
90
+ e.deltaY > 0 ? this._transformScale("out") : this._transformScale("in");
91
91
  };
92
92
  afterOpened() {
93
93
  a(document, "wheel", this._handleWhell, { passive: !0 });
@@ -100,5 +100,5 @@ class g extends s {
100
100
  }
101
101
  }
102
102
  export {
103
- g as default
103
+ p as default
104
104
  };
@@ -29,7 +29,8 @@ export default class Input extends FormInner {
29
29
  /** 宽度铺满 */
30
30
  block: boolean;
31
31
  error: boolean;
32
- maxlength?: number;
32
+ maxlength?: string;
33
+ minlength?: string;
33
34
  inputmode: InputMode;
34
35
  $inner?: HTMLInputElement;
35
36
  set value(value: any);
@@ -1,9 +1,9 @@
1
- import { addClass as h, removeClass as u, $one as d, on as o, formatStyle as f, off as p, $ as c, $$ as a } from "ph-utils/dom";
2
- import { initAttr as g, parseAttrValue as n } from "../utils/index.js";
3
- import b from "../form/form_inner.js";
4
- import { add as m, remove as x } from "../utils/event.js";
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
5
  import { i as v } from "../index-D4II9KsF.js";
6
- class y extends b {
6
+ class I extends m {
7
7
  static baseName = "input";
8
8
  /** 原生 input 的 type */
9
9
  type = "text";
@@ -19,6 +19,7 @@ class y extends b {
19
19
  block = !1;
20
20
  error = !1;
21
21
  maxlength;
22
+ minlength;
22
23
  inputmode = "text";
23
24
  $inner;
24
25
  #t = !1;
@@ -35,56 +36,63 @@ class y extends b {
35
36
  this.#t = t, t ? h(this, "l-input--clearable") : u(this, "l-input--clearable");
36
37
  }
37
38
  static get observedAttributes() {
38
- return ["disabled", "error", "clearable", "maxlength", "inputmode"];
39
+ return [
40
+ "disabled",
41
+ "value",
42
+ "name",
43
+ "error",
44
+ "clearable",
45
+ "maxlength",
46
+ "inputmode"
47
+ ];
39
48
  }
40
49
  connectedCallback() {
41
- g(this), this.loadStyleText([v]), super.connectedCallback(), this.$inner = d(".l-input__inner", this.root), o(this.$inner, "input", this._input), o(this.$inner, "change", this.#s), this.style.cssText = f(this._getStyleObj()) + this.getAttr("style", ""), this.error && h(this, "is-error"), this.getName() && this.formAttrs.id && m(this.formAttrs.id, "validateChange", this._validateChange);
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
51
  }
43
52
  disconnectedCallback() {
44
53
  super.disconnectedCallback(), this.formAttrs.id && x(this.formAttrs.id, "validateChange", this._validateChange), p(this.$inner, "input", this._input);
45
54
  }
46
55
  attributeChange(t, s, e) {
47
- const r = n(
56
+ const r = a(
48
57
  e,
49
58
  this[t],
50
59
  t
51
60
  );
52
61
  if (r !== this[t] && (this[t] = r), t === "error") {
53
- const i = n(e, !1, t);
62
+ const i = a(e, !1, t);
54
63
  i !== this.error && (this.error = i, this._updateError());
55
64
  } else if (t === "clearable") {
56
- const i = n(e, !1, t);
65
+ const i = a(e, !1, t);
57
66
  i !== this.clearable && (this.clearable = i);
58
67
  } else if (t === "maxlength") {
59
- const i = n(e, -1);
68
+ const i = a(e, this.maxlength);
60
69
  i !== this.maxlength && (this.maxlength = i);
61
70
  }
62
71
  }
63
72
  render() {
64
73
  const t = document.createDocumentFragment();
65
- if (c('[slot="prefix"]', this).length > 0) {
66
- const i = a("slot", {
74
+ if (f('[slot="prefix"]', this).length > 0) {
75
+ const i = n("slot", {
67
76
  name: "prefix"
68
- }), l = a("span", {
77
+ }), l = n("span", {
69
78
  class: "l-input__prefix",
70
79
  part: "prefix"
71
80
  });
72
81
  l.appendChild(i), t.appendChild(l);
73
82
  }
74
- const e = a("input", {
83
+ const e = n("input", {
75
84
  class: "l-input__inner",
76
85
  value: this.value,
77
- name: this.getName(),
78
- placeholder: this.placeholder,
79
- disabled: this.isDisabled(),
86
+ name: this.getName() || "",
87
+ placeholder: this.placeholder || "",
80
88
  part: "default",
81
89
  type: this.type,
82
90
  inputmode: this.inputmode
83
91
  });
84
- if (this.maxlength && this.maxlength >= 0 && e.setAttribute("maxlength", String(this.maxlength)), t.appendChild(e), c('[slot="suffix"]', this).length > 0) {
85
- const i = a("slot", {
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", {
86
94
  name: "suffix"
87
- }), l = a("span", {
95
+ }), l = n("span", {
88
96
  class: "l-input__suffix",
89
97
  part: "suffix"
90
98
  });
@@ -117,10 +125,10 @@ class y extends b {
117
125
  let t = d(".l-clearable", this.root);
118
126
  if (this.value.length > 0) {
119
127
  if (t == null) {
120
- t = a("span", {
128
+ t = n("span", {
121
129
  class: "l-input__suffix l-clearable"
122
130
  });
123
- const s = a("l-close-filled-icon");
131
+ const s = n("l-close-filled-icon");
124
132
  t.appendChild(s), this.root.appendChild(t), o(t, "click", this.#i);
125
133
  }
126
134
  } else
@@ -129,7 +137,10 @@ class y extends b {
129
137
  }
130
138
  #i = () => {
131
139
  this.value = "", this.dispatchEvent(
132
- new CustomEvent("input", { bubbles: !0, detail: { value: this.value } })
140
+ new CustomEvent("input", {
141
+ bubbles: !0,
142
+ detail: { value: this.value }
143
+ })
133
144
  ), this.#e();
134
145
  };
135
146
  disabledChange() {
@@ -177,5 +188,5 @@ class y extends b {
177
188
  };
178
189
  }
179
190
  export {
180
- y as default
191
+ I as default
181
192
  };
@@ -38,7 +38,7 @@ function x(e) {
38
38
  "</div>"
39
39
  ].join(""), t;
40
40
  }
41
- const i = (e) => {
41
+ const i = ((e) => {
42
42
  m && (y([h, $, v, w]), m = !1);
43
43
  const t = c.reduce(
44
44
  (f, l) => f + l.offsetHeight + 15,
@@ -51,7 +51,7 @@ const i = (e) => {
51
51
  return o == null && (o = 3e3), o !== 0 && setTimeout(() => {
52
52
  g(s);
53
53
  }, o), s;
54
- };
54
+ });
55
55
  function a(e, t = "info") {
56
56
  const s = typeof e == "string" ? { message: e } : e;
57
57
  return s.type || (s.type = t), i(s);
@@ -9,9 +9,11 @@ export default class Tabbar extends BaseComponent {
9
9
  * 3. card - 卡片
10
10
  */
11
11
  type: "nav" | "bar" | "card";
12
- name?: string;
12
+ _name: string;
13
13
  gap?: string;
14
14
  private $line?;
15
+ get name(): string;
16
+ set name(nameValue: string);
15
17
  connectedCallback(): void;
16
18
  static get observedAttributes(): string[] | null | undefined;
17
19
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
@@ -1,7 +1,7 @@
1
1
  import { isBlank as h, isNumeric as c } from "ph-utils";
2
2
  import d from "../base.js";
3
3
  import { parseAttrValue as l } from "../utils/index.js";
4
- import { addClass as b, removeClass as o, $one as r, create as n, $$ as p, on as f, off as m, shouldEventNext as u, isVisible as v } from "ph-utils/dom";
4
+ import { addClass as b, removeClass as s, $one as r, create as n, $$ as p, on as f, off as m, shouldEventNext as u, isVisible as v } from "ph-utils/dom";
5
5
  const g = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:flex;flex-wrap:nowrap;align-items:stretch;gap:var(--l-tabbar-item-gap);box-sizing:border-box}:host(.l-tabbar--nav){--l-tabbar-height: 50px;--l-tabbar-item-grow: 1;width:100%}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}";
6
6
  class _ extends d {
7
7
  static baseName = "tabbar";
@@ -12,9 +12,15 @@ class _ extends d {
12
12
  * 3. card - 卡片
13
13
  */
14
14
  type = "nav";
15
- name;
15
+ _name = "";
16
16
  gap;
17
17
  $line;
18
+ get name() {
19
+ return this._name;
20
+ }
21
+ set name(t) {
22
+ this._name = t;
23
+ }
18
24
  connectedCallback() {
19
25
  this.loadStyleText(g), b(this, `l-tabbar--${this.type}`), this.#t(), super.connectedCallback();
20
26
  }
@@ -27,9 +33,9 @@ class _ extends d {
27
33
  this.name = i, this._updateActive(), this._updateLine();
28
34
  } else if (t === "type") {
29
35
  const i = l(a, "nav");
30
- if (i !== this.type && (o(this, `l-tabbar--${this.type}`), this.type = i, o(this, `l-tabbar--${i}`), i === "card")) {
31
- let s = r(".l-tabbar-card-border", this.root);
32
- s || (s = n("div", { class: "l-tabbar-card-border" }), this.root.appendChild(s));
36
+ if (i !== this.type && (s(this, `l-tabbar--${this.type}`), this.type = i, s(this, `l-tabbar--${i}`), i === "card")) {
37
+ let o = r(".l-tabbar-card-border", this.root);
38
+ o || (o = n("div", { class: "l-tabbar-card-border" }), this.root.appendChild(o));
33
39
  }
34
40
  } else {
35
41
  const i = l(a, void 0);
@@ -64,7 +70,7 @@ class _ extends d {
64
70
  };
65
71
  _updateActive() {
66
72
  const t = r(".active", this);
67
- t && o(t, "active");
73
+ t && s(t, "active");
68
74
  const e = r(`[name="${this.name}"]`, this);
69
75
  e && b(e, "active");
70
76
  }
@@ -91,7 +97,7 @@ class _ extends d {
91
97
  #t() {
92
98
  const t = this.getAttr("justify-content");
93
99
  if (h(t) ? this.style.removeProperty("justify-content") : this.style.setProperty("justify-content", t), h(this.gap))
94
- this.style.removeProperty("--l-tabbar-item-gap"), o(this, "l-tabbar-gap");
100
+ this.style.removeProperty("--l-tabbar-item-gap"), s(this, "l-tabbar-gap");
95
101
  else {
96
102
  let e = this.gap;
97
103
  c(e, { isPositive: !0 }) && (e = `${e}px`), b(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
@@ -1,25 +1,41 @@
1
1
  import BaseComponent from "../base";
2
- import type { Column } from "./types";
2
+ import type { Column, SortOption } from "./types";
3
+ type ChangeFixedParams = {
4
+ fixedColumn?: boolean;
5
+ fixedHead?: boolean;
6
+ };
3
7
  export default class Table extends BaseComponent {
4
8
  static baseName: string;
5
9
  /** 斑马纹 */
6
10
  stripe: boolean;
11
+ /** 是否显示四周边框 */
12
+ border: boolean;
13
+ /** 是否固定表头 */
14
+ fixedHead: boolean;
15
+ /** 是否固定列,在进行列解析时,会自动确认该属性 */
16
+ fixedColumn: boolean;
17
+ /** 最大高度 */
18
+ maxHeight?: number | string;
19
+ /** 表格布局 */
20
+ tableLayout?: "auto" | "fixed";
7
21
  columns?: Column[];
8
22
  data?: any[];
9
- /** 左边固定列, 格式: [列key, 宽度] */
10
- private _fixedLeft;
11
- /** 右边固定列, 格式: [列key, 宽度] */
12
- private _fixedRight;
23
+ sortInfo?: SortOption;
13
24
  /** 缓存列通用样式, 避免渲染数据时,重复计算 */
14
25
  private _globalColStyles?;
15
26
  connectedCallback(): void;
16
27
  setColumns(columns: Column[]): void;
17
28
  setData(data: any[]): void;
29
+ setDefaultSort(sortInfo: SortOption): void;
30
+ changeFixed(params?: ChangeFixedParams): void;
18
31
  static get observedAttributes(): string[];
19
32
  attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
20
33
  render(): HTMLElement;
21
- rerender(): void;
22
- private _updateStripe;
34
+ rerender(partial: "head" | "body" | "all"): void;
35
+ private _changeCssVar;
36
+ private _changeMaxHeight;
37
+ private _classAttrChannge;
38
+ private _updateFixedHead;
23
39
  private _headRender;
24
40
  private _rendHeadRow;
25
41
  private _headColRender;
@@ -28,8 +44,8 @@ export default class Table extends BaseComponent {
28
44
  /**
29
45
  * 解析列配置,表头跨行跨列、固定列
30
46
  * @param columns 列配置
31
- * @param fixedLeft 左边固定列
32
- * @param fixedRight 右边固定列
47
+ * @param leftOffset 左边固定列偏移
48
+ * @param rightOffset 右边固定列偏移
33
49
  * @returns
34
50
  */
35
51
  private _parseColumns;
@@ -44,3 +60,4 @@ export default class Table extends BaseComponent {
44
60
  afterInit(): void;
45
61
  beforeDestroy(): void;
46
62
  }
63
+ export {};
@@ -1,159 +1,216 @@
1
1
  import c from "../base.js";
2
- import { kebabToCamel as f, parseAttrValue as b } from "../utils/index.js";
3
- import { $$ as o, $one as p, iterate as g, formatStyle as _, shouldEventNext as u, on as C, off as y } from "ph-utils/dom";
4
- import { random as x } from "ph-utils";
5
- const R = ":host{--l-table-td-padding: 10px;--l-table-th-padding: var(--l-table-td-padding);display:inline-block;width:100%;overflow:auto;font-size:14px}.l-table{width:100%;border-collapse:collapse;border-spacing:0}.l-table th{padding:var(--l-table-th-padding);border-bottom:1px solid #e6e6e6}.l-table td{padding:var(--l-table-td-padding);border-bottom:1px solid #e6e6e6}.l-table thead tr,.l-table tfoot tr{text-align:left;background-color:#f2f2f2}.l-table tr{background-color:#fff}.l-table tr:hover{background-color:#f2f2f2}.l-table__empty-col{color:#999;text-align:center}.l-table-stripe tr:nth-child(2n){background-color:#fafafa}.l-table-stripe tr:nth-child(2n):hover{background-color:#f2f2f2}";
6
- class T extends c {
2
+ import { kebabToCamel as b, parseAttrValue as x } from "../utils/index.js";
3
+ import { $one as h, $$ as o, iterate as g, formatStyle as p, shouldEventNext as y, on as C, off as u } from "ph-utils/dom";
4
+ import { random as _ } from "ph-utils";
5
+ const m = ":host{--l-table-max-height: 100%;--l-table-td-padding: 10px;--l-table-th-padding: var(--l-table-td-padding);--l-table-layout: auto;display:inline-block;width:100%;max-height:var(--l-table-max-height);overflow:auto;font-size:14px}.l-table{width:100%;border-collapse:collapse;border-spacing:0;table-layout:var(--l-table-layout)}.l-table th,.l-table td{padding:var(--l-table-th-padding);border-bottom:1px solid #e6e6e6}.l-table th{text-align:left;background-color:#f2f2f2}.l-table td{background-color:#fff;transition:background-color .3s}.l-table tr:hover td{background-color:#f2f2f2}.l-table__empty-col{color:#999;text-align:center}.l-table-stripe tr:nth-child(2n) td{background-color:#fafafa}.l-table-stripe tr:nth-child(2n):hover td{background-color:#f2f2f2}.l-table-border th,.l-table-border td{border:1px solid #e6e6e6}.l-table-fixed{--l-table-layout: fixed}.l-table-fixed .l-fixed{position:-webkit-sticky;position:sticky;z-index:1;box-sizing:border-box}.l-table-fixed thead.l-fixed,.l-table-fixed tfoot.l-fixed{z-index:2}";
6
+ class S extends c {
7
7
  static baseName = "table";
8
8
  /** 斑马纹 */
9
9
  stripe = !0;
10
+ /** 是否显示四周边框 */
11
+ border = !1;
12
+ /** 是否固定表头 */
13
+ fixedHead = !1;
14
+ /** 是否固定列,在进行列解析时,会自动确认该属性 */
15
+ fixedColumn = !1;
16
+ /** 最大高度 */
17
+ maxHeight;
18
+ /** 表格布局 */
19
+ tableLayout;
10
20
  columns = [];
11
21
  data = [];
12
- /** 左边固定列, 格式: [列key, 宽度] */
13
- _fixedLeft = [];
14
- /** 右边固定列, 格式: [列key, 宽度] */
15
- _fixedRight = [];
22
+ sortInfo;
16
23
  /** 缓存列通用样式, 避免渲染数据时,重复计算 */
17
24
  _globalColStyles;
18
25
  connectedCallback() {
19
- this.loadStyleText(R), super.connectedCallback();
26
+ this.loadStyleText(m), super.connectedCallback();
20
27
  }
21
- setColumns(t) {
22
- this._fixedLeft = [], this._fixedRight = [], this.columns = this._parseColumns(
23
- t,
24
- this._fixedLeft,
25
- this._fixedRight
26
- ), this.rerender();
28
+ setColumns(e) {
29
+ let i = 0, t = 0;
30
+ this.columns = this._parseColumns(e, i, t), this.rerender("all");
31
+ }
32
+ setData(e) {
33
+ this.data = e, this.columns && this.columns.length > 0 && this.rerender("body");
34
+ }
35
+ setDefaultSort(e) {
36
+ this.sortInfo = e, this.rerender("all");
27
37
  }
28
- setData(t) {
29
- this.data = t, this.columns && this.columns.length > 0 && this.rerender();
38
+ changeFixed(e) {
39
+ const i = {
40
+ fixedHead: this.fixedHead,
41
+ fixedColumn: this.fixedColumn,
42
+ ...e
43
+ };
44
+ if (this.fixedHead = i.fixedHead, this.fixedColumn = i.fixedColumn, this.rendered) {
45
+ const t = h(".l-table", this.root);
46
+ t && (this.fixedHead || this.fixedColumn ? t.classList.add("l-table-fixed") : t.classList.remove("l-table-fixed"));
47
+ }
30
48
  }
31
49
  static get observedAttributes() {
32
- return ["stripe"];
33
- }
34
- attributeChangedCallback(t, i, l) {
35
- t = f(t);
36
- const s = b(
37
- l,
38
- this[t],
39
- t
50
+ return ["stripe", "border", "fixed-head", "max-height", "table-layout"];
51
+ }
52
+ attributeChangedCallback(e, i, t) {
53
+ e = b(e);
54
+ const s = x(
55
+ t,
56
+ this[e],
57
+ e
40
58
  );
41
- if (s !== this[t])
42
- switch (this[t] = s, t) {
59
+ if (s !== this[e])
60
+ switch (this[e] = s, e) {
43
61
  case "stripe":
44
- this._updateStripe();
62
+ this._classAttrChannge("stripe", s);
63
+ break;
64
+ case "border":
65
+ this._classAttrChannge("border", s);
66
+ break;
67
+ case "fixedHead":
68
+ this._updateFixedHead(), this.changeFixed();
69
+ break;
70
+ case "maxHeight":
71
+ this._changeMaxHeight();
72
+ break;
73
+ case "tableLayout":
74
+ this._changeCssVar("table-layout", s);
45
75
  break;
46
76
  }
47
77
  }
48
78
  render() {
49
- const t = o("table", {
50
- class: ["l-table", this.stripe ? "l-table-stripe" : ""]
79
+ const e = o("table", {
80
+ class: [
81
+ "l-table",
82
+ this.stripe ? "l-table-stripe" : "",
83
+ this.border ? "l-table-border" : "",
84
+ this.fixedHead || this.fixedColumn ? "l-table-fixed" : ""
85
+ ]
51
86
  });
52
- return t.appendChild(this._headRender()), t.appendChild(this._bodyRender()), t;
87
+ return e.appendChild(this._headRender()), e.appendChild(this._bodyRender()), e;
53
88
  }
54
- rerender() {
89
+ rerender(e) {
55
90
  if (this.rendered) {
56
- const t = p("thead", this.root);
57
- t && t.replaceWith(this._headRender());
58
- const i = p("tbody", this.root);
59
- i && i.replaceWith(this._bodyRender());
91
+ if (e === "all" || e === "head") {
92
+ const i = h("thead", this.root);
93
+ i && i.replaceWith(this._headRender());
94
+ }
95
+ if (e === "all" || e === "body") {
96
+ const i = h("tbody", this.root);
97
+ i && i.replaceWith(this._bodyRender());
98
+ }
60
99
  }
61
100
  }
62
- _updateStripe() {
101
+ _changeCssVar(e, i) {
102
+ if (!this.rendered) return;
103
+ const t = `--l-table-${e}`;
104
+ i ? this.style.setProperty(t, i) : this.style.removeProperty(t);
105
+ }
106
+ _changeMaxHeight() {
107
+ let e = this.maxHeight;
108
+ e && typeof e == "number" && (e = `${e}px`), this._changeCssVar("max-height", e);
109
+ }
110
+ _classAttrChannge(e, i) {
111
+ if (this.rendered) {
112
+ const t = h("table", this.root);
113
+ t && t.classList.toggle(`l-table-${e}`, i);
114
+ }
115
+ }
116
+ _updateFixedHead() {
63
117
  if (this.rendered) {
64
- const t = p("table", this.root);
65
- t && (this.stripe ? t.classList.add("l-table-stripe") : t.classList.remove("l-table-stripe"));
118
+ const e = h("thead", this.root);
119
+ e && (e.classList.toggle("l-fixed", this.fixedHead), e.style.top = this.fixedHead ? "0" : "");
66
120
  }
67
121
  }
68
122
  _headRender() {
69
- const t = o("thead");
70
- return this.columns && this._rendHeadRow(t, this.columns), t;
123
+ const e = o("thead", {
124
+ class: {
125
+ "l-fixed": this.fixedHead
126
+ },
127
+ style: {
128
+ top: this.fixedHead ? "0" : void 0
129
+ }
130
+ });
131
+ return this.columns && this._rendHeadRow(e, this.columns), e;
71
132
  }
72
- _rendHeadRow(t, i) {
73
- const l = o("tr");
133
+ _rendHeadRow(e, i) {
134
+ const t = o("tr");
74
135
  for (let s = 0, a = i.length; s < a; s++) {
75
- const d = i[s];
76
- l.appendChild(this._headColRender(d, s)), d.children && this._rendHeadRow(t, d.children);
136
+ const r = i[s];
137
+ t.appendChild(this._headColRender(r, s)), r.children && this._rendHeadRow(e, r.children);
77
138
  }
78
- t.appendChild(l);
139
+ e.appendChild(t);
79
140
  }
80
- _headColRender(t, i) {
81
- const l = o("th");
82
- if (t.titleColspan && (l.colSpan = t.titleColspan), t.titleRowspan && (l.rowSpan = t.titleRowspan), l.appendChild(
141
+ _headColRender(e, i) {
142
+ const t = o("th");
143
+ if (e.titleColspan && e.titleColspan > 1 && (t.colSpan = e.titleColspan), e.titleRowspan && e.titleRowspan > 1 && (t.rowSpan = e.titleRowspan), t.style.cssText = this._getColumnStyle(e, "th"), e.fixed && t.classList.add("l-fixed"), t.appendChild(
83
144
  o("span", {
84
- textContent: t.title
145
+ textContent: e.title
85
146
  })
86
- ), t.sorter) {
147
+ ), e.sorter) {
87
148
  const s = o("span", { class: "caret-wrapper" });
88
- s.appendChild(o("span", { class: "sort-caret ascending" })), s.appendChild(o("span", { class: "sort-caret descending" })), l.appendChild(s);
149
+ s.appendChild(o("span", { class: "sort-caret ascending" })), s.appendChild(o("span", { class: "sort-caret descending" })), t.appendChild(s);
89
150
  }
90
- return l;
151
+ return t;
91
152
  }
92
153
  _bodyRender() {
93
- const t = o("tbody");
154
+ const e = o("tbody");
94
155
  if (this.data && this.data.length > 0)
95
- for (let i = 0, l = this.data.length; i < l; i++) {
156
+ for (let i = 0, t = this.data.length; i < t; i++) {
96
157
  const s = this.data[i];
97
158
  if (this.columns) {
98
159
  const a = o("tr");
99
- this._bodyRowRender(this.columns, i, s, a), t.appendChild(a);
160
+ this._bodyRowRender(this.columns, i, s, a), e.appendChild(a);
100
161
  }
101
162
  }
102
163
  else {
103
- const i = o("tr"), l = o("td", {
164
+ const i = o("tr"), t = o("td", {
104
165
  class: "l-table__empty-col",
105
166
  textContent: "暂无数据"
106
167
  });
107
- this.columns && (l.colSpan = this.columns.length), i.appendChild(l), t.appendChild(i);
168
+ this.columns && (t.colSpan = this.columns.length), i.appendChild(t), e.appendChild(i);
108
169
  }
109
- return t;
170
+ return e;
110
171
  }
111
- _bodyRowRender(t, i, l, s) {
112
- for (let a = 0, d = t.length; a < d; a++) {
113
- const e = t[a];
114
- if (e.children && e.children.length > 0)
115
- this._bodyRowRender(e.children, i, l, s);
172
+ _bodyRowRender(e, i, t, s) {
173
+ for (let a = 0, r = e.length; a < r; a++) {
174
+ const l = e[a];
175
+ if (l.children && l.children.length > 0)
176
+ this._bodyRowRender(l.children, i, t, s);
116
177
  else {
117
- const n = o("td");
118
- if (typeof e.rowspan == "number" && (n.rowSpan = e.rowspan), typeof e.rowspan == "function" && (n.rowSpan = e.rowspan(l, i)), typeof e.colspan == "number" && (n.colSpan = e.colspan), typeof e.colspan == "function" && (n.colSpan = e.colspan(l, i)), e.fixed && (n.className = "l-fixed"), n.style.cssText = this._getColumnStyle(
119
- e,
120
- this._fixedLeft,
121
- this._fixedRight
122
- ), e.render) {
123
- const r = e.render(l, i);
124
- typeof r == "string" ? n.innerHTML = r : Array.isArray(r) ? g(r, (h) => {
125
- n.appendChild(h);
126
- }) : n.appendChild(r);
178
+ const d = o("td");
179
+ if (typeof l.rowspan == "number" && (d.rowSpan = l.rowspan), typeof l.rowspan == "function" && (d.rowSpan = l.rowspan(t, i)), typeof l.colspan == "number" && (d.colSpan = l.colspan), typeof l.colspan == "function" && (d.colSpan = l.colspan(t, i)), l.fixed && (d.className = "l-fixed"), d.style.cssText = this._getColumnStyle(l), l.render) {
180
+ const n = l.render(t, i);
181
+ typeof n == "string" ? d.innerHTML = n : Array.isArray(n) ? g(n, (f) => {
182
+ d.appendChild(f);
183
+ }) : d.appendChild(n);
127
184
  } else
128
- n.textContent = e.key ? l[e.key] : "";
129
- s.appendChild(n);
185
+ d.textContent = l.key ? t[l.key] : "";
186
+ s.appendChild(d);
130
187
  }
131
188
  }
132
189
  }
133
190
  /**
134
191
  * 解析列配置,表头跨行跨列、固定列
135
192
  * @param columns 列配置
136
- * @param fixedLeft 左边固定列
137
- * @param fixedRight 右边固定列
193
+ * @param leftOffset 左边固定列偏移
194
+ * @param rightOffset 右边固定列偏移
138
195
  * @returns
139
196
  */
140
- _parseColumns(t, i, l) {
197
+ _parseColumns(e, i, t) {
141
198
  const s = [];
142
- for (let a = 0, d = t.length; a < d; a++) {
143
- const e = t[a];
144
- if (e.id || (e.id = e.key || e.title), e.id || (e.id = `${a}_${x(6)}`), e.fixed) {
145
- const n = Number.parseFloat(`${e.width || 0}`);
146
- e.fixed === "left" ? i.push([e.id, n]) : e.fixed === "right" && l.push([e.id, n]);
199
+ for (let a = 0, r = e.length; a < r; a++) {
200
+ const l = e[a];
201
+ if (l.id || (l.id = l.key || l.title), l.id || (l.id = `${a}_${_(6)}`), l.fixed) {
202
+ const d = Number.parseFloat(`${l.width || 0}`);
203
+ l.fixed === "left" ? (l.left = i, i += d) : l.fixed === "right" && (l.right = t, t += d);
147
204
  }
148
- if (e.children) {
149
- const n = this._parseColumns(
150
- e.children,
205
+ if (l.children) {
206
+ const d = this._parseColumns(
207
+ l.children,
151
208
  i,
152
- l
209
+ t
153
210
  );
154
- e.titleRowspan = e.titleRowspan || 1, e.titleColspan || (e.titleColspan = n.reduce((r, h) => r + (h.titleColspan || 1), 0)), s.push({ ...e, children: n });
211
+ l.titleRowspan = l.titleRowspan || 1, l.titleColspan || (l.titleColspan = d.reduce((n, f) => n + (f.titleColspan || 1), 0)), s.push({ ...l, children: d });
155
212
  } else
156
- e.titleRowspan = e.titleRowspan || this._getMaxDepth(t), e.titleColspan = e.titleColspan || 1, s.push({ ...e });
213
+ l.titleRowspan = l.titleRowspan || this._getMaxDepth(e), l.titleColspan = l.titleColspan || 1, s.push({ ...l });
157
214
  }
158
215
  return s;
159
216
  }
@@ -162,26 +219,29 @@ class T extends c {
162
219
  * @param headers 表头配置
163
220
  * @returns 最大深度, 最大跨行数
164
221
  */
165
- _getMaxDepth(t) {
222
+ _getMaxDepth(e) {
166
223
  let i = 1;
167
- for (const l of t)
168
- l.children && (i = Math.max(i, this._getMaxDepth(l.children) + 1));
224
+ for (const t of e)
225
+ t.children && (i = Math.max(i, this._getMaxDepth(t.children) + 1));
169
226
  return i;
170
227
  }
171
- _getColumnStyle(t, i, l) {
172
- const s = t.id;
173
- if (this._globalColStyles && s in this._globalColStyles)
174
- return this._globalColStyles[s];
175
- const a = { ...t.style };
176
- t.width && (typeof t.width == "number" ? a.width = `${t.width}px` : a.width = t.width), this._globalColStyles || (this._globalColStyles = {});
177
- const d = _(a);
178
- return this._globalColStyles[s] = d, d;
179
- }
180
- _handleTap = (t) => {
181
- const [i, l, s] = u(
182
- t,
228
+ _getColumnStyle(e, i = "td") {
229
+ const t = e.id;
230
+ if (this._globalColStyles && t in this._globalColStyles)
231
+ return this._globalColStyles[t][i];
232
+ const s = {};
233
+ e.width && (typeof e.width == "number" ? s.width = `${e.width}px` : s.width = e.width), e.fixed && (e.fixed === "left" ? (s.left = `${e.left}px`, s["box-shadow"] = "-4px 0 4px -4px #d9d9d9 inset") : e.fixed === "right" && (s.right = `${e.right}px`, s["box-shadow"] = "4px 0 4px -4px #d9d9d9 inset")), this._globalColStyles || (this._globalColStyles = {});
234
+ const a = p(s), r = {
235
+ th: a,
236
+ td: a + p(e.style || "")
237
+ };
238
+ return this._globalColStyles[t] = r, r[i];
239
+ }
240
+ _handleTap = (e) => {
241
+ const [i, t, s] = y(
242
+ e,
183
243
  "data-action",
184
- t.currentTarget
244
+ e.currentTarget
185
245
  );
186
246
  if (i) {
187
247
  const a = s.dataset;
@@ -189,12 +249,12 @@ class T extends c {
189
249
  }
190
250
  };
191
251
  afterInit() {
192
- C(this.root, "click", this._handleTap);
252
+ this._changeMaxHeight(), C(this.root, "click", this._handleTap);
193
253
  }
194
254
  beforeDestroy() {
195
- y(this.root, "click", this._handleTap);
255
+ u(this.root, "click", this._handleTap);
196
256
  }
197
257
  }
198
258
  export {
199
- T as default
259
+ S as default
200
260
  };
@@ -9,6 +9,10 @@ export interface Column {
9
9
  width?: number | string;
10
10
  /** 是否固定列, left - 固定在左方, right - 固定右方 */
11
11
  fixed?: "left" | "right";
12
+ /** 列固定左时, 左边偏移量 */
13
+ left?: number;
14
+ /** 列固定右时, 右边偏移量 */
15
+ right?: number;
12
16
  /** 多级表头 */
13
17
  children?: Column[];
14
18
  /** 表头跨行 */
@@ -16,7 +20,7 @@ export interface Column {
16
20
  /** 表头跨列 */
17
21
  titleColspan?: number;
18
22
  /** 列是否支持排序 */
19
- sorter?: boolean;
23
+ sorter?: boolean | "default" | ((a: any, b: any) => number);
20
24
  /** 列的样式 */
21
25
  style?: Record<string, string | null | undefined>;
22
26
  /** td colspan */
@@ -26,3 +30,7 @@ export interface Column {
26
30
  /** 单元格内容渲染函数 */
27
31
  render?: (rowData: any, rowIndex: number) => HTMLElement | DocumentFragment | HTMLElement[] | string;
28
32
  }
33
+ export interface SortOption {
34
+ key: string;
35
+ order: "asc" | "desc";
36
+ }
package/lib/tag/index.js CHANGED
@@ -66,7 +66,10 @@ class x extends s {
66
66
  o || this.classList.add(`l-tag--${this.type}`);
67
67
  }
68
68
  _toggleColorStyle() {
69
- this.rendered && (c(this.color) ? (this.style.removeProperty("--l-tag-color"), this.style.removeProperty("--l-tag-border-color"), this.style.removeProperty("--l-tag-background")) : (this.style.setProperty("--l-tag-color", this.color), this.style.setProperty("--l-tag-border-color", this.color), this.style.setProperty("--l-tag-background", n(this.color, 5, !0))));
69
+ this.rendered && (c(this.color) ? (this.style.removeProperty("--l-tag-color"), this.style.removeProperty("--l-tag-border-color"), this.style.removeProperty("--l-tag-background")) : (this.style.setProperty("--l-tag-color", this.color), this.style.setProperty("--l-tag-border-color", this.color), this.style.setProperty(
70
+ "--l-tag-background",
71
+ n(this.color, 5, !0)
72
+ )));
70
73
  }
71
74
  beforeDestroy() {
72
75
  h(this.root, "click", this.#t);
package/package.json CHANGED
@@ -1,71 +1,71 @@
1
- {
2
- "name": "litos-ui",
3
- "description": "基于 Web Component 的 UI 组件库",
4
- "version": "0.15.7",
5
- "type": "module",
6
- "devDependencies": {
7
- "@eslint/js": "^9.34.0",
8
- "@eslint/markdown": "^7.2.0",
9
- "@types/node": "^24.3.0",
10
- "eslint": "^9.34.0",
11
- "globals": "^16.3.0",
12
- "less": "^4.4.1",
13
- "lightningcss": "^1.30.1",
14
- "prettier": "^3.6.2",
15
- "typescript": "^5.9.2",
16
- "typescript-eslint": "^8.41.0",
17
- "vite": "^7.1.3",
18
- "vite-plugin-dts": "^4.5.4",
19
- "vitepress": "^1.6.4"
20
- },
21
- "files": [
22
- "lib",
23
- "styles"
24
- ],
25
- "main": "./lib/index.js",
26
- "module": "./lib/index.js",
27
- "types": "./lib/index.d.ts",
28
- "jsdelivr": "./lib/litos-ui.min.js",
29
- "unpkg": "./lib/litos-ui.min.js",
30
- "exports": {
31
- "./styles/*": "./styles/*",
32
- "./lib/*": "./lib/*",
33
- ".": {
34
- "import": "./lib/index.js",
35
- "types": "./lib/index.d.ts",
36
- "require": "./lib/index.js"
37
- }
38
- },
39
- "repository": {
40
- "type": "git",
41
- "url": "git+https://github.com/DvShu/litos-ui.git"
42
- },
43
- "keywords": [
44
- "litos-ui",
45
- "web component",
46
- "ui framework",
47
- "component library"
48
- ],
49
- "homepage": "https://dvshu.github.io/litos-ui/",
50
- "bugs": {
51
- "url": "https://github.com/DvShu/litos-ui/issues"
52
- },
53
- "license": "MIT",
54
- "dependencies": {
55
- "iconify-icon": "^3.0.0",
56
- "ph-utils": "^0.16.2",
57
- "qrcode-generator-es": "^1.1.4",
58
- "shiki": "^3.12.0"
59
- },
60
- "scripts": {
61
- "dev": "vite dev",
62
- "build": "vite build",
63
- "docs:dev": "vitepress dev docs --force --host 0.0.0.0",
64
- "docs:build": "vitepress build docs",
65
- "docs:preview": "vitepress preview docs",
66
- "inspect:eslint": "eslint --inspect-config",
67
- "create": "node scripts/index.js create",
68
- "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
69
- "lib:build": "pnpm build && pnpm dts:build"
70
- }
71
- }
1
+ {
2
+ "name": "litos-ui",
3
+ "description": "基于 Web Component 的 UI 组件库",
4
+ "version": "0.15.8",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "vite dev",
8
+ "build": "vite build",
9
+ "docs:dev": "vitepress dev docs --force --host 0.0.0.0",
10
+ "docs:build": "vitepress build docs",
11
+ "docs:preview": "vitepress preview docs",
12
+ "inspect:eslint": "eslint --inspect-config",
13
+ "create": "node scripts/index.js create",
14
+ "dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
15
+ "lib:build": "pnpm build && pnpm dts:build"
16
+ },
17
+ "devDependencies": {
18
+ "@eslint/js": "^9.34.0",
19
+ "@eslint/markdown": "^7.2.0",
20
+ "@types/node": "^24.3.0",
21
+ "eslint": "^9.34.0",
22
+ "globals": "^16.3.0",
23
+ "less": "^4.4.1",
24
+ "lightningcss": "^1.30.1",
25
+ "prettier": "^3.6.2",
26
+ "typescript": "^5.9.2",
27
+ "typescript-eslint": "^8.41.0",
28
+ "vite": "^7.1.3",
29
+ "vite-plugin-dts": "^4.5.4",
30
+ "vitepress": "^1.6.4"
31
+ },
32
+ "files": [
33
+ "lib",
34
+ "styles"
35
+ ],
36
+ "main": "./lib/index.js",
37
+ "module": "./lib/index.js",
38
+ "types": "./lib/index.d.ts",
39
+ "jsdelivr": "./lib/litos-ui.min.js",
40
+ "unpkg": "./lib/litos-ui.min.js",
41
+ "exports": {
42
+ "./styles/*": "./styles/*",
43
+ "./lib/*": "./lib/*",
44
+ ".": {
45
+ "import": "./lib/index.js",
46
+ "types": "./lib/index.d.ts",
47
+ "require": "./lib/index.js"
48
+ }
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "git+https://github.com/DvShu/litos-ui.git"
53
+ },
54
+ "keywords": [
55
+ "litos-ui",
56
+ "web component",
57
+ "ui framework",
58
+ "component library"
59
+ ],
60
+ "homepage": "https://dvshu.github.io/litos-ui/",
61
+ "bugs": {
62
+ "url": "https://github.com/DvShu/litos-ui/issues"
63
+ },
64
+ "license": "MIT",
65
+ "dependencies": {
66
+ "iconify-icon": "^3.0.0",
67
+ "ph-utils": "^0.16.2",
68
+ "qrcode-generator-es": "^1.1.4",
69
+ "shiki": "^3.12.0"
70
+ }
71
+ }
package/lib/menu/base.js DELETED
@@ -1 +0,0 @@
1
-