litos-ui 0.7.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 (81) hide show
  1. package/lib/{animation-QfX4RtqD.js → animation-DttknHkX.js} +2 -2
  2. package/lib/base.d.ts +1 -3
  3. package/lib/base.js +26 -58
  4. package/lib/button/index.js +58 -62
  5. package/lib/color_picker/index.js +18 -20
  6. package/lib/form/form_events.js +15 -17
  7. package/lib/form/form_inner.js +43 -47
  8. package/lib/form/form_item.d.ts +1 -1
  9. package/lib/form/form_item.js +49 -53
  10. package/lib/form/index.d.ts +1 -1
  11. package/lib/form/index.js +58 -61
  12. package/lib/icon/arrow_down.js +4 -7
  13. package/lib/icon/arrow_left.js +4 -7
  14. package/lib/icon/arrow_right.js +4 -7
  15. package/lib/icon/arrow_up.js +4 -7
  16. package/lib/icon/base.js +21 -24
  17. package/lib/icon/caret_bottom.js +4 -7
  18. package/lib/icon/caret_top.js +4 -7
  19. package/lib/icon/font_icon.js +13 -17
  20. package/lib/icon/info.js +4 -7
  21. package/lib/icon/loading.js +4 -7
  22. package/lib/icon/mask_close.js +4 -7
  23. package/lib/icon/moon.js +4 -7
  24. package/lib/icon/reduction.js +4 -7
  25. package/lib/icon/refresh_left.js +4 -7
  26. package/lib/icon/refresh_right.js +4 -7
  27. package/lib/icon/search.js +4 -7
  28. package/lib/icon/sort.js +4 -7
  29. package/lib/icon/success.js +4 -7
  30. package/lib/icon/sun.js +4 -7
  31. package/lib/icon/theme_default.js +4 -7
  32. package/lib/icon/warn.js +4 -7
  33. package/lib/{index-B_9rPBWp.js → index-391POYEJ.js} +1 -1
  34. package/lib/index.d.ts +2 -10
  35. package/lib/index.js +62 -70
  36. package/lib/input/index.d.ts +1 -1
  37. package/lib/input/index.js +66 -70
  38. package/lib/list/index.d.ts +1 -1
  39. package/lib/list/index.js +26 -30
  40. package/lib/litos-ui.css +1 -1
  41. package/lib/litos-ui.min.js +1 -1
  42. package/lib/message/index.js +35 -33
  43. package/lib/polygon/index.d.ts +1 -1
  44. package/lib/polygon/index.js +14 -17
  45. package/lib/popconfirm/index.js +11 -17
  46. package/lib/popover/index.js +115 -120
  47. package/lib/radio/index.d.ts +2 -2
  48. package/lib/radio/index.js +65 -68
  49. package/lib/select_ori/index.d.ts +1 -1
  50. package/lib/select_ori/index.js +25 -29
  51. package/lib/switch/index.js +39 -48
  52. package/lib/tabbar/index.js +115 -123
  53. package/lib/theme/index.js +71 -74
  54. package/lib/theme/theme_color.js +17 -27
  55. package/lib/utils/event.js +16 -18
  56. package/lib/utils/index.js +48 -51
  57. package/lib/utils/transition.js +24 -34
  58. package/package.json +4 -1
  59. package/lib/browser.d.ts +0 -17
  60. package/lib/button/regist.d.ts +0 -2
  61. package/lib/button/regist.js +0 -7
  62. package/lib/form/types.js +0 -1
  63. package/lib/index-116dRdDj.js +0 -4
  64. package/lib/index-BUyxD_nH.js +0 -4
  65. package/lib/index-BeOxuMd4.js +0 -4
  66. package/lib/index-Bl8lRTJd.js +0 -4
  67. package/lib/index-BxlGVrX3.js +0 -4
  68. package/lib/index-C2D4YsFw.js +0 -4
  69. package/lib/index-C98Kx857.js +0 -4
  70. package/lib/index-CCcVpk6U.js +0 -4
  71. package/lib/index-CMz7GCCH.js +0 -4
  72. package/lib/index-D-Ikkdx0.js +0 -4
  73. package/lib/index-DJ70Xyma.js +0 -4
  74. package/lib/index-DKvzJmsR.js +0 -4
  75. package/lib/index-oNjb_IVt.js +0 -4
  76. package/lib/popconfirm/regist.d.ts +0 -2
  77. package/lib/popconfirm/regist.js +0 -7
  78. package/lib/popover/regist.d.ts +0 -2
  79. package/lib/popover/regist.js +0 -7
  80. package/lib/tabbar/regist.d.ts +0 -2
  81. package/lib/tabbar/regist.js +0 -7
@@ -1,138 +1,129 @@
1
- var L = Object.defineProperty;
2
- var A = (n) => {
3
- throw TypeError(n);
4
- };
5
- var N = (n, a, e) => a in n ? L(n, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[a] = e;
6
- var f = (n, a, e) => N(n, typeof a != "symbol" ? a + "" : a, e), w = (n, a, e) => a.has(n) || A("Cannot " + e);
7
- var k = (n, a, e) => a.has(n) ? A("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(n) : a.set(n, e);
8
- var u = (n, a, e) => (w(n, a, "access private method"), e);
9
- import { isBlank as g, isNumeric as T } from "ph-utils";
10
- import W from "../base.js";
11
- import { initAttr as E, parseAttrValue as C } from "../utils/index.js";
12
- import { addClass as v, removeClass as $, $one as l, create as b, $ as x, iterate as j, on as S, off as B, isVisible as D, formatStyle as I, formatClass as M } from "ph-utils/dom";
13
- function R(n, a, e) {
14
- let t = n.target, i = "";
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 = "";
15
8
  do
16
- if (e && e.isSameNode(t) || t.tagName === "BODY" || (t.getAttribute && (i = t.getAttribute(a) || ""), i === "" && (t = t.parentNode), !t)) break;
17
- while (i === "");
18
- return [i !== "__stop__" && i !== "", i, t];
9
+ if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (a = e.getAttribute(r) || ""), a === "" && (e = e.parentNode), !e)) break;
10
+ while (a === "");
11
+ return [a !== "__stop__" && a !== "", a, e];
19
12
  }
20
- var p, y, _;
21
- class F extends W {
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;
22
25
  constructor() {
23
- super();
24
- k(this, p);
25
- /**
26
- * 标签类型:
27
- * 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
28
- * 2. bar - 选项卡
29
- * 3. card - 卡片
30
- */
31
- f(this, "type", "nav");
32
- f(this, "name");
33
- f(this, "gap");
34
- f(this, "$line");
35
- f(this, "_handleClick", (e) => {
36
- const [t, i] = R(e, "l-name", this.root);
37
- t && i !== this.name && (this.name = i, this.dispatchEvent(
38
- new CustomEvent("change", {
39
- detail: {
40
- name: i
41
- }
42
- })
43
- ), this._updateActive(), this._updateLine());
44
- });
45
- E(this);
26
+ super(), x(this);
46
27
  }
47
28
  connectedCallback() {
48
- this.loadStyle(["tabbar"]), 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();
49
30
  }
50
31
  static get observedAttributes() {
51
32
  return ["name", "type", "justify-content", "gap"];
52
33
  }
53
- attributeChangedCallback(e, t, i) {
54
- if (e === "name") {
55
- const s = C(i, void 0);
56
- this.name = s, this._updateActive(), this._updateLine();
57
- } else if (e === "type") {
58
- const s = C(i, "nav");
59
- if (s !== this.type && ($(this, `l-tabbar--${this.type}`), this.type = s, $(this, `l-tabbar--${s}`), s === "card")) {
60
- let r = l(".l-tabbar-card-border", this.root);
61
- r || (r = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(r));
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));
62
43
  }
63
44
  } else {
64
- const s = C(i, void 0);
65
- this[e] = s;
66
- const r = l(".l-tabbar-wrapper", this.root);
67
- r && (r.style.cssText = u(this, p, y).call(this)), e === "gap" && (!g(this.gap) && !this.gap.startsWith("0") ? v(this, "l-tabbar-gap") : $(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"));
68
49
  }
69
50
  }
70
51
  disconnectedCallback() {
71
52
  super.disconnectedCallback(), this._destroy();
72
53
  }
73
54
  render() {
74
- const e = document.createDocumentFragment(), t = document.createElement("div");
75
- if (t.className = "l-tabbar-wrapper", t.style.cssText = u(this, p, y).call(this), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
76
- const s = document.createElement("slot");
77
- t.appendChild(s);
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);
78
59
  } else {
79
- const s = x("[l-name]", this);
80
- s.length > 0 && j(s, (r) => {
81
- const h = r.getAttribute("l-name");
82
- if (h) {
83
- const o = r.cloneNode(!0);
84
- o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), h === this.name && o.classList.add("active");
85
- const d = l("[l-icon]", o), c = x(":not([l-icon])", o);
86
- if (d) {
87
- const m = b("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", {
88
69
  class: [
89
70
  "l-tabbar-item-icon",
90
- c.length === 0 ? "only" : void 0
71
+ s.length === 0 ? "only" : void 0
91
72
  ]
92
73
  });
93
- m.appendChild(d.cloneNode(!0)), d.replaceWith(m);
74
+ d.appendChild(n.cloneNode(!0)), n.replaceWith(d);
94
75
  }
95
76
  t.appendChild(o);
96
77
  }
97
78
  });
98
79
  }
99
- if (e.appendChild(t), this.type === "card") {
100
- const s = b("div", { class: "l-tabbar-card-border" });
101
- e.appendChild(s);
80
+ if (r.appendChild(t), this.type === "card") {
81
+ const a = b("div", { class: "l-tabbar-card-border" });
82
+ r.appendChild(a);
102
83
  }
103
- return e;
84
+ return r;
104
85
  }
105
86
  /**
106
87
  * 设置选项卡栏的项目列表。
107
88
  * @param items - 选项卡栏项目的数组。
108
89
  * 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
109
90
  */
110
- setItems(e) {
91
+ setItems(r) {
111
92
  const t = l(".l-tabbar-wrapper", this.root);
112
- t && (t.innerHTML = "", t.appendChild(u(this, p, _).call(this, e)));
93
+ t && (t.innerHTML = "", t.appendChild(this.#e(r)));
113
94
  }
114
95
  /**
115
96
  * 向标签栏添加项目。
116
97
  * @param items 要添加的标签栏项目数组。
117
98
  * @returns 无返回值。
118
99
  */
119
- addItems(e) {
100
+ addItems(r) {
120
101
  const t = l(".l-tabbar-wrapper", this.root);
121
- t && t.appendChild(u(this, p, _).call(this, e));
102
+ t && t.appendChild(this.#e(r));
122
103
  }
123
104
  _init() {
124
- S(this.root, "click", this._handleClick), setTimeout(() => {
105
+ C(this.root, "click", this._handleClick), setTimeout(() => {
125
106
  this._updateLine();
126
107
  }, 300);
127
108
  }
128
109
  _destroy() {
129
- B(this.root, "click", this._handleClick), this.$line = void 0;
110
+ k(this.root, "click", this._handleClick), this.$line = void 0;
130
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
+ };
131
122
  _updateActive() {
132
- const t = this.getAttr("custom-content", !1) ? this : this.root, i = l(".active", t);
133
- i && $(i, "active");
134
- const s = l(`[l-name="${this.name}"]`, t);
135
- s && v(s, "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");
136
127
  }
137
128
  /**
138
129
  * 初始化线条的方法,在微任务队列中执行。
@@ -141,53 +132,54 @@ class F extends W {
141
132
  _updateLine() {
142
133
  queueMicrotask(() => {
143
134
  if (!this.name || this.type === "nav" || !this.rendered) return;
144
- const e = this.getAttr("custom-content", !1), t = l(".active", e ? this : this.root);
135
+ const r = this.getAttr("custom-content", !1), t = l(".active", r ? this : this.root);
145
136
  if (!t) return;
146
- const i = t.offsetLeft;
137
+ const e = t.offsetLeft;
147
138
  if (!this.$line) {
148
- const s = b("div", { class: "l-tabbar--bar-line" });
149
- s.part = "line", this.root.appendChild(s), this.$line = l(".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);
150
141
  }
151
- this.$line.style.cssText = `width:${t.offsetWidth}px;left:${i}px`, D(t, this) || this.scrollTo({
152
- left: i,
142
+ this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, w(t, this) || this.scrollTo({
143
+ left: e,
153
144
  behavior: "smooth"
154
145
  });
155
146
  });
156
147
  }
157
- }
158
- p = new WeakSet(), y = function() {
159
- const e = {}, t = this.getAttr("justify-content");
160
- if (g(t) || (e["justify-content"] = t), !g(this.gap)) {
161
- let i = this.gap;
162
- T(i, { isPositive: !0 }) && (i = `${i}px`), e["--l-tabbar-item-gap"] = i;
163
- }
164
- return I(e);
165
- }, _ = function(e) {
166
- const t = document.createDocumentFragment();
167
- for (let i = 0, s = e.length; i < s; i++) {
168
- const r = e[i], h = b("div", {
169
- class: M([
170
- "l-tabbar-item",
171
- this.name === r.name ? "active" : void 0
172
- ]),
173
- "l-name": r.name,
174
- part: "item"
175
- }), o = r.icon;
176
- if (o) {
177
- const c = b("div", { class: "l-tabbar-item-icon" });
178
- let m = typeof o == "string" ? o : o();
179
- typeof m == "string" ? c.innerHTML = m : c.appendChild(m), h.appendChild(c);
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;
180
153
  }
181
- const d = r.text;
182
- if (d) {
183
- let c = typeof d == "string" ? d : d();
184
- typeof c == "string" ? h.appendChild(b(c)) : h.appendChild(c);
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);
185
178
  }
186
- t.appendChild(h);
179
+ return t;
187
180
  }
188
- return t;
189
- }, f(F, "baseName", "tabbar");
181
+ }
190
182
  export {
191
- F as default,
192
- R as shouldEventNext
183
+ S as default,
184
+ N as shouldEventNext
193
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 r = (e, n, t) => E(e, typeof n != "symbol" ? n + "" : n, t), m = (e, n, t) => n.has(e) || b("Cannot " + t);
7
- var o = (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, s) => (m(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), h = (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 f, off as k } from "ph-utils/dom";
11
- import { getTheme as L, applyTheme as j } from "ph-utils/theme";
12
- const A = [
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, $, v, y, g, w, c, T, x;
18
- class B 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
- r(this, "type", "button");
23
- r(this, "label", "text");
24
- r(this, "theme");
25
- u(this, l);
26
- u(this, c, async (t) => {
27
- let s;
28
- if (this.type === "button")
29
- s = this.theme === "dark" ? "auto" : "dark";
30
- else {
31
- const a = t.target.value;
32
- this.type !== "switch" ? s = a : s = a ? "dark" : "light";
33
- }
34
- await j(s), this.theme = s, this.type === "button" && h(this, i, v).call(this, o(this, l)), this.dispatchEvent(new CustomEvent("change", { detail: s }));
35
- });
36
- R(this), this.theme = L();
17
+ super(), c(this), this.theme = h();
37
18
  }
38
19
  connectedCallback() {
39
- this.loadStyle(["theme"]), super.connectedCallback(), h(this, i, T).call(this);
20
+ this.loadStyleText(u), super.connectedCallback(), this.#c();
40
21
  }
41
22
  disconnectedCallback() {
42
- super.disconnectedCallback(), h(this, i, x).call(this);
23
+ super.disconnectedCallback(), this.#r();
43
24
  }
44
25
  render() {
45
26
  switch (this.type) {
46
27
  case "select":
47
- return h(this, i, y).call(this);
28
+ return this.#o();
48
29
  case "radio":
49
- return h(this, i, w).call(this);
30
+ return this.#l();
50
31
  case "switch":
51
- return h(this, i, g).call(this);
32
+ return this.#s();
52
33
  default:
53
- return h(this, i, $).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(), $ = function() {
58
- const t = d("l-button", {
59
- class: "l-theme-btn l-theme-inner"
60
- });
61
- return h(this, i, v).call(this, t), t;
62
- }, v = function(t) {
63
- const s = this.theme === "auto" ? "sun" : "moon";
64
- t.innerHTML = `<l-${s}-icon></l-${s}-icon>`;
65
- }, y = function() {
66
- const t = d("l-select-ori", {
67
- class: "l-theme-inner"
68
- });
69
- t.value = this.theme;
70
- const s = [
71
- '<option value="auto">跟随系统</option>',
72
- '<option value="light">浅色模式</option>',
73
- '<option value="dark">深色模式</option>'
74
- ];
75
- return t.innerHTML = s.join(""), t;
76
- }, g = 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
- }, w = function() {
82
- const t = d("l-radio", {
83
- class: "l-theme-inner"
84
- });
85
- t.value = this.theme, t.type = "button";
86
- const s = A.map((a) => this.label === "icon" ? `<${a.icon} radio-value="${a.value}"></${a.icon}>` : `<span radio-value="${a.value}">${a.text}</span>`);
87
- return t.innerHTML = s.join(""), t;
88
- }, c = new WeakMap(), T = function() {
89
- p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ? f(o(this, l), "click", o(this, c)) : f(o(this, l), "change", o(this, c));
90
- }, x = function() {
91
- o(this, l) && (this.type === "button" ? k(o(this, l), "click", o(this, c)) : k(o(this, l), "change", o(this, c)), p(this, l, void 0));
92
- }, r(B, "baseName", "theme");
93
90
  export {
94
- B 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
  };
@@ -1,24 +1,22 @@
1
- let i;
2
- function w(f, t, o) {
3
- i == null && (i = /* @__PURE__ */ new Map()), i.has(f) || i.set(f, /* @__PURE__ */ new Map([[t, /* @__PURE__ */ new Set()]])), i.get(f).has(t) || i.get(f).set(t, /* @__PURE__ */ new Set()), i.get(f).get(t).add(o);
1
+ let e;
2
+ function s(t, i, f) {
3
+ e == null && (e = /* @__PURE__ */ new Map()), e.has(t) || e.set(t, /* @__PURE__ */ new Map([[i, /* @__PURE__ */ new Set()]])), e.get(t).has(i) || e.get(t).set(i, /* @__PURE__ */ new Set()), e.get(t).get(i).add(f);
4
4
  }
5
- function z(f, t, o) {
6
- var g, d, e, l, u, r;
7
- (d = (g = i == null ? void 0 : i.get(f)) == null ? void 0 : g.get(t)) == null || d.delete(o), ((l = (e = i == null ? void 0 : i.get(f)) == null ? void 0 : e.get(t)) == null ? void 0 : l.size) == 0 && ((u = i.get(f)) == null || u.delete(t)), ((r = i == null ? void 0 : i.get(f)) == null ? void 0 : r.size) == 0 && i.delete(f), (i == null ? void 0 : i.size) == 0 && (i = void 0);
5
+ function d(t, i, f) {
6
+ e?.get(t)?.get(i)?.delete(f), e?.get(t)?.get(i)?.size == 0 && e.get(t)?.delete(i), e?.get(t)?.size == 0 && e.delete(t), e?.size == 0 && (e = void 0);
8
7
  }
9
- function p(f) {
10
- f == null ? i != null && (i.clear(), i = void 0) : i != null && (i.delete(f), i.size === 0 && (i = void 0));
8
+ function l(t) {
9
+ t == null ? e != null && (e.clear(), e = void 0) : e != null && (e.delete(t), e.size === 0 && (e = void 0));
11
10
  }
12
- function m(f, t, ...o) {
13
- var d;
14
- const g = (d = i == null ? void 0 : i.get(f)) == null ? void 0 : d.get(t);
15
- if (g != null)
16
- for (const e of g)
17
- e(...o);
11
+ function u(t, i, ...f) {
12
+ const o = e?.get(t)?.get(i);
13
+ if (o != null)
14
+ for (const g of o)
15
+ g(...f);
18
16
  }
19
17
  export {
20
- w as add,
21
- p as clear,
22
- m as emit,
23
- z as remove
18
+ s as add,
19
+ l as clear,
20
+ u as emit,
21
+ d as remove
24
22
  };