litos-ui 0.17.5 → 0.18.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 (161) hide show
  1. package/README.md +49 -49
  2. package/lib/animation-CTt9qgA7.js +4 -0
  3. package/lib/base-Dm0WS1pK.js +62 -0
  4. package/lib/base.js +111 -147
  5. package/lib/button/index.d.ts +8 -3
  6. package/lib/button/index.js +2 -137
  7. package/lib/button-CC5PmAb1.js +146 -0
  8. package/lib/calendar/index.d.ts +10 -5
  9. package/lib/calendar/index.js +2 -123
  10. package/lib/calendar-DeP6yZB0.js +149 -0
  11. package/lib/carousel/index.js +2 -280
  12. package/lib/carousel/item.js +2 -15
  13. package/lib/carousel-D4Fe3LEx.js +272 -0
  14. package/lib/check/checkbox.js +2 -18
  15. package/lib/check/checkbox_group.js +6 -6
  16. package/lib/check/radio.js +2 -15
  17. package/lib/check/radio_group.js +9 -9
  18. package/lib/check-B0XraJvb.js +73 -0
  19. package/lib/check-CvGaONEx.js +117 -0
  20. package/lib/checkbox-DbWsmAaL.js +16 -0
  21. package/lib/collapse/index.d.ts +18 -11
  22. package/lib/collapse/index.js +2 -88
  23. package/lib/collapse/item.d.ts +28 -9
  24. package/lib/collapse/item.js +2 -115
  25. package/lib/collapse/types.d.ts +7 -0
  26. package/lib/collapse-CeKRZ-43.js +104 -0
  27. package/lib/color_picker/index.js +2 -42
  28. package/lib/color_picker-D0brKFm-.js +41 -0
  29. package/lib/date_picker/index.d.ts +23 -0
  30. package/lib/date_picker/index.js +3 -0
  31. package/lib/date_picker-DQGoiN8v.js +103 -0
  32. package/lib/date_picker_ori/index.js +2 -129
  33. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  34. package/lib/description_panel/index.js +2 -66
  35. package/lib/description_panel-Df_8rVbX.js +57 -0
  36. package/lib/dialog/dialog_container.js +2 -131
  37. package/lib/dialog/index.js +67 -85
  38. package/lib/dialog_container-DcN87wj0.js +126 -0
  39. package/lib/esm-sVEoAVPu.js +244 -0
  40. package/lib/form/form_item.d.ts +1 -0
  41. package/lib/form/form_item.js +2 -136
  42. package/lib/form/index.js +2 -147
  43. package/lib/form-DdU0yK0k.js +154 -0
  44. package/lib/form_inner-DR9tyB_r.js +117 -0
  45. package/lib/form_item-Bv-YafZK.js +137 -0
  46. package/lib/icon/arrow_down.js +12 -12
  47. package/lib/icon/arrow_left.js +9 -9
  48. package/lib/icon/arrow_right.js +9 -9
  49. package/lib/icon/arrow_up.js +12 -12
  50. package/lib/icon/base.d.ts +16 -2
  51. package/lib/icon/base.js +2 -38
  52. package/lib/icon/calendar.d.ts +5 -0
  53. package/lib/icon/calendar.js +10 -0
  54. package/lib/icon/caret_bottom.js +9 -9
  55. package/lib/icon/caret_top.js +9 -9
  56. package/lib/icon/close.js +9 -9
  57. package/lib/icon/close_filled.js +12 -12
  58. package/lib/icon/d_arrow_left.js +12 -12
  59. package/lib/icon/d_arrow_right.js +12 -12
  60. package/lib/icon/font_icon.d.ts +2 -3
  61. package/lib/icon/font_icon.js +35 -39
  62. package/lib/icon/info.js +12 -12
  63. package/lib/icon/loading.js +9 -9
  64. package/lib/icon/moon.js +12 -12
  65. package/lib/icon/more.js +12 -12
  66. package/lib/icon/reduction.js +12 -12
  67. package/lib/icon/refresh.d.ts +5 -0
  68. package/lib/icon/refresh.js +10 -0
  69. package/lib/icon/refresh_left.js +12 -12
  70. package/lib/icon/refresh_right.js +9 -9
  71. package/lib/icon/search.js +9 -9
  72. package/lib/icon/select.js +12 -12
  73. package/lib/icon/sort.js +9 -9
  74. package/lib/icon/success.js +12 -12
  75. package/lib/icon/sun.js +12 -12
  76. package/lib/icon/theme_default.js +12 -12
  77. package/lib/icon/warn.js +12 -12
  78. package/lib/icon/zoom_in.js +12 -12
  79. package/lib/icon/zoom_out.js +12 -12
  80. package/lib/image/image_preview.js +2 -104
  81. package/lib/image/index.js +2 -176
  82. package/lib/image-CeQVfS-v.js +162 -0
  83. package/lib/image_preview-PzZzwo6m.js +92 -0
  84. package/lib/index.d.ts +10 -4
  85. package/lib/index.js +80 -169
  86. package/lib/input/index.d.ts +6 -2
  87. package/lib/input/index.js +188 -203
  88. package/lib/input-DjKxcxry.js +4 -0
  89. package/lib/input_inner-BKJg9n9A.js +4 -0
  90. package/lib/item-Cuw_ZPyn.js +14 -0
  91. package/lib/item-DV842Aux.js +57 -0
  92. package/lib/item-ZXLWFzSm.js +119 -0
  93. package/lib/list/index.js +2 -58
  94. package/lib/list-CU7vHS6s.js +51 -0
  95. package/lib/loading/index.d.ts +3 -2
  96. package/lib/loading/index.js +109 -127
  97. package/lib/mask/index.js +2 -105
  98. package/lib/mask-BlV5QfTj.js +112 -0
  99. package/lib/md_input/index.js +2 -60
  100. package/lib/md_input-DSQx5TMW.js +58 -0
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/menu_item.js +2 -21
  103. package/lib/menu/sub_menu.js +2 -83
  104. package/lib/menu-DAtplYAH.js +91 -0
  105. package/lib/menu_item-BW1Tu11Q.js +20 -0
  106. package/lib/message/index.js +67 -60
  107. package/lib/modal/index.js +2 -196
  108. package/lib/modal/modal_box.js +87 -86
  109. package/lib/modal-DWyWrN-D.js +192 -0
  110. package/lib/page_header/index.js +2 -109
  111. package/lib/page_header-DdeRDN4U.js +101 -0
  112. package/lib/pagination/index.js +2 -248
  113. package/lib/pagination-BoPzSPjT.js +210 -0
  114. package/lib/polygon/index.js +2 -27
  115. package/lib/polygon-C4Ow2lxi.js +20 -0
  116. package/lib/qrcode/index.d.ts +13 -4
  117. package/lib/qrcode/index.js +2 -57
  118. package/lib/qrcode-BFxsD_OP.js +64 -0
  119. package/lib/radio-2mNSYujz.js +13 -0
  120. package/lib/select/index.js +3 -401
  121. package/lib/select-CAgggYh7.js +326 -0
  122. package/lib/select_ori/index.js +47 -50
  123. package/lib/space/index.js +2 -35
  124. package/lib/space-CpTmBfHP.js +38 -0
  125. package/lib/sub_menu-D1s8ABNu.js +75 -0
  126. package/lib/switch/index.js +2 -50
  127. package/lib/switch-BaVBi5Ip.js +48 -0
  128. package/lib/tabbar/index.js +2 -109
  129. package/lib/tabbar/item.js +2 -58
  130. package/lib/tabbar-4_d2Fj1n.js +91 -0
  131. package/lib/table/index.js +2 -269
  132. package/lib/table-Hifj8jAX.js +234 -0
  133. package/lib/tabs/index.js +38 -42
  134. package/lib/tag/index.js +2 -72
  135. package/lib/tag-DPENZf_V.js +76 -0
  136. package/lib/theme/index.js +2 -89
  137. package/lib/theme/theme_color.js +22 -26
  138. package/lib/theme-BRTI2-Yk.js +83 -0
  139. package/lib/utils/clickoutside.js +18 -18
  140. package/lib/utils/context_provide.js +21 -21
  141. package/lib/utils/event.js +13 -18
  142. package/lib/utils/index.js +55 -58
  143. package/lib/utils/popover.d.ts +4 -1
  144. package/lib/utils/popover.js +276 -352
  145. package/lib/utils/transition.js +33 -31
  146. package/package.json +10 -11
  147. package/styles/container.css +4 -0
  148. package/styles/datepicker.css +55 -0
  149. package/styles/popover.css +14 -1
  150. package/lib/animation-DttknHkX.js +0 -4
  151. package/lib/calendar/langs.js +0 -8
  152. package/lib/carousel/timer.js +0 -19
  153. package/lib/check/check.js +0 -118
  154. package/lib/check/index.js +0 -68
  155. package/lib/check-CksURvTv.js +0 -4
  156. package/lib/form/form_inner.js +0 -125
  157. package/lib/form/types.js +0 -1
  158. package/lib/index-CrMiSe0x.js +0 -249
  159. package/lib/index-DY6m9Wbe.js +0 -4
  160. package/lib/litos-ui.css +0 -1
  161. package/lib/table/types.js +0 -1
@@ -0,0 +1,234 @@
1
+ import e from "./base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n } from "./utils/index.js";
3
+ import { $$ as r, $one as i, formatStyle as a, iterate as o, off as s, on as c, shouldEventNext as l } from "ph-utils/dom";
4
+ import { random as u } from "ph-utils";
5
+ //#region src/components/table/index.less?inline
6
+ var d = ":host{width:100%;max-height:var(--l-table-max-height,100%);font-size:var(--l-table-font-size,14px);display:inline-block;overflow:auto}.l-table{border-collapse:collapse;border-spacing:0;table-layout:var(--l-table-layout,auto);width:100%}.l-table th,.l-table td{border-bottom:1px solid var(--l-table-border-color,#e6e6e6)}.l-table th{padding:var(--l-table-th-padding,10px);text-align:left;background-color:var(--l-table-th-bg,#f2f2f2);color:var(--l-table-th-color,#000)}.l-table td{background-color:var(--l-table-td-bg,#fff);color:var(--l-table-td-color,#000);padding:var(--l-table-td-padding,10px);transition:background-color .3s}.l-table tr:hover td{background-color:var(--l-table-row-hover-bg,#f2f2f2)}.l-table .l-table__empty-col{color:var(--l-table-empty-color,#999);text-align:center}.l-table-stripe tr:nth-child(2n) td{background-color:var(--l-table-stripe-bg,#fafafa)}.l-table-stripe tr:nth-child(2n):hover td{background-color:var(--l-table-row-hover-bg,#f2f2f2)}.l-table-border th,.l-table-border td{border:1px solid var(--l-table-border-color,#e6e6e6)}.l-table-fixed{--l-table-layout:fixed}.l-table-fixed .l-fixed{z-index:1;box-sizing:border-box;position:sticky}.l-table-fixed thead.l-fixed,.l-table-fixed tfoot.l-fixed{z-index:2}.l-table .caret-wrapper{vertical-align:middle;justify-content:center;align-items:center;width:20px;height:14px;display:inline-flex;position:relative}.l-table .caret-wrapper .ascending{border-bottom-color:var(--l-table-sort-inactive-color,#c0c4cc);top:-5px}.l-table .caret-wrapper .descending{border-top-color:var(--l-table-sort-inactive-color,#c0c4cc);bottom:-3px}.l-table .sort-caret{border:5px solid #0000;border-radius:3px;width:0;height:0;display:inline-block;position:absolute}.l-table .sort-column{cursor:pointer}.l-table .sort-asc .ascending{border-bottom-color:var(--l-primary-color,#52c41a)}.l-table .sort-desc .descending{border-top-color:var(--l-primary-color,#52c41a)}", f = class extends e {
7
+ static baseName = "table";
8
+ stripe = !0;
9
+ border = !1;
10
+ fixedHead = !1;
11
+ fixedColumn = !1;
12
+ maxHeight;
13
+ tableLayout;
14
+ columns = [];
15
+ data = [];
16
+ sortInfo;
17
+ _globalColStyles;
18
+ connectedCallback() {
19
+ this.loadStyleText(d), super.connectedCallback();
20
+ }
21
+ setColumns(e) {
22
+ this.columns = this._parseColumns(e, 0, 0), this.rerender("all");
23
+ }
24
+ setData(e, t) {
25
+ this.data = e, this.sortInfo = t, this.columns && this.columns.length > 0 && this.rerender(t ? "all" : "body");
26
+ }
27
+ changeFixed(e) {
28
+ let t = {
29
+ fixedHead: this.fixedHead,
30
+ fixedColumn: this.fixedColumn,
31
+ ...e
32
+ };
33
+ if (this.fixedHead = t.fixedHead, this.fixedColumn = t.fixedColumn, this.rendered) {
34
+ let e = i(".l-table", this.root);
35
+ e && (this.fixedHead || this.fixedColumn ? e.classList.add("l-table-fixed") : e.classList.remove("l-table-fixed"));
36
+ }
37
+ }
38
+ static get observedAttributes() {
39
+ return [
40
+ "stripe",
41
+ "border",
42
+ "fixed-head",
43
+ "max-height",
44
+ "table-layout"
45
+ ];
46
+ }
47
+ attributeChangedCallback(e, r, i) {
48
+ e = t(e);
49
+ let a = n(i, this[e], e);
50
+ if (a !== this[e]) switch (this[e] = a, e) {
51
+ case "stripe":
52
+ this._classAttrChannge("stripe", a);
53
+ break;
54
+ case "border":
55
+ this._classAttrChannge("border", a);
56
+ break;
57
+ case "fixedHead":
58
+ this._updateFixedHead(), this.changeFixed();
59
+ break;
60
+ case "maxHeight":
61
+ this._changeMaxHeight();
62
+ break;
63
+ case "tableLayout":
64
+ this._changeCssVar("table-layout", a);
65
+ break;
66
+ }
67
+ }
68
+ render() {
69
+ let e = r("table", { class: [
70
+ "l-table",
71
+ this.stripe ? "l-table-stripe" : "",
72
+ this.border ? "l-table-border" : "",
73
+ this.fixedHead || this.fixedColumn ? "l-table-fixed" : ""
74
+ ] });
75
+ return e.appendChild(this._headRender()), e.appendChild(this._bodyRender()), e;
76
+ }
77
+ rerender(e) {
78
+ if (this.rendered) {
79
+ if (e === "all" || e === "head") {
80
+ let e = i("thead", this.root);
81
+ e && e.replaceWith(this._headRender());
82
+ }
83
+ if (e === "all" || e === "body") {
84
+ let e = i("tbody", this.root);
85
+ e && e.replaceWith(this._bodyRender());
86
+ }
87
+ }
88
+ }
89
+ _changeCssVar(e, t) {
90
+ if (!this.rendered) return;
91
+ let n = `--l-table-${e}`;
92
+ t ? this.style.setProperty(n, t) : this.style.removeProperty(n);
93
+ }
94
+ _changeMaxHeight() {
95
+ let e = this.maxHeight;
96
+ e && typeof e == "number" && (e = `${e}px`), this._changeCssVar("max-height", e);
97
+ }
98
+ _classAttrChannge(e, t) {
99
+ if (this.rendered) {
100
+ let n = i("table", this.root);
101
+ n && n.classList.toggle(`l-table-${e}`, t);
102
+ }
103
+ }
104
+ _updateFixedHead() {
105
+ if (this.rendered) {
106
+ let e = i("thead", this.root);
107
+ e && (e.classList.toggle("l-fixed", this.fixedHead), e.style.top = this.fixedHead ? "0" : "");
108
+ }
109
+ }
110
+ _headRender() {
111
+ let e = r("thead", {
112
+ class: { "l-fixed": this.fixedHead },
113
+ style: { top: this.fixedHead ? "0" : void 0 }
114
+ });
115
+ return this.columns && this._rendHeadRow(e, this.columns), e;
116
+ }
117
+ _rendHeadRow(e, t) {
118
+ let n = r("tr");
119
+ for (let r = 0, i = t.length; r < i; r++) {
120
+ let i = t[r];
121
+ n.appendChild(this._headColRender(i, r)), i.children && this._rendHeadRow(e, i.children);
122
+ }
123
+ e.appendChild(n);
124
+ }
125
+ _headColRender(e, t) {
126
+ let n = r("th");
127
+ if (e.titleColspan && e.titleColspan > 1 && (n.colSpan = e.titleColspan), e.titleRowspan && e.titleRowspan > 1 && (n.rowSpan = e.titleRowspan), n.style.cssText = this._getColumnStyle(e, "th"), e.fixed && n.classList.add("l-fixed"), n.appendChild(r("span", { textContent: e.title })), e.sorter) {
128
+ let e = r("span", { class: "caret-wrapper" });
129
+ e.appendChild(r("span", { class: "sort-caret ascending" })), e.appendChild(r("span", { class: "sort-caret descending" })), n.classList.add("sort-column"), n.setAttribute("data-action", "sort"), n.setAttribute("data-col", `${t}`), n.appendChild(e);
130
+ }
131
+ return this.sortInfo && this.sortInfo.key === e.key && n.classList.add(this.sortInfo.order === "asc" ? "sort-asc" : "sort-desc"), n;
132
+ }
133
+ _bodyRender() {
134
+ let e = r("tbody");
135
+ if (this.data && this.data.length > 0) for (let t = 0, n = this.data.length; t < n; t++) {
136
+ let n = this.data[t];
137
+ if (this.columns) {
138
+ let i = r("tr");
139
+ this._bodyRowRender(this.columns, t, n, i), e.appendChild(i);
140
+ }
141
+ }
142
+ else {
143
+ let t = r("tr"), n = r("td", {
144
+ class: "l-table__empty-col",
145
+ textContent: "暂无数据"
146
+ });
147
+ this.columns && (n.colSpan = this.columns.length), t.appendChild(n), e.appendChild(t);
148
+ }
149
+ return e;
150
+ }
151
+ _bodyRowRender(e, t, n, i) {
152
+ for (let a = 0, s = e.length; a < s; a++) {
153
+ let s = e[a];
154
+ if (s.children && s.children.length > 0) this._bodyRowRender(s.children, t, n, i);
155
+ else {
156
+ let e = r("td");
157
+ if (typeof s.rowspan == "number" && (e.rowSpan = s.rowspan), typeof s.rowspan == "function" && (e.rowSpan = s.rowspan(n, t)), typeof s.colspan == "number" && (e.colSpan = s.colspan), typeof s.colspan == "function" && (e.colSpan = s.colspan(n, t)), s.fixed && (e.className = "l-fixed"), e.style.cssText = this._getColumnStyle(s), s.render) {
158
+ let r = s.render(n, t);
159
+ typeof r == "string" ? e.innerHTML = r : Array.isArray(r) ? o(r, (t) => {
160
+ e.appendChild(t);
161
+ }) : e.appendChild(r);
162
+ } else e.textContent = s.key ? n[s.key] : "";
163
+ i.appendChild(e);
164
+ }
165
+ }
166
+ }
167
+ _parseColumns(e, t, n) {
168
+ let r = [];
169
+ for (let i = 0, a = e.length; i < a; i++) {
170
+ let a = e[i];
171
+ if (a.id ||= a.key || a.title, a.id ||= `${i}_${u(6)}`, a.fixed) {
172
+ let e = Number.parseFloat(`${a.width || 0}`);
173
+ a.fixed === "left" ? (a.left = t, t += e) : a.fixed === "right" && (a.right = n, n += e);
174
+ }
175
+ if (a.children) {
176
+ let e = this._parseColumns(a.children, t, n);
177
+ a.titleRowspan = a.titleRowspan || 1, a.titleColspan ||= e.reduce((e, t) => e + (t.titleColspan || 1), 0), r.push({
178
+ ...a,
179
+ children: e
180
+ });
181
+ } else a.titleRowspan = a.titleRowspan || this._getMaxDepth(e), a.titleColspan = a.titleColspan || 1, r.push({ ...a });
182
+ }
183
+ return r;
184
+ }
185
+ _getMaxDepth(e) {
186
+ let t = 1;
187
+ for (let n of e) n.children && (t = Math.max(t, this._getMaxDepth(n.children) + 1));
188
+ return t;
189
+ }
190
+ _getColumnStyle(e, t = "td") {
191
+ let n = e.id;
192
+ if (this._globalColStyles && n in this._globalColStyles) return this._globalColStyles[n][t];
193
+ let r = {};
194
+ e.width && (typeof e.width == "number" ? r.width = `${e.width}px` : r.width = e.width), e.fixed && (e.fixed === "left" ? (r.left = `${e.left}px`, r["box-shadow"] = "-4px 0 4px -4px #d9d9d9 inset") : e.fixed === "right" && (r.right = `${e.right}px`, r["box-shadow"] = "4px 0 4px -4px #d9d9d9 inset")), this._globalColStyles ||= {};
195
+ let i = a(r), o = {
196
+ th: i,
197
+ td: i + a(e.style || "")
198
+ };
199
+ return this._globalColStyles[n] = o, o[t];
200
+ }
201
+ _handleTap = (e) => {
202
+ let [t, n, r] = l(e, "data-action", e.currentTarget);
203
+ if (t) {
204
+ let e = r.dataset;
205
+ if (n === "sort") {
206
+ let t = parseInt(e.col), n = this.columns[t], r = this.sortInfo && this.sortInfo.order === "desc" ? "asc" : "desc";
207
+ this.sortInfo = {
208
+ key: n.key,
209
+ order: r
210
+ }, n.sorter === "custom" ? this.emit("sort", { detail: {
211
+ index: t,
212
+ key: n.key,
213
+ dir: r
214
+ } }) : (this.data = this._dataSort(), this.rerender("all"));
215
+ } else this.emit(n, { detail: e });
216
+ }
217
+ };
218
+ afterInit() {
219
+ this._changeMaxHeight(), c(this.root, "click", this._handleTap);
220
+ }
221
+ beforeDestroy() {
222
+ s(this.root, "click", this._handleTap);
223
+ }
224
+ _dataSort() {
225
+ if (!this.sortInfo || !this.data) return;
226
+ let { key: e, order: t } = this.sortInfo;
227
+ return this.data.sort((n, r) => {
228
+ let i = n[e], a = r[e];
229
+ return t === "asc" ? i - a : a - i;
230
+ });
231
+ }
232
+ };
233
+ //#endregion
234
+ export { f as t };
package/lib/tabs/index.js CHANGED
@@ -1,43 +1,39 @@
1
- import { $ as _, iterate as i, $one as r, on as d, off as u } from "ph-utils/dom";
2
- function g() {
3
- let n = _(".l-tabs");
4
- function l(e) {
5
- const t = e.target.parentElement;
6
- if (t) {
7
- const o = t.getAttribute("l-current-tab");
8
- if (o) {
9
- const b = r(`.l-tabs__content[l-tab="${o}"]`, t);
10
- b && b.classList.add("l-tabs__content--hide");
11
- }
12
- const s = e.detail.name;
13
- t.setAttribute("l-current-tab", s);
14
- const c = r(`.l-tabs__content[l-tab="${s}"]`, t);
15
- c && c.classList.remove("l-tabs__content--hide");
16
- }
17
- }
18
- n && n.length > 0 && i(n, (e) => {
19
- const a = r(".l-tabs__bar", e);
20
- if (a) {
21
- d(a, "change", l);
22
- const t = a.getAttribute("name");
23
- t && e.setAttribute("l-current-tab", t);
24
- const o = _(".l-tabs__content[l-tab]", e);
25
- i(o, (s) => {
26
- s.getAttribute("l-tab") === t ? s.classList.remove("l-tabs__content--hide") : s.classList.add("l-tabs__content--hide");
27
- });
28
- }
29
- });
30
- function f() {
31
- n && n.length > 0 && i(n, (e) => {
32
- const a = r(".l-tabs__bar", e);
33
- a && (console.log("destroy"), u(a, "change", l));
34
- }), n = void 0;
35
- }
36
- return { destroy: f };
1
+ import { $ as e, $one as t, iterate as n, off as r, on as i } from "ph-utils/dom";
2
+ //#region src/components/tabs/index.ts
3
+ function a() {
4
+ let a = e(".l-tabs");
5
+ function o(e) {
6
+ let n = e.target.parentElement;
7
+ if (n) {
8
+ let r = n.getAttribute("l-current-tab");
9
+ if (r) {
10
+ let e = t(`.l-tabs__content[l-tab="${r}"]`, n);
11
+ e && e.classList.add("l-tabs__content--hide");
12
+ }
13
+ let i = e.detail.name;
14
+ n.setAttribute("l-current-tab", i);
15
+ let a = t(`.l-tabs__content[l-tab="${i}"]`, n);
16
+ a && a.classList.remove("l-tabs__content--hide");
17
+ }
18
+ }
19
+ a && a.length > 0 && n(a, (r) => {
20
+ let a = t(".l-tabs__bar", r);
21
+ if (a) {
22
+ i(a, "change", o);
23
+ let t = a.getAttribute("name");
24
+ t && r.setAttribute("l-current-tab", t), n(e(".l-tabs__content[l-tab]", r), (e) => {
25
+ e.getAttribute("l-tab") === t ? e.classList.remove("l-tabs__content--hide") : e.classList.add("l-tabs__content--hide");
26
+ });
27
+ }
28
+ });
29
+ function s() {
30
+ a && a.length > 0 && n(a, (e) => {
31
+ let n = t(".l-tabs__bar", e);
32
+ n && (console.log("destroy"), r(n, "change", o));
33
+ }), a = void 0;
34
+ }
35
+ return { destroy: s };
37
36
  }
38
- const m = {
39
- init: g
40
- };
41
- export {
42
- m as default
43
- };
37
+ var o = { init: a };
38
+ //#endregion
39
+ export { o as default };
package/lib/tag/index.js CHANGED
@@ -1,72 +1,2 @@
1
- import i from "../base.js";
2
- import { parseAttrValue as c } from "../utils/index.js";
3
- import { isBlank as n } from "ph-utils";
4
- import { adjust as g } from "ph-utils/color";
5
- import { $one as d, $$ as l, shouldEventNext as f, on as h, off as p } from "ph-utils/dom";
6
- const b = ":host{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;vertical-align:middle;height:var(--l-tag-height, 22px);padding:0 5px;font-size:12px;line-height:1;border:1px solid var(--l-tag-border-color, var(--l-border-color, #dedede));border-radius:4px;background:var(--l-tag-background, #fff);white-space:nowrap;color:var(--l-tag-color, #333)}:host(.l-tag--primary){--l-tag-border-color: var(--l-primary-color-light3, #d3adf7);--l-tag-background: var(--l-primary-color-light5, #f9f0ff);--l-tag-color: var(--l-primary-color-light3, #d3adf7)}:host(.l-tag--error){--l-tag-color: var(--l-error-color, #ed3f13);--l-tag-background: var(--l-error-color-light5, #fff1f0);--l-tag-border-color: var(--l-error-color, #ed3f13)}:host(.l-tag--success){--l-tag-color: var(--l-success-color, #a0d911);--l-tag-background: var(--l-success-color-light5, #fcffe6);--l-tag-border-color: var(--l-success-color, #a0d911)}:host(.l-tag--info){--l-tag-color: var(--l-info-color, #999999);--l-tag-background: var(--l-info-color-light9, #f5f5f5);--l-tag-border-color: var(--l-border-color, #dedede)}:host(.l-tag--warning){--l-tag-color: var(--l-warning-color, #ff9900);--l-tag-background: var(--l-warning-color-light5, #fff5e6);--l-tag-border-color: var(--l-warning-color, #ff9900)}.l-tag-close{margin-left:3px;font-size:12px;width:14px;height:14px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;transition:color .3s,background-color .3s;cursor:pointer}.l-tag-close:hover{background-color:var(--l-tag-color, #1890ff);color:#fff}";
7
- class C extends i {
8
- static baseName = "tag";
9
- connectedCallback() {
10
- this.loadStyleText(b), super.connectedCallback();
11
- }
12
- static get observedAttributes() {
13
- return ["type", "color", "closeable"];
14
- }
15
- attributeChangedCallback(t, o, r) {
16
- const e = r.trim();
17
- switch (t) {
18
- case "type":
19
- this._toggleTypeClass(e);
20
- break;
21
- case "color":
22
- this._toggleColorStyle(e);
23
- break;
24
- case "closable":
25
- if (!this.rendered) return;
26
- const a = c(e, !1, "closeable"), s = d(".l-tag-close", this.root);
27
- if (s) {
28
- if (a) return;
29
- s.remove();
30
- } else
31
- a && this.root.appendChild(this.#t());
32
- break;
33
- }
34
- }
35
- render() {
36
- const t = document.createDocumentFragment();
37
- return t.appendChild(l("div", { class: "l-tag-content", innerHTML: "<slot></slot>" })), this.getAttr("closeable", !1) && t.appendChild(this.#t()), t.appendChild(l("slot", { name: "suffix" })), t;
38
- }
39
- #t() {
40
- return l("div", {
41
- class: "l-tag-close",
42
- innerHTML: "<l-close-icon></l-close-icon>",
43
- "data-action": "close"
44
- });
45
- }
46
- #r = (t) => {
47
- const [o, r, e] = f(t, "data-action", this);
48
- o && r === "close" && this.emit("close", { detail: { ...e.dataset } });
49
- };
50
- afterInit() {
51
- this.classList.add(`l-tag--${this.getAttr("type", "info")}`), this._toggleColorStyle(), h(this.root, "click", this.#r);
52
- }
53
- _toggleTypeClass(t) {
54
- if (!this.rendered) return;
55
- let o = !1;
56
- for (const r of this.classList)
57
- if (r.startsWith("l-tag--")) {
58
- this.classList.replace(r, `l-tag--${t}`), o = !0;
59
- break;
60
- }
61
- o || this.classList.add(`l-tag--${t}`);
62
- }
63
- _toggleColorStyle(t) {
64
- this.rendered && (n(t) ? (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", t), this.style.setProperty("--l-tag-border-color", t), this.style.setProperty("--l-tag-background", g(t, 5, !0))));
65
- }
66
- beforeDestroy() {
67
- p(this.root, "click", this.#r);
68
- }
69
- }
70
- export {
71
- C as default
72
- };
1
+ import { t as e } from "../tag-DPENZf_V.js";
2
+ export { e as default };
@@ -0,0 +1,76 @@
1
+ import e from "./base.js";
2
+ import { parseAttrValue as t } from "./utils/index.js";
3
+ import { $$ as n, $one as r, off as i, on as a, shouldEventNext as o } from "ph-utils/dom";
4
+ import { isBlank as s } from "ph-utils";
5
+ import { adjust as c } from "ph-utils/color";
6
+ //#region src/components/tag/index.less?inline
7
+ var l = ":host{box-sizing:border-box;vertical-align:middle;height:var(--l-tag-height,22px);border:1px solid var(--l-tag-border-color,var(--l-border-color,#dedede));background:var(--l-tag-background,#fff);white-space:nowrap;color:var(--l-tag-color,#333);border-radius:4px;justify-content:center;align-items:center;padding:0 5px;font-size:12px;line-height:1;display:inline-flex}:host(.l-tag--primary){--l-tag-border-color:var(--l-primary-color-light3,#d3adf7);--l-tag-background:var(--l-primary-color-light5,#f9f0ff);--l-tag-color:var(--l-primary-color-light3,#d3adf7)}:host(.l-tag--error){--l-tag-color:var(--l-error-color,#ed3f13);--l-tag-background:var(--l-error-color-light5,#fff1f0);--l-tag-border-color:var(--l-error-color,#ed3f13)}:host(.l-tag--success){--l-tag-color:var(--l-success-color,#a0d911);--l-tag-background:var(--l-success-color-light5,#fcffe6);--l-tag-border-color:var(--l-success-color,#a0d911)}:host(.l-tag--info){--l-tag-color:var(--l-info-color,#999);--l-tag-background:var(--l-info-color-light9,#f5f5f5);--l-tag-border-color:var(--l-border-color,#dedede)}:host(.l-tag--warning){--l-tag-color:var(--l-warning-color,#f90);--l-tag-background:var(--l-warning-color-light5,#fff5e6);--l-tag-border-color:var(--l-warning-color,#f90)}.l-tag-close{cursor:pointer;border-radius:50%;justify-content:center;align-items:center;width:14px;height:14px;margin-left:3px;font-size:12px;transition:color .3s,background-color .3s;display:inline-flex}.l-tag-close:hover{background-color:var(--l-tag-color,#1890ff);color:#fff}", u = class extends e {
8
+ static baseName = "tag";
9
+ connectedCallback() {
10
+ this.loadStyleText(l), super.connectedCallback();
11
+ }
12
+ static get observedAttributes() {
13
+ return [
14
+ "type",
15
+ "color",
16
+ "closeable"
17
+ ];
18
+ }
19
+ attributeChangedCallback(e, n, i) {
20
+ let a = i.trim();
21
+ switch (e) {
22
+ case "type":
23
+ this._toggleTypeClass(a);
24
+ break;
25
+ case "color":
26
+ this._toggleColorStyle(a);
27
+ break;
28
+ case "closable":
29
+ if (!this.rendered) return;
30
+ let e = t(a, !1, "closeable"), n = r(".l-tag-close", this.root);
31
+ if (n) {
32
+ if (e) return;
33
+ n.remove();
34
+ } else e && this.root.appendChild(this.#e());
35
+ break;
36
+ }
37
+ }
38
+ render() {
39
+ let e = document.createDocumentFragment();
40
+ return e.appendChild(n("div", {
41
+ class: "l-tag-content",
42
+ innerHTML: "<slot></slot>"
43
+ })), this.getAttr("closeable", !1) && e.appendChild(this.#e()), e.appendChild(n("slot", { name: "suffix" })), e;
44
+ }
45
+ #e() {
46
+ return n("div", {
47
+ class: "l-tag-close",
48
+ innerHTML: "<l-close-icon></l-close-icon>",
49
+ "data-action": "close"
50
+ });
51
+ }
52
+ #t = (e) => {
53
+ let [t, n, r] = o(e, "data-action", this);
54
+ t && n === "close" && this.emit("close", { detail: { ...r.dataset } });
55
+ };
56
+ afterInit() {
57
+ this.classList.add(`l-tag--${this.getAttr("type", "info")}`), this._toggleColorStyle(), a(this.root, "click", this.#t);
58
+ }
59
+ _toggleTypeClass(e) {
60
+ if (!this.rendered) return;
61
+ let t = !1;
62
+ for (let n of this.classList) if (n.startsWith("l-tag--")) {
63
+ this.classList.replace(n, `l-tag--${e}`), t = !0;
64
+ break;
65
+ }
66
+ t || this.classList.add(`l-tag--${e}`);
67
+ }
68
+ _toggleColorStyle(e) {
69
+ this.rendered && (s(e) ? (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", e), this.style.setProperty("--l-tag-border-color", e), this.style.setProperty("--l-tag-background", c(e, 5, !0))));
70
+ }
71
+ beforeDestroy() {
72
+ i(this.root, "click", this.#t);
73
+ }
74
+ };
75
+ //#endregion
76
+ export { u as t };
@@ -1,89 +1,2 @@
1
- import l from "../base.js";
2
- import { initAttr as r } from "../utils/index.js";
3
- import { create as i, $one as c, 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;width:auto;box-sizing:border-box}.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-control-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 = [
6
- { value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
7
- { value: "light", text: "浅色模式", icon: "l-sun-icon" },
8
- { value: "dark", text: "深色模式", icon: "l-moon-icon" }
9
- ];
10
- class k extends l {
11
- static baseName = "theme";
12
- type = "button";
13
- label = "text";
14
- theme;
15
- #t;
16
- connectedCallback() {
17
- r(this), this.theme = h(), this.loadStyleText(u), super.connectedCallback(), this.#r();
18
- }
19
- disconnectedCallback() {
20
- super.disconnectedCallback(), this.#c();
21
- }
22
- render() {
23
- switch (this.type) {
24
- case "select":
25
- return this.#o();
26
- case "radio":
27
- return this.#l();
28
- case "switch":
29
- return this.#s();
30
- default:
31
- return this.#i();
32
- }
33
- }
34
- #i() {
35
- const t = i("l-button", {
36
- class: "l-theme-btn l-theme-inner"
37
- });
38
- return this.#n(t), t;
39
- }
40
- #n(t) {
41
- const e = this.theme === "auto" ? "sun" : "moon";
42
- t.innerHTML = `<l-${e}-icon></l-${e}-icon>`;
43
- }
44
- #o() {
45
- const t = i("l-select-ori", {
46
- class: "l-theme-inner"
47
- });
48
- t.value = this.theme;
49
- const e = [
50
- '<option value="auto">跟随系统</option>',
51
- '<option value="light">浅色模式</option>',
52
- '<option value="dark">深色模式</option>'
53
- ];
54
- return t.innerHTML = e.join(""), t;
55
- }
56
- #s() {
57
- const t = i("l-switch", {
58
- class: "l-theme-switch l-theme-inner"
59
- });
60
- 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;
61
- }
62
- #l() {
63
- const t = i("l-radio", {
64
- class: "l-theme-inner"
65
- });
66
- t.value = this.theme, t.type = "button";
67
- const e = d.map((n) => this.label === "icon" ? `<${n.icon} radio-value="${n.value}"></${n.icon}>` : `<span radio-value="${n.value}">${n.text}</span>`);
68
- return t.innerHTML = e.join(""), t;
69
- }
70
- #e = async (t) => {
71
- let e;
72
- if (this.type === "button")
73
- e = this.theme === "dark" ? "auto" : "dark";
74
- else {
75
- const n = t.target.value;
76
- this.type !== "switch" ? e = n : e = n ? "dark" : "light";
77
- }
78
- await a(e), this.theme = e, this.type === "button" && this.#n(this.#t), this.dispatchEvent(new CustomEvent("change", { detail: e }));
79
- };
80
- #r() {
81
- this.#t = c(".l-theme-inner", this.root), this.type === "button" ? o(this.#t, "click", this.#e) : o(this.#t, "change", this.#e);
82
- }
83
- #c() {
84
- this.#t && (this.type === "button" ? s(this.#t, "click", this.#e) : s(this.#t, "change", this.#e), this.#t = void 0);
85
- }
86
- }
87
- export {
88
- k as default
89
- };
1
+ import { t as e } from "../theme-BRTI2-Yk.js";
2
+ export { e as default };
@@ -1,27 +1,23 @@
1
- import { $one as t, on as r } from "ph-utils/dom";
2
- import s from "../base.js";
3
- import { getColorTheme as a, applyColorTheme as c } from "ph-utils/theme";
4
- class m extends s {
5
- static baseName = "theme-color";
6
- constructor() {
7
- super(), this.version = 2, this._state = {
8
- color: a() || "#722ed1"
9
- };
10
- }
11
- render_v2() {
12
- return {
13
- template: `<l-color-picker value="${this._state.color}"></l-color-picker>`
14
- };
15
- }
16
- afterInit() {
17
- const e = t("l-color-picker", this.root);
18
- e && r(e, "change", this.#e);
19
- }
20
- #e = async (e) => {
21
- const o = e.detail;
22
- this._state.color = o, await c(o), this.dispatchEvent(new CustomEvent("change", { detail: o }));
23
- };
24
- }
25
- export {
26
- m as default
1
+ import e from "../base.js";
2
+ import { $one as t, on as n } from "ph-utils/dom";
3
+ import { applyColorTheme as r, getColorTheme as i } from "ph-utils/theme";
4
+ //#region src/components/theme/theme_color.ts
5
+ var a = class extends e {
6
+ static baseName = "theme-color";
7
+ constructor() {
8
+ super(), this.version = 2, this._state = { color: i() || "#722ed1" };
9
+ }
10
+ render_v2() {
11
+ return { template: `<l-color-picker value="${this._state.color}"></l-color-picker>` };
12
+ }
13
+ afterInit() {
14
+ let e = t("l-color-picker", this.root);
15
+ e && n(e, "change", this.#e);
16
+ }
17
+ #e = async (e) => {
18
+ let t = e.detail;
19
+ this._state.color = t, await r(t), this.dispatchEvent(new CustomEvent("change", { detail: t }));
20
+ };
27
21
  };
22
+ //#endregion
23
+ export { a as default };