litos-ui 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/base.js +26 -30
  2. package/lib/button/index.js +55 -59
  3. package/lib/color_picker/index.js +17 -21
  4. package/lib/form/form_events.js +15 -17
  5. package/lib/form/form_inner.js +43 -47
  6. package/lib/form/form_item.js +49 -54
  7. package/lib/form/index.js +62 -66
  8. package/lib/icon/arrow_down.js +4 -7
  9. package/lib/icon/arrow_left.js +4 -7
  10. package/lib/icon/arrow_right.js +4 -7
  11. package/lib/icon/arrow_up.js +4 -7
  12. package/lib/icon/base.js +21 -25
  13. package/lib/icon/caret_bottom.js +4 -7
  14. package/lib/icon/caret_top.js +4 -7
  15. package/lib/icon/font_icon.js +13 -17
  16. package/lib/icon/info.js +4 -7
  17. package/lib/icon/loading.js +4 -7
  18. package/lib/icon/mask_close.js +4 -7
  19. package/lib/icon/moon.js +4 -7
  20. package/lib/icon/reduction.js +4 -7
  21. package/lib/icon/refresh_left.js +4 -7
  22. package/lib/icon/refresh_right.js +4 -7
  23. package/lib/icon/search.js +4 -7
  24. package/lib/icon/sort.js +4 -7
  25. package/lib/icon/success.js +4 -7
  26. package/lib/icon/sun.js +4 -7
  27. package/lib/icon/theme_default.js +4 -7
  28. package/lib/icon/warn.js +4 -7
  29. package/lib/input/index.js +66 -71
  30. package/lib/list/index.js +23 -27
  31. package/lib/polygon/index.js +14 -18
  32. package/lib/popconfirm/index.js +11 -14
  33. package/lib/popover/index.js +107 -113
  34. package/lib/radio/index.js +53 -57
  35. package/lib/select_ori/index.js +23 -27
  36. package/lib/switch/index.js +34 -44
  37. package/lib/tabbar/index.js +117 -126
  38. package/lib/theme/index.js +71 -74
  39. package/lib/theme/theme_color.js +17 -27
  40. package/lib/utils/event.js +16 -18
  41. package/lib/utils/transition.js +23 -27
  42. package/package.json +1 -1
@@ -1,65 +1,55 @@
1
- var x = Object.defineProperty;
2
- var u = (e) => {
3
- throw TypeError(e);
4
- };
5
- var w = (e, i, t) => i in e ? x(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
6
- var o = (e, i, t) => w(e, typeof i != "symbol" ? i + "" : i, t), p = (e, i, t) => i.has(e) || u("Cannot " + t);
7
- var r = (e, i, t) => (p(e, i, "read from private field"), t ? t.call(e) : i.get(e)), d = (e, i, t) => i.has(e) ? u("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(e) : i.set(e, t);
8
- var l = (e, i, t) => (p(e, i, "access private method"), t);
9
- import { on as k, off as v, addClass as b, removeClass as g, $one as n } from "ph-utils/dom";
10
- import m from "../form/form_inner.js";
11
- import { initAttr as T, parseAttrValue as y } from "../utils/index.js";
12
- const C = ":host{display:inline-flex}:host{--l-switch-height: 22px;--l-switch-width: 40px;display:inline-flex;box-sizing:border-box;width:var(--l-switch-width);height:var(--l-switch-height);align-items:center;justify-content:flex-start;background-color:#dcdfe6;border-radius:calc(var(--l-switch-height) / 2);padding:2px;position:relative;cursor:pointer;transition:all .3s ease-in-out;vertical-align:middle;border:1px solid #c2c2c2}:host(:hover),:host(.l-switch--checked):hover{border-color:var(--l-primary-color, #722ed1)}:host(.l-switch--checked){background-color:var(--l-primary-color, #722ed1);border-color:var(--l-primary-color, #722ed1)}.l-switch-action{position:absolute;width:calc(var(--l-switch-height) - 6px);top:2px;left:2px;bottom:2px;background-color:#fff;border-radius:50%;transition:all .3s ease-in-out;display:flex;justify-content:center;align-items:center;padding:2px;font-size:12px;box-sizing:border-box}.l-switch-text{color:#fff;padding-left:calc(var(--l-switch-width) - 20px);transition:padding-left .3s ease-in-out}:host(.l-switch--checked) .l-switch-action{left:calc(var(--l-switch-width) - var(--l-switch-height) + 3px)}:host(.l-switch--checked) .l-switch-text{padding-left:5px}";
13
- var h, c, a;
14
- class L extends m {
1
+ import { on as c, off as h, addClass as o, removeClass as l, $one as i } from "ph-utils/dom";
2
+ import n from "../form/form_inner.js";
3
+ import { initAttr as a, parseAttrValue as r } from "../utils/index.js";
4
+ const d = ":host{display:inline-flex}:host{--l-switch-height: 22px;--l-switch-width: 40px;display:inline-flex;box-sizing:border-box;width:var(--l-switch-width);height:var(--l-switch-height);align-items:center;justify-content:flex-start;background-color:#dcdfe6;border-radius:calc(var(--l-switch-height) / 2);padding:2px;position:relative;cursor:pointer;transition:all .3s ease-in-out;vertical-align:middle;border:1px solid #c2c2c2}:host(:hover),:host(.l-switch--checked):hover{border-color:var(--l-primary-color, #722ed1)}:host(.l-switch--checked){background-color:var(--l-primary-color, #722ed1);border-color:var(--l-primary-color, #722ed1)}.l-switch-action{position:absolute;width:calc(var(--l-switch-height) - 6px);top:2px;left:2px;bottom:2px;background-color:#fff;border-radius:50%;transition:all .3s ease-in-out;display:flex;justify-content:center;align-items:center;padding:2px;font-size:12px;box-sizing:border-box}.l-switch-text{color:#fff;padding-left:calc(var(--l-switch-width) - 20px);transition:padding-left .3s ease-in-out}:host(.l-switch--checked) .l-switch-action{left:calc(var(--l-switch-width) - var(--l-switch-height) + 3px)}:host(.l-switch--checked) .l-switch-text{padding-left:5px}";
5
+ class w extends n {
6
+ static baseName = "switch";
7
+ actionRender;
8
+ checkedText;
9
+ uncheckedText;
15
10
  constructor() {
16
- super(!1);
17
- d(this, c);
18
- o(this, "actionRender");
19
- o(this, "checkedText");
20
- o(this, "uncheckedText");
21
- d(this, h, (t) => {
22
- this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
23
- });
24
- T(this);
25
- const t = this.value ? y(this.value, !1, "value") : !1;
11
+ super(!1), a(this);
12
+ const t = this.value ? r(this.value, !1, "value") : !1;
26
13
  this._resetValue = t, this.value = t;
27
14
  }
28
15
  connectedCallback() {
29
- this.loadStyleText(C), super.connectedCallback(), this.pushValueChange(), l(this, c, a).call(this), k(this, "click", r(this, h));
16
+ this.loadStyleText(d), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
30
17
  }
31
18
  disconnectedCallback() {
32
- super.disconnectedCallback(), v(this, "click", r(this, h)), this.actionRender = void 0;
19
+ super.disconnectedCallback(), h(this, "click", this.#e), this.actionRender = void 0;
33
20
  }
34
21
  render() {
35
22
  this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
36
23
  const t = ['<div class="l-switch-action" part="action"></div>'];
37
24
  if (this.checkedText || this.uncheckedText) {
38
- const s = this.value ? this.checkedText || "" : this.uncheckedText || "";
39
- t.push(`<span class="l-switch-text">${s}</span>`);
25
+ const e = this.value ? this.checkedText || "" : this.uncheckedText || "";
26
+ t.push(`<span class="l-switch-text">${e}</span>`);
40
27
  }
41
28
  return t.join("");
42
29
  }
30
+ #e = (t) => {
31
+ this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
32
+ };
43
33
  setValue(t) {
44
- super.setValue(t), t ? b(this, "l-switch--checked") : g(this, "l-switch--checked");
45
- const s = n(".l-switch-text", this.root);
46
- s && (s.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), l(this, c, a).call(this);
34
+ super.setValue(t), t ? o(this, "l-switch--checked") : l(this, "l-switch--checked");
35
+ const e = i(".l-switch-text", this.root);
36
+ e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
47
37
  }
48
38
  setActionRender(t) {
49
- this.actionRender = t, l(this, c, a).call(this);
39
+ this.actionRender = t, this.#t();
40
+ }
41
+ #t() {
42
+ const t = i(".l-switch-action", this.root);
43
+ if (t)
44
+ if (this.actionRender) {
45
+ const e = this.actionRender({ checked: this.value });
46
+ typeof e == "string" ? t.innerHTML = e : t.innerHTML = e.outerHTML;
47
+ } else {
48
+ const e = i('[slot="checked-action"]', this), s = i('[slot="unchecked-action"]', this);
49
+ this.value && e ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && s && (t.innerHTML = '<slot name="unchecked-action"></slot>');
50
+ }
50
51
  }
51
52
  }
52
- h = new WeakMap(), c = new WeakSet(), a = function() {
53
- const t = n(".l-switch-action", this.root);
54
- if (t)
55
- if (this.actionRender) {
56
- const s = this.actionRender({ checked: this.value });
57
- typeof s == "string" ? t.innerHTML = s : t.innerHTML = s.outerHTML;
58
- } else {
59
- const s = n('[slot="checked-action"]', this), f = n('[slot="unchecked-action"]', this);
60
- this.value && s ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && f && (t.innerHTML = '<slot name="unchecked-action"></slot>');
61
- }
62
- }, o(L, "baseName", "switch");
63
53
  export {
64
- L as default
54
+ w as default
65
55
  };
@@ -1,139 +1,129 @@
1
- var A = Object.defineProperty;
2
- var k = (o) => {
3
- throw TypeError(o);
4
- };
5
- var L = (o, i, e) => i in o ? A(o, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[i] = e;
6
- var h = (o, i, e) => L(o, typeof i != "symbol" ? i + "" : i, e), N = (o, i, e) => i.has(o) || k("Cannot " + e);
7
- var w = (o, i, e) => i.has(o) ? k("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(o) : i.set(o, e);
8
- var u = (o, i, e) => (N(o, i, "access private method"), e);
9
- import { isBlank as g, isNumeric as T } from "ph-utils";
10
- import j from "../base.js";
11
- import { initAttr as W, parseAttrValue as x } from "../utils/index.js";
12
- import { addClass as v, removeClass as y, $one as c, create as f, $ as _, iterate as E, on as S, off as z, isVisible as B, formatStyle as D, formatClass as I } from "ph-utils/dom";
13
- const M = ":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:block}.l-tabbar-wrapper{display:flex;flex-wrap:nowrap;height:100%;align-items:stretch;gap:var(--l-tabbar-item-gap)}.l-tabbar-item{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center}.l-tabbar-item:hover{color:var(--l-tabbar-hover-color)}.l-tabbar-item.active{color:var(--l-tabbar-active-color)}.l-tabbar-item-icon{font-size:18px;margin-bottom:5px;display:flex;justify-content:center;align-items:center}.l-tabbar-item-icon.only{font-size:24px;margin-bottom:0}:host(.l-tabbar--nav){--l-tabbar-height: 50px;width:100%}:host(.l-tabbar--nav) .l-tabbar-item{flex-grow:1;display:inline-flex;flex-direction:column;justify-content:center;align-items:center;font-size:12px;line-height:1}: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)}:host(.l-tabbar--card) .l-tabbar-item{padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-tabbar--card) .l-tabbar-item:first-child{border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item:last-child{border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar-gap) .l-tabbar-item{border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item.active{background:#fff}";
14
- function R(o, i, e) {
15
- let t = o.target, a = "";
1
+ import { isBlank as p, isNumeric as v } from "ph-utils";
2
+ import y from "../base.js";
3
+ import { initAttr as x, parseAttrValue as m } from "../utils/index.js";
4
+ import { addClass as h, removeClass as f, $one as l, create as b, $ as g, iterate as $, on as C, off as k, isVisible as w, formatStyle as _, formatClass as A } from "ph-utils/dom";
5
+ const L = ":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:block}.l-tabbar-wrapper{display:flex;flex-wrap:nowrap;height:100%;align-items:stretch;gap:var(--l-tabbar-item-gap)}.l-tabbar-item{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center}.l-tabbar-item:hover{color:var(--l-tabbar-hover-color)}.l-tabbar-item.active{color:var(--l-tabbar-active-color)}.l-tabbar-item-icon{font-size:18px;margin-bottom:5px;display:flex;justify-content:center;align-items:center}.l-tabbar-item-icon.only{font-size:24px;margin-bottom:0}:host(.l-tabbar--nav){--l-tabbar-height: 50px;width:100%}:host(.l-tabbar--nav) .l-tabbar-item{flex-grow:1;display:inline-flex;flex-direction:column;justify-content:center;align-items:center;font-size:12px;line-height:1}: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)}:host(.l-tabbar--card) .l-tabbar-item{padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-tabbar--card) .l-tabbar-item:first-child{border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item:last-child{border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar-gap) .l-tabbar-item{border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item.active{background:#fff}";
6
+ function N(u, r, t) {
7
+ let e = u.target, a = "";
16
8
  do
17
- if (e && e.isSameNode(t) || t.tagName === "BODY" || (t.getAttribute && (a = t.getAttribute(i) || ""), a === "" && (t = t.parentNode), !t)) break;
9
+ if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (a = e.getAttribute(r) || ""), a === "" && (e = e.parentNode), !e)) break;
18
10
  while (a === "");
19
- return [a !== "__stop__" && a !== "", a, t];
11
+ return [a !== "__stop__" && a !== "", a, e];
20
12
  }
21
- var d, $, C;
22
- class F extends j {
13
+ class S extends y {
14
+ static baseName = "tabbar";
15
+ /**
16
+ * 标签类型:
17
+ * 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
18
+ * 2. bar - 选项卡
19
+ * 3. card - 卡片
20
+ */
21
+ type = "nav";
22
+ name;
23
+ gap;
24
+ $line;
23
25
  constructor() {
24
- super();
25
- w(this, d);
26
- /**
27
- * 标签类型:
28
- * 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
29
- * 2. bar - 选项卡
30
- * 3. card - 卡片
31
- */
32
- h(this, "type", "nav");
33
- h(this, "name");
34
- h(this, "gap");
35
- h(this, "$line");
36
- h(this, "_handleClick", (e) => {
37
- const [t, a] = R(e, "l-name", this.root);
38
- t && a !== this.name && (this.name = a, this.dispatchEvent(
39
- new CustomEvent("change", {
40
- detail: {
41
- name: a
42
- }
43
- })
44
- ), this._updateActive(), this._updateLine());
45
- });
46
- W(this);
26
+ super(), x(this);
47
27
  }
48
28
  connectedCallback() {
49
- this.loadStyleText(M), v(this, `l-tabbar--${this.type}`), !g(this.gap) && !this.gap.startsWith("0") && v(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
29
+ this.loadStyleText(L), h(this, `l-tabbar--${this.type}`), !p(this.gap) && !this.gap.startsWith("0") && h(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
50
30
  }
51
31
  static get observedAttributes() {
52
32
  return ["name", "type", "justify-content", "gap"];
53
33
  }
54
- attributeChangedCallback(e, t, a) {
55
- if (e === "name") {
56
- const r = x(a, void 0);
57
- this.name = r, this._updateActive(), this._updateLine();
58
- } else if (e === "type") {
59
- const r = x(a, "nav");
60
- if (r !== this.type && (y(this, `l-tabbar--${this.type}`), this.type = r, y(this, `l-tabbar--${r}`), r === "card")) {
61
- let s = c(".l-tabbar-card-border", this.root);
62
- s || (s = f("div", { class: "l-tabbar-card-border" }), this.root.appendChild(s));
34
+ attributeChangedCallback(r, t, e) {
35
+ if (r === "name") {
36
+ const a = m(e, void 0);
37
+ this.name = a, this._updateActive(), this._updateLine();
38
+ } else if (r === "type") {
39
+ const a = m(e, "nav");
40
+ if (a !== this.type && (f(this, `l-tabbar--${this.type}`), this.type = a, f(this, `l-tabbar--${a}`), a === "card")) {
41
+ let i = l(".l-tabbar-card-border", this.root);
42
+ i || (i = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(i));
63
43
  }
64
44
  } else {
65
- const r = x(a, void 0);
66
- this[e] = r;
67
- const s = c(".l-tabbar-wrapper", this.root);
68
- s && (s.style.cssText = u(this, d, $).call(this)), e === "gap" && (!g(this.gap) && !this.gap.startsWith("0") ? v(this, "l-tabbar-gap") : y(this, "l-tabbar-gap"));
45
+ const a = m(e, void 0);
46
+ this[r] = a;
47
+ const i = l(".l-tabbar-wrapper", this.root);
48
+ i && (i.style.cssText = this.#t()), r === "gap" && (!p(this.gap) && !this.gap.startsWith("0") ? h(this, "l-tabbar-gap") : f(this, "l-tabbar-gap"));
69
49
  }
70
50
  }
71
51
  disconnectedCallback() {
72
52
  super.disconnectedCallback(), this._destroy();
73
53
  }
74
54
  render() {
75
- const e = document.createDocumentFragment(), t = document.createElement("div");
76
- if (t.className = "l-tabbar-wrapper", t.style.cssText = u(this, d, $).call(this), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
77
- const r = document.createElement("slot");
78
- t.appendChild(r);
55
+ const r = document.createDocumentFragment(), t = document.createElement("div");
56
+ if (t.className = "l-tabbar-wrapper", t.style.cssText = this.#t(), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
57
+ const a = document.createElement("slot");
58
+ t.appendChild(a);
79
59
  } else {
80
- const r = _("[l-name]", this);
81
- r.length > 0 && E(r, (s) => {
82
- const p = s.getAttribute("l-name");
83
- if (p) {
84
- const l = s.cloneNode(!0);
85
- l.classList.add("l-tabbar-item"), l.setAttribute("part", "item"), p === this.name && l.classList.add("active");
86
- const b = c("[l-icon]", l), n = _(":not([l-icon])", l);
87
- if (b) {
88
- const m = f("div", {
60
+ const a = g("[l-name]", this);
61
+ a.length > 0 && $(a, (i) => {
62
+ const c = i.getAttribute("l-name");
63
+ if (c) {
64
+ const o = i.cloneNode(!0);
65
+ o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), c === this.name && o.classList.add("active");
66
+ const n = l("[l-icon]", o), s = g(":not([l-icon])", o);
67
+ if (n) {
68
+ const d = b("div", {
89
69
  class: [
90
70
  "l-tabbar-item-icon",
91
- n.length === 0 ? "only" : void 0
71
+ s.length === 0 ? "only" : void 0
92
72
  ]
93
73
  });
94
- m.appendChild(b.cloneNode(!0)), b.replaceWith(m);
74
+ d.appendChild(n.cloneNode(!0)), n.replaceWith(d);
95
75
  }
96
- t.appendChild(l);
76
+ t.appendChild(o);
97
77
  }
98
78
  });
99
79
  }
100
- if (e.appendChild(t), this.type === "card") {
101
- const r = f("div", { class: "l-tabbar-card-border" });
102
- e.appendChild(r);
80
+ if (r.appendChild(t), this.type === "card") {
81
+ const a = b("div", { class: "l-tabbar-card-border" });
82
+ r.appendChild(a);
103
83
  }
104
- return e;
84
+ return r;
105
85
  }
106
86
  /**
107
87
  * 设置选项卡栏的项目列表。
108
88
  * @param items - 选项卡栏项目的数组。
109
89
  * 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
110
90
  */
111
- setItems(e) {
112
- const t = c(".l-tabbar-wrapper", this.root);
113
- t && (t.innerHTML = "", t.appendChild(u(this, d, C).call(this, e)));
91
+ setItems(r) {
92
+ const t = l(".l-tabbar-wrapper", this.root);
93
+ t && (t.innerHTML = "", t.appendChild(this.#e(r)));
114
94
  }
115
95
  /**
116
96
  * 向标签栏添加项目。
117
97
  * @param items 要添加的标签栏项目数组。
118
98
  * @returns 无返回值。
119
99
  */
120
- addItems(e) {
121
- const t = c(".l-tabbar-wrapper", this.root);
122
- t && t.appendChild(u(this, d, C).call(this, e));
100
+ addItems(r) {
101
+ const t = l(".l-tabbar-wrapper", this.root);
102
+ t && t.appendChild(this.#e(r));
123
103
  }
124
104
  _init() {
125
- S(this.root, "click", this._handleClick), setTimeout(() => {
105
+ C(this.root, "click", this._handleClick), setTimeout(() => {
126
106
  this._updateLine();
127
107
  }, 300);
128
108
  }
129
109
  _destroy() {
130
- z(this.root, "click", this._handleClick), this.$line = void 0;
110
+ k(this.root, "click", this._handleClick), this.$line = void 0;
131
111
  }
112
+ _handleClick = (r) => {
113
+ const [t, e] = N(r, "l-name", this.root);
114
+ t && e !== this.name && (this.name = e, this.dispatchEvent(
115
+ new CustomEvent("change", {
116
+ detail: {
117
+ name: e
118
+ }
119
+ })
120
+ ), this._updateActive(), this._updateLine());
121
+ };
132
122
  _updateActive() {
133
- const t = this.getAttr("custom-content", !1) ? this : this.root, a = c(".active", t);
134
- a && y(a, "active");
135
- const r = c(`[l-name="${this.name}"]`, t);
136
- r && v(r, "active");
123
+ const t = this.getAttr("custom-content", !1) ? this : this.root, e = l(".active", t);
124
+ e && f(e, "active");
125
+ const a = l(`[l-name="${this.name}"]`, t);
126
+ a && h(a, "active");
137
127
  }
138
128
  /**
139
129
  * 初始化线条的方法,在微任务队列中执行。
@@ -142,53 +132,54 @@ class F extends j {
142
132
  _updateLine() {
143
133
  queueMicrotask(() => {
144
134
  if (!this.name || this.type === "nav" || !this.rendered) return;
145
- const e = this.getAttr("custom-content", !1), t = c(".active", e ? this : this.root);
135
+ const r = this.getAttr("custom-content", !1), t = l(".active", r ? this : this.root);
146
136
  if (!t) return;
147
- const a = t.offsetLeft;
137
+ const e = t.offsetLeft;
148
138
  if (!this.$line) {
149
- const r = f("div", { class: "l-tabbar--bar-line" });
150
- r.part = "line", this.root.appendChild(r), this.$line = c(".l-tabbar--bar-line", this.root);
139
+ const a = b("div", { class: "l-tabbar--bar-line" });
140
+ a.part = "line", this.root.appendChild(a), this.$line = l(".l-tabbar--bar-line", this.root);
151
141
  }
152
- this.$line.style.cssText = `width:${t.offsetWidth}px;left:${a}px`, B(t, this) || this.scrollTo({
153
- left: a,
142
+ this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, w(t, this) || this.scrollTo({
143
+ left: e,
154
144
  behavior: "smooth"
155
145
  });
156
146
  });
157
147
  }
158
- }
159
- d = new WeakSet(), $ = function() {
160
- const e = {}, t = this.getAttr("justify-content");
161
- if (g(t) || (e["justify-content"] = t), !g(this.gap)) {
162
- let a = this.gap;
163
- T(a, { isPositive: !0 }) && (a = `${a}px`), e["--l-tabbar-item-gap"] = a;
164
- }
165
- return D(e);
166
- }, C = function(e) {
167
- const t = document.createDocumentFragment();
168
- for (let a = 0, r = e.length; a < r; a++) {
169
- const s = e[a], p = f("div", {
170
- class: I([
171
- "l-tabbar-item",
172
- this.name === s.name ? "active" : void 0
173
- ]),
174
- "l-name": s.name,
175
- part: "item"
176
- }), l = s.icon;
177
- if (l) {
178
- const n = f("div", { class: "l-tabbar-item-icon" });
179
- let m = typeof l == "string" ? l : l();
180
- typeof m == "string" ? n.innerHTML = m : n.appendChild(m), p.appendChild(n);
148
+ #t() {
149
+ const r = {}, t = this.getAttr("justify-content");
150
+ if (p(t) || (r["justify-content"] = t), !p(this.gap)) {
151
+ let e = this.gap;
152
+ v(e, { isPositive: !0 }) && (e = `${e}px`), r["--l-tabbar-item-gap"] = e;
181
153
  }
182
- const b = s.text;
183
- if (b) {
184
- let n = typeof b == "string" ? b : b();
185
- typeof n == "string" ? p.appendChild(f(n)) : p.appendChild(n);
154
+ return _(r);
155
+ }
156
+ #e(r) {
157
+ const t = document.createDocumentFragment();
158
+ for (let e = 0, a = r.length; e < a; e++) {
159
+ const i = r[e], c = b("div", {
160
+ class: A([
161
+ "l-tabbar-item",
162
+ this.name === i.name ? "active" : void 0
163
+ ]),
164
+ "l-name": i.name,
165
+ part: "item"
166
+ }), o = i.icon;
167
+ if (o) {
168
+ const s = b("div", { class: "l-tabbar-item-icon" });
169
+ let d = typeof o == "string" ? o : o();
170
+ typeof d == "string" ? s.innerHTML = d : s.appendChild(d), c.appendChild(s);
171
+ }
172
+ const n = i.text;
173
+ if (n) {
174
+ let s = typeof n == "string" ? n : n();
175
+ typeof s == "string" ? c.appendChild(b(s)) : c.appendChild(s);
176
+ }
177
+ t.appendChild(c);
186
178
  }
187
- t.appendChild(p);
179
+ return t;
188
180
  }
189
- return t;
190
- }, h(F, "baseName", "tabbar");
181
+ }
191
182
  export {
192
- F as default,
193
- R as shouldEventNext
183
+ S as default,
184
+ N as shouldEventNext
194
185
  };
@@ -1,95 +1,92 @@
1
- var C = Object.defineProperty;
2
- var b = (e) => {
3
- throw TypeError(e);
4
- };
5
- var E = (e, n, t) => n in e ? C(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
6
- var a = (e, n, t) => E(e, typeof n != "symbol" ? n + "" : n, t), m = (e, n, t) => n.has(e) || b("Cannot " + t);
7
- var s = (e, n, t) => (m(e, n, "read from private field"), t ? t.call(e) : n.get(e)), u = (e, n, t) => n.has(e) ? b("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), p = (e, n, t, o) => (m(e, n, "write to private field"), o ? o.call(e, t) : n.set(e, t), t), c = (e, n, t) => (m(e, n, "access private method"), t);
8
- import M from "../base.js";
9
- import { initAttr as R } from "../utils/index.js";
10
- import { create as d, $one as H, on as v, off as k } from "ph-utils/dom";
11
- import { getTheme as L, applyTheme as j } from "ph-utils/theme";
12
- const A = ":host{display:inline-flex}.l-theme-btn::part(default){--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-text-color: #9ca3af;--l-btn-hover-text-color: #666666;width:var(--l-form-edit-height, 32px);padding:0;font-size:18px}.l-theme-switch.l-switch--checked{background-color:#65757129;border-color:#3c3f44}.l-theme-switch.l-switch--checked::part(action){background-color:#000;color:#fff}html.dark .l-theme-btn{--l-btn-hover-text-color: #ffffff}", B = [
1
+ import l from "../base.js";
2
+ import { initAttr as c } from "../utils/index.js";
3
+ import { create as i, $one as r, on as o, off as s } from "ph-utils/dom";
4
+ import { getTheme as h, applyTheme as a } from "ph-utils/theme";
5
+ const u = ":host{display:inline-flex}.l-theme-btn::part(default){--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-text-color: #9ca3af;--l-btn-hover-text-color: #666666;width:var(--l-form-edit-height, 32px);padding:0;font-size:18px}.l-theme-switch.l-switch--checked{background-color:#65757129;border-color:#3c3f44}.l-theme-switch.l-switch--checked::part(action){background-color:#000;color:#fff}html.dark .l-theme-btn{--l-btn-hover-text-color: #ffffff}", d = [
13
6
  { value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
14
7
  { value: "light", text: "浅色模式", icon: "l-sun-icon" },
15
8
  { value: "dark", text: "深色模式", icon: "l-moon-icon" }
16
9
  ];
17
- var l, i, g, f, w, x, $, h, y, T;
18
- class I extends M {
10
+ class k extends l {
11
+ static baseName = "theme";
12
+ type = "button";
13
+ label = "text";
14
+ theme;
15
+ #t;
19
16
  constructor() {
20
- super();
21
- u(this, i);
22
- a(this, "type", "button");
23
- a(this, "label", "text");
24
- a(this, "theme");
25
- u(this, l);
26
- u(this, h, async (t) => {
27
- let o;
28
- if (this.type === "button")
29
- o = this.theme === "dark" ? "auto" : "dark";
30
- else {
31
- const r = t.target.value;
32
- this.type !== "switch" ? o = r : o = r ? "dark" : "light";
33
- }
34
- await j(o), this.theme = o, this.type === "button" && c(this, i, f).call(this, s(this, l)), this.dispatchEvent(new CustomEvent("change", { detail: o }));
35
- });
36
- R(this), this.theme = L();
17
+ super(), c(this), this.theme = h();
37
18
  }
38
19
  connectedCallback() {
39
- this.loadStyleText(A), super.connectedCallback(), c(this, i, y).call(this);
20
+ this.loadStyleText(u), super.connectedCallback(), this.#c();
40
21
  }
41
22
  disconnectedCallback() {
42
- super.disconnectedCallback(), c(this, i, T).call(this);
23
+ super.disconnectedCallback(), this.#r();
43
24
  }
44
25
  render() {
45
26
  switch (this.type) {
46
27
  case "select":
47
- return c(this, i, w).call(this);
28
+ return this.#o();
48
29
  case "radio":
49
- return c(this, i, $).call(this);
30
+ return this.#l();
50
31
  case "switch":
51
- return c(this, i, x).call(this);
32
+ return this.#s();
52
33
  default:
53
- return c(this, i, g).call(this);
34
+ return this.#i();
35
+ }
36
+ }
37
+ #i() {
38
+ const t = i("l-button", {
39
+ class: "l-theme-btn l-theme-inner"
40
+ });
41
+ return this.#n(t), t;
42
+ }
43
+ #n(t) {
44
+ const e = this.theme === "auto" ? "sun" : "moon";
45
+ t.innerHTML = `<l-${e}-icon></l-${e}-icon>`;
46
+ }
47
+ #o() {
48
+ const t = i("l-select-ori", {
49
+ class: "l-theme-inner"
50
+ });
51
+ t.value = this.theme;
52
+ const e = [
53
+ '<option value="auto">跟随系统</option>',
54
+ '<option value="light">浅色模式</option>',
55
+ '<option value="dark">深色模式</option>'
56
+ ];
57
+ return t.innerHTML = e.join(""), t;
58
+ }
59
+ #s() {
60
+ const t = i("l-switch", {
61
+ class: "l-theme-switch l-theme-inner"
62
+ });
63
+ return t.value = this.theme === "dark", t.innerHTML = '<l-sun-icon slot="unchecked-action"></l-sun-icon><l-moon-icon slot="checked-action"></l-moon-icon>', t;
64
+ }
65
+ #l() {
66
+ const t = i("l-radio", {
67
+ class: "l-theme-inner"
68
+ });
69
+ t.value = this.theme, t.type = "button";
70
+ const e = d.map((n) => this.label === "icon" ? `<${n.icon} radio-value="${n.value}"></${n.icon}>` : `<span radio-value="${n.value}">${n.text}</span>`);
71
+ return t.innerHTML = e.join(""), t;
72
+ }
73
+ #e = async (t) => {
74
+ let e;
75
+ if (this.type === "button")
76
+ e = this.theme === "dark" ? "auto" : "dark";
77
+ else {
78
+ const n = t.target.value;
79
+ this.type !== "switch" ? e = n : e = n ? "dark" : "light";
54
80
  }
81
+ await a(e), this.theme = e, this.type === "button" && this.#n(this.#t), this.dispatchEvent(new CustomEvent("change", { detail: e }));
82
+ };
83
+ #c() {
84
+ this.#t = r(".l-theme-inner", this.root), this.type === "button" ? o(this.#t, "click", this.#e) : o(this.#t, "change", this.#e);
85
+ }
86
+ #r() {
87
+ this.#t && (this.type === "button" ? s(this.#t, "click", this.#e) : s(this.#t, "change", this.#e), this.#t = void 0);
55
88
  }
56
89
  }
57
- l = new WeakMap(), i = new WeakSet(), g = function() {
58
- const t = d("l-button", {
59
- class: "l-theme-btn l-theme-inner"
60
- });
61
- return c(this, i, f).call(this, t), t;
62
- }, f = function(t) {
63
- const o = this.theme === "auto" ? "sun" : "moon";
64
- t.innerHTML = `<l-${o}-icon></l-${o}-icon>`;
65
- }, w = function() {
66
- const t = d("l-select-ori", {
67
- class: "l-theme-inner"
68
- });
69
- t.value = this.theme;
70
- const o = [
71
- '<option value="auto">跟随系统</option>',
72
- '<option value="light">浅色模式</option>',
73
- '<option value="dark">深色模式</option>'
74
- ];
75
- return t.innerHTML = o.join(""), t;
76
- }, x = function() {
77
- const t = d("l-switch", {
78
- class: "l-theme-switch l-theme-inner"
79
- });
80
- return t.value = this.theme === "dark", t.innerHTML = '<l-sun-icon slot="unchecked-action"></l-sun-icon><l-moon-icon slot="checked-action"></l-moon-icon>', t;
81
- }, $ = function() {
82
- const t = d("l-radio", {
83
- class: "l-theme-inner"
84
- });
85
- t.value = this.theme, t.type = "button";
86
- const o = B.map((r) => this.label === "icon" ? `<${r.icon} radio-value="${r.value}"></${r.icon}>` : `<span radio-value="${r.value}">${r.text}</span>`);
87
- return t.innerHTML = o.join(""), t;
88
- }, h = new WeakMap(), y = function() {
89
- p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ? v(s(this, l), "click", s(this, h)) : v(s(this, l), "change", s(this, h));
90
- }, T = function() {
91
- s(this, l) && (this.type === "button" ? k(s(this, l), "click", s(this, h)) : k(s(this, l), "change", s(this, h)), p(this, l, void 0));
92
- }, a(I, "baseName", "theme");
93
90
  export {
94
- I as default
91
+ k as default
95
92
  };
@@ -1,28 +1,14 @@
1
- var d = Object.defineProperty;
2
- var s = (o) => {
3
- throw TypeError(o);
4
- };
5
- var u = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
- var a = (o, t, e) => u(o, typeof t != "symbol" ? t + "" : t, e), i = (o, t, e) => t.has(o) || s("Cannot " + e);
7
- var h = (o, t, e) => (i(o, t, "read from private field"), e ? e.call(o) : t.get(o)), l = (o, t, e) => t.has(o) ? s("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e);
8
- var m = (o, t, e) => (i(o, t, "access private method"), e);
9
- import { $one as C, on as k } from "ph-utils/dom";
10
- import f from "../base.js";
11
- import { getColorTheme as g, applyColorTheme as v } from "ph-utils/theme";
12
- var c, p, r;
13
- class E extends f {
1
+ import { $one as t, on as r } from "ph-utils/dom";
2
+ import c from "../base.js";
3
+ import { getColorTheme as n, applyColorTheme as l } from "ph-utils/theme";
4
+ class m extends c {
5
+ static baseName = "theme-color";
6
+ color;
14
7
  constructor() {
15
- super();
16
- l(this, c);
17
- a(this, "color");
18
- l(this, r, async (e) => {
19
- const n = e.detail;
20
- this.color = n, await v(n), this.dispatchEvent(new CustomEvent("change", { detail: n }));
21
- });
22
- this.color = g() || "#722ed1";
8
+ super(), this.color = n() || "#722ed1";
23
9
  }
24
10
  connectedCallback() {
25
- super.connectedCallback(), m(this, c, p).call(this);
11
+ super.connectedCallback(), this.#e();
26
12
  }
27
13
  render() {
28
14
  const e = document.createElement(
@@ -30,11 +16,15 @@ class E extends f {
30
16
  );
31
17
  return e.value = this.color, e;
32
18
  }
19
+ #e() {
20
+ const e = t("l-color-picker", this.root);
21
+ e && r(e, "change", this.#o);
22
+ }
23
+ #o = async (e) => {
24
+ const o = e.detail;
25
+ this.color = o, await l(o), this.dispatchEvent(new CustomEvent("change", { detail: o }));
26
+ };
33
27
  }
34
- c = new WeakSet(), p = function() {
35
- const e = C("l-color-picker", this.root);
36
- e && k(e, "change", h(this, r));
37
- }, r = new WeakMap(), a(E, "baseName", "theme-color");
38
28
  export {
39
- E as default
29
+ m as default
40
30
  };