litos-ui 0.17.5 → 0.18.1

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 (163) hide show
  1. package/lib/animation-CTt9qgA7.js +4 -0
  2. package/lib/base-Dm0WS1pK.js +62 -0
  3. package/lib/base.js +111 -147
  4. package/lib/button/index.d.ts +8 -3
  5. package/lib/button/index.js +2 -137
  6. package/lib/button-CC5PmAb1.js +146 -0
  7. package/lib/calendar/index.d.ts +10 -5
  8. package/lib/calendar/index.js +2 -123
  9. package/lib/calendar-GpYHNmXG.js +149 -0
  10. package/lib/carousel/index.js +2 -280
  11. package/lib/carousel/item.js +2 -15
  12. package/lib/carousel-dT3FJPQo.js +272 -0
  13. package/lib/check/checkbox.js +2 -18
  14. package/lib/check/checkbox_group.js +6 -6
  15. package/lib/check/radio.js +2 -15
  16. package/lib/check/radio_group.js +9 -9
  17. package/lib/check-B0XraJvb.js +73 -0
  18. package/lib/check-CvGaONEx.js +117 -0
  19. package/lib/checkbox-DbWsmAaL.js +16 -0
  20. package/lib/collapse/index.d.ts +18 -11
  21. package/lib/collapse/index.js +2 -88
  22. package/lib/collapse/item.d.ts +28 -9
  23. package/lib/collapse/item.js +2 -115
  24. package/lib/collapse/types.d.ts +7 -0
  25. package/lib/collapse-C3IRHLeg.js +104 -0
  26. package/lib/color_picker/index.js +2 -42
  27. package/lib/color_picker-D0brKFm-.js +41 -0
  28. package/lib/date_picker/index.d.ts +23 -0
  29. package/lib/date_picker/index.js +3 -0
  30. package/lib/date_picker-DQGoiN8v.js +103 -0
  31. package/lib/date_picker_ori/index.js +2 -129
  32. package/lib/date_picker_ori-aRuSSi9D.js +122 -0
  33. package/lib/description_panel/index.js +2 -66
  34. package/lib/description_panel-BY2yljeC.js +57 -0
  35. package/lib/dialog/dialog_container.js +2 -131
  36. package/lib/dialog/index.js +67 -85
  37. package/lib/dialog_container-DcN87wj0.js +126 -0
  38. package/lib/esm-sVEoAVPu.js +244 -0
  39. package/lib/form/form_item.d.ts +1 -0
  40. package/lib/form/form_item.js +2 -136
  41. package/lib/form/index.js +2 -147
  42. package/lib/form-DdU0yK0k.js +154 -0
  43. package/lib/form_inner-DR9tyB_r.js +117 -0
  44. package/lib/form_item-Bv-YafZK.js +137 -0
  45. package/lib/icon/arrow_down.js +12 -12
  46. package/lib/icon/arrow_left.js +9 -9
  47. package/lib/icon/arrow_right.js +9 -9
  48. package/lib/icon/arrow_up.js +12 -12
  49. package/lib/icon/base.d.ts +16 -2
  50. package/lib/icon/base.js +2 -38
  51. package/lib/icon/calendar.d.ts +5 -0
  52. package/lib/icon/calendar.js +10 -0
  53. package/lib/icon/caret_bottom.js +9 -9
  54. package/lib/icon/caret_top.js +9 -9
  55. package/lib/icon/close.js +9 -9
  56. package/lib/icon/close_filled.js +12 -12
  57. package/lib/icon/d_arrow_left.js +12 -12
  58. package/lib/icon/d_arrow_right.js +12 -12
  59. package/lib/icon/font_icon.d.ts +2 -3
  60. package/lib/icon/font_icon.js +35 -39
  61. package/lib/icon/info.js +12 -12
  62. package/lib/icon/loading.js +9 -9
  63. package/lib/icon/moon.js +12 -12
  64. package/lib/icon/more.js +12 -12
  65. package/lib/icon/reduction.js +12 -12
  66. package/lib/icon/refresh.d.ts +5 -0
  67. package/lib/icon/refresh.js +10 -0
  68. package/lib/icon/refresh_left.js +12 -12
  69. package/lib/icon/refresh_right.js +9 -9
  70. package/lib/icon/search.js +9 -9
  71. package/lib/icon/select.js +12 -12
  72. package/lib/icon/sort.js +9 -9
  73. package/lib/icon/success.js +12 -12
  74. package/lib/icon/sun.js +12 -12
  75. package/lib/icon/theme_default.js +12 -12
  76. package/lib/icon/warn.js +12 -12
  77. package/lib/icon/zoom_in.js +12 -12
  78. package/lib/icon/zoom_out.js +12 -12
  79. package/lib/image/image_preview.js +2 -104
  80. package/lib/image/index.js +2 -176
  81. package/lib/image-COPKk8Jm.js +162 -0
  82. package/lib/image_preview-CYEup07F.js +92 -0
  83. package/lib/index.d.ts +5 -81
  84. package/lib/index.js +78 -169
  85. package/lib/input/index.d.ts +6 -2
  86. package/lib/input/index.js +188 -203
  87. package/lib/input-DjKxcxry.js +4 -0
  88. package/lib/input_inner-BKJg9n9A.js +4 -0
  89. package/lib/item-B7Elh5xE.js +14 -0
  90. package/lib/item-CvoJt3wp.js +60 -0
  91. package/lib/item-DRsOV_Tc.js +119 -0
  92. package/lib/list/index.js +2 -58
  93. package/lib/list-CU7vHS6s.js +51 -0
  94. package/lib/loading/index.d.ts +3 -2
  95. package/lib/loading/index.js +109 -127
  96. package/lib/mask/index.js +2 -105
  97. package/lib/mask-CEznzwji.js +112 -0
  98. package/lib/md_input/index.js +2 -60
  99. package/lib/md_input-DSQx5TMW.js +58 -0
  100. package/lib/menu/index.d.ts +30 -13
  101. package/lib/menu/index.js +2 -105
  102. package/lib/menu/types.d.ts +6 -0
  103. package/lib/menu/types.js +0 -0
  104. package/lib/menu-CzV6lOlw.js +224 -0
  105. package/lib/message/index.js +67 -60
  106. package/lib/modal/index.js +2 -196
  107. package/lib/modal/modal_box.js +87 -86
  108. package/lib/modal-DWyWrN-D.js +192 -0
  109. package/lib/page_header/index.js +2 -109
  110. package/lib/page_header-BJkEstRw.js +101 -0
  111. package/lib/pagination/index.js +2 -248
  112. package/lib/pagination-5t7AOeFV.js +210 -0
  113. package/lib/polygon/index.js +2 -27
  114. package/lib/polygon-C4Ow2lxi.js +20 -0
  115. package/lib/qrcode/index.d.ts +13 -4
  116. package/lib/qrcode/index.js +2 -57
  117. package/lib/qrcode-BKG2MibP.js +64 -0
  118. package/lib/radio-2mNSYujz.js +13 -0
  119. package/lib/select/index.js +3 -401
  120. package/lib/select-CAgggYh7.js +326 -0
  121. package/lib/select_ori/index.js +47 -50
  122. package/lib/space/index.js +2 -35
  123. package/lib/space-Bv-p0DL8.js +38 -0
  124. package/lib/switch/index.js +2 -50
  125. package/lib/switch-BaVBi5Ip.js +48 -0
  126. package/lib/tabbar/index.js +2 -109
  127. package/lib/tabbar/item.js +2 -58
  128. package/lib/tabbar-CI1xSj1G.js +96 -0
  129. package/lib/table/index.js +2 -269
  130. package/lib/table-DfL2hFqA.js +234 -0
  131. package/lib/tabs/index.js +38 -42
  132. package/lib/tag/index.js +2 -72
  133. package/lib/tag-72DwCkvq.js +76 -0
  134. package/lib/theme/index.js +2 -89
  135. package/lib/theme/theme_color.js +22 -26
  136. package/lib/theme-BRTI2-Yk.js +83 -0
  137. package/lib/utils/clickoutside.js +18 -18
  138. package/lib/utils/context_provide.js +21 -21
  139. package/lib/utils/event.js +13 -18
  140. package/lib/utils/index.js +55 -58
  141. package/lib/utils/popover.d.ts +4 -1
  142. package/lib/utils/popover.js +276 -352
  143. package/lib/utils/transition.js +33 -31
  144. package/package.json +14 -14
  145. package/styles/container.css +4 -0
  146. package/styles/datepicker.css +55 -0
  147. package/styles/popover.css +14 -1
  148. package/lib/animation-DttknHkX.js +0 -4
  149. package/lib/calendar/langs.js +0 -8
  150. package/lib/carousel/timer.js +0 -19
  151. package/lib/check/check.js +0 -118
  152. package/lib/check/index.js +0 -68
  153. package/lib/check-CksURvTv.js +0 -4
  154. package/lib/form/form_inner.js +0 -125
  155. package/lib/form/types.js +0 -1
  156. package/lib/index-CrMiSe0x.js +0 -249
  157. package/lib/index-DY6m9Wbe.js +0 -4
  158. package/lib/litos-ui.css +0 -1
  159. package/lib/menu/menu_item.d.ts +0 -6
  160. package/lib/menu/menu_item.js +0 -21
  161. package/lib/menu/sub_menu.d.ts +0 -15
  162. package/lib/menu/sub_menu.js +0 -83
  163. package/lib/table/types.js +0 -1
@@ -0,0 +1,326 @@
1
+ import { kebabToCamel as e, parseAttrValue as t } from "./utils/index.js";
2
+ import { t as n } from "./form_inner-DR9tyB_r.js";
3
+ import { Popover as r } from "./utils/popover.js";
4
+ import { $ as i, $$ as a, $one as o, iterate as s, off as c, on as l, shouldEventNext as u } from "ph-utils/dom";
5
+ import { debounce as d } from "ph-utils/web";
6
+ //#region src/components/select/index.less?inline
7
+ var f = ":host{--l-select-width:100%;min-height:var(--l-form-control-height,32px);width:var(--l-select-width);border:1px solid var(--l-border-color,#d9d9d9);cursor:pointer;box-sizing:border-box;border-radius:4px;justify-content:space-between;align-items:center;gap:5px;padding:4px 10px;font-size:14px;line-height:1;transition:border-color .3s;display:inline-flex;position:relative}:host(:hover){border-color:silver}:host(.l-select--disabled){background-color:var(--l-disabled-color,#f5f7fa);cursor:not-allowed}:host(.l-select--expand),:host(.l-select--active){border-color:var(--l-primary-color,#722ed1)}:host(.l-select--expand) .l-select-arrow{transform:rotate(180deg)}:host(.l-select--loading) .l-select-arrow{opacity:.2}:host(.l-select--clearable) .l-select-arrow{opacity:0}.l-select-main{box-sizing:border-box;flex-flow:wrap;flex-grow:1;gap:5px;display:flex;overflow:hidden}.l-selected-item{flex-shrink:0}.l-select-placeholder{flex-grow:1}.l-select-placeholder,.l-select-arrow{color:#a8abb2}.l-select-filter{background-color:#0000;border:none;outline:none;flex-grow:1;flex-shrink:0;width:0;min-width:15px;max-width:100%}.l-select-filter::placeholder{color:#a8abb2}.l-select-arrow{flex-shrink:0;transition:transform .3s,opacity .3s;transform:rotate(0)}.l-select-tag-close{box-sizing:border-box;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-select-tag-close:hover{color:#fff;background-color:#999}.l-select-clear,.l-select-loading{position:absolute;top:50%;right:10px;transform:translateY(-50%)}.l-select-loading{color:var(--l-primary-color,#722ed1);z-index:2;animation:1.5s linear infinite l-select-loading}.l-select-clear{color:#afafaf;z-index:1}@keyframes l-select-loading{0%{transform:translateY(-50%)rotate(0)}to{transform:translateY(-50%)rotate(360deg)}}", p = class extends n {
8
+ static baseName = "select";
9
+ selectedLabels = [];
10
+ filterable = !1;
11
+ placeholder = "请选择";
12
+ labelField = "label";
13
+ valueField = "value";
14
+ multiple = !1;
15
+ collapseTags = !1;
16
+ _loading = !1;
17
+ width;
18
+ clearable = !1;
19
+ _expanded = !1;
20
+ remote = !1;
21
+ filter;
22
+ options = [];
23
+ _backOptions;
24
+ inputHandler;
25
+ _popover;
26
+ _searchEl;
27
+ constructor() {
28
+ super(!0, !1);
29
+ }
30
+ connectedCallback() {
31
+ this.loadStyleText(f), super.connectedCallback();
32
+ }
33
+ setInputHandler(e) {
34
+ this.inputHandler = e;
35
+ }
36
+ setFilter(e) {
37
+ this.filter = e;
38
+ }
39
+ get loading() {
40
+ return this._loading;
41
+ }
42
+ set loading(e) {
43
+ this.setLoading(e ?? !1);
44
+ }
45
+ setLoading(e) {
46
+ this._loading = e;
47
+ let t = o(".l-select-loading", this.root);
48
+ e && (t || this.root.appendChild(a("l-loading-icon", { class: "l-select-loading" })), this.classList.add("l-select--loading")), t &&= (this.classList.remove("l-select--loading"), t.remove(), null);
49
+ }
50
+ get expanded() {
51
+ return this._expanded;
52
+ }
53
+ set expanded(e) {
54
+ this.setExpanded(e);
55
+ }
56
+ setExpanded(e) {
57
+ this._expanded = e, e ? (this.classList.add("l-select--expand"), this._searchEl && this._searchEl.focus()) : this.classList.remove("l-select--expand");
58
+ }
59
+ setValue(e) {
60
+ let t = e;
61
+ typeof e == "string" && (t = e.split(",")), this.multiple ? Array.isArray(t) || (t = [t]) : Array.isArray(t) && (t = t[0]), super.setValue(t), this._updateSelectedLabels(), this._reRenderLabels();
62
+ }
63
+ _updateSelectedLabels() {
64
+ if (this.options) {
65
+ this.selectedLabels = this.options.filter((e) => this._isOptionSelect(e[this.valueField])).map((e) => e[this.labelField]);
66
+ return;
67
+ }
68
+ this.selectedLabels = [];
69
+ }
70
+ static get observedAttributes() {
71
+ return [
72
+ "disabled",
73
+ "value",
74
+ "multiple",
75
+ "placeholder",
76
+ "collapse-tags",
77
+ "filterable",
78
+ "loading",
79
+ "label-field",
80
+ "value-field",
81
+ "width",
82
+ "clearable",
83
+ "expanded",
84
+ "remote"
85
+ ];
86
+ }
87
+ attributeChange(n, r, i) {
88
+ n = e(n);
89
+ let a = t(i, this[n], n);
90
+ if (a !== this[n] && (this[n] = a), this.rendered) switch (n) {
91
+ case "width":
92
+ a ? this.style.setProperty("--l-select-width", a) : this.style.removeProperty("--l-select-width");
93
+ break;
94
+ }
95
+ }
96
+ setOptions(e) {
97
+ this.options = e, this._backOptions = [...e], this._popover && this.expanded && this._popover.updatePopoverContent();
98
+ }
99
+ _isOptionSelect(e) {
100
+ let t = !1;
101
+ return e != null && this.value != null && (t = this.multiple ? this.value.includes(e) : e === this.value), t;
102
+ }
103
+ _updateOptionSelect(e, t) {
104
+ let n = o(".l-select-icon", e);
105
+ t ? (e.classList.add("l-select-option--selected"), n || a("l-select-icon", { class: "l-select-icon" }, e)) : (e.classList.remove("l-select-option--selected"), n && n.remove());
106
+ }
107
+ _renderOption() {
108
+ let e = [];
109
+ if (this.options) {
110
+ let t = this.options.length;
111
+ for (let n = 0; n < t; n++) {
112
+ let t = this.options[n], r = this._isOptionSelect(t[this.valueField]), i = a("li", {
113
+ class: ["l-select-option", r ? "l-select-option--selected" : void 0],
114
+ "data-action": `${n}`
115
+ });
116
+ a("span", {
117
+ class: "l-select-option-content",
118
+ textContent: t[this.labelField],
119
+ title: t[this.labelField]
120
+ }, i), r && a("l-select-icon", { class: "l-select-icon" }, i), e.push(i.outerHTML);
121
+ }
122
+ }
123
+ if (e.length === 0) {
124
+ let t = a("li", {
125
+ class: "l-select-option l-select-option--empty",
126
+ textContent: "暂无数据"
127
+ });
128
+ e.push(t.outerHTML);
129
+ }
130
+ return e.join("");
131
+ }
132
+ _calculateOffset(e, t) {
133
+ let n = e.getBoundingClientRect(), r = t.getBoundingClientRect();
134
+ return n.top - r.top + t.scrollTop;
135
+ }
136
+ isEmpty() {
137
+ let e = !0;
138
+ return !this.multiple && this.value != null && this.value !== "" && (e = !1), this.multiple && this.value && this.value.length > 0 && (e = !1), e;
139
+ }
140
+ _toggleClearable(e = !1) {
141
+ if (this.clearable) {
142
+ let t = o(".l-select-clear", this.root);
143
+ if (e || this.isEmpty() || this.loading) {
144
+ t && t.remove(), this.classList.remove("l-select--clearable");
145
+ return;
146
+ }
147
+ t || a("l-close-filled-icon", {
148
+ class: "l-select-clear",
149
+ "data-action": "clear"
150
+ }, this.root), this.classList.add("l-select--clearable");
151
+ }
152
+ }
153
+ _onMouseEnter = () => {
154
+ this._toggleClearable(!1);
155
+ };
156
+ _onMouseLeave = () => {
157
+ this._toggleClearable(!0);
158
+ };
159
+ _togglePopover() {
160
+ if (this._popover) {
161
+ if (this._popover.isShow()) {
162
+ this._popover.hide();
163
+ return;
164
+ }
165
+ this._popover.show(this);
166
+ }
167
+ }
168
+ _updatePopoverContent() {
169
+ this._popover && this.expanded && this._popover.updatePopoverContent();
170
+ }
171
+ _onRootTap = (e) => {
172
+ e.stopPropagation();
173
+ let [t, n, r] = u(e, "data-action", e.currentTarget);
174
+ if (t) {
175
+ if (n === "clear") this.value = this.multiple ? [] : "", this.selectedLabels = [], this._toggleClearable(!0), this._reRenderLabels(), this._updatePopoverContent();
176
+ else {
177
+ let e = Number(n);
178
+ this.selectedLabels.splice(e, 1), this._value.splice(e, 1), this._updatePopoverContent(), this.collapseTags ? this._reRenderLabels() : r.parentElement && (r.parentElement.remove(), this._updateSearchValue()), this._searchEl && this._searchEl.focus();
179
+ }
180
+ return;
181
+ }
182
+ this._togglePopover();
183
+ };
184
+ _onTap = () => {
185
+ this._togglePopover();
186
+ };
187
+ _onSearchBlur = () => {
188
+ this._updateSearchValue();
189
+ };
190
+ _onSearchInput = (e) => {
191
+ if (this.inputHandler && this.filterable) {
192
+ let t = e.target.value;
193
+ this.inputHandler(t);
194
+ }
195
+ };
196
+ _handleFilte = (e) => {
197
+ if (this.remote) {
198
+ this.emit("search", { detail: { value: e } });
199
+ return;
200
+ }
201
+ this.options = this._filteOption(e), this._popover && this.expanded && this._popover.updatePopoverContent();
202
+ };
203
+ _filteOption(e) {
204
+ let t = [];
205
+ return this._backOptions && (t = this._backOptions.filter((t) => e ? this.filter ? this.filter(e, t) : t[this.labelField].includes(e) : !0)), t;
206
+ }
207
+ afterInit() {
208
+ l(this, "mouseenter", this._onMouseEnter), l(this, "mouseleave", this._onMouseLeave), l(this.root, "click", this._onRootTap), l(this, "click", this._onTap), this._searchEl = o(".l-select-filter", this.root), this._searchEl && (this.inputHandler = d(this._handleFilte, 300), l(this._searchEl, "input", this._onSearchInput), l(this._searchEl, "blur", this._onSearchBlur)), this.disabledChange(), this.width && this.style.setProperty("--l-select-width", this.width), this._popover ||= new r({
209
+ arrow: !1,
210
+ offset: 2,
211
+ placement: "bottom",
212
+ popoverWidth: "trigger",
213
+ trigger: "manual",
214
+ theme: "select",
215
+ disabled: this.isDisabled(),
216
+ contentRender() {
217
+ return "<ul class=\"l-select-list\"></ul>";
218
+ },
219
+ updateContent: (e) => {
220
+ let t = o(".l-select-list", e);
221
+ t && (t.innerHTML = this._renderOption());
222
+ },
223
+ onOpenChange: (e) => {
224
+ this.setExpanded(e);
225
+ },
226
+ onPopoverAction: (e, t) => {
227
+ if (e && this.options) {
228
+ let n = Number(e), r = this.options[n], a = r[this.valueField], o = r[this.labelField], c = this.value, l = this.selectedLabels;
229
+ if (this.multiple === !0) if (!c) c = [a], l = [o];
230
+ else if (Array.isArray(c)) {
231
+ let e = c.indexOf(a);
232
+ e === -1 ? (c.push(a), l.push(o)) : (c.splice(e, 1), l.splice(e, 1));
233
+ } else c != a && (c = [c, a], l = [l, o]);
234
+ else c = a, l = [o];
235
+ this._value = c, this.selectedLabels = l;
236
+ let u = this._isOptionSelect(a);
237
+ this.multiple || s(i(".l-select-option--selected", t.parentElement), (e) => {
238
+ this._updateOptionSelect(e, !1);
239
+ }), this._updateOptionSelect(t, u), this._reRenderLabels(), !this.multiple && this._popover && this._popover.hide(), this._searchEl && this.multiple && this._searchEl.focus();
240
+ }
241
+ }
242
+ });
243
+ }
244
+ beforeDestroy() {
245
+ if (c(this, "mouseenter", this._onMouseEnter), c(this, "mouseleave", this._onMouseLeave), c(this.root, "click", this._onRootTap), c(this, "click", this._onTap), this.options = void 0, this._popover &&= (this._popover.destroy(), void 0), this._searchEl) {
246
+ if (c(this._searchEl, "blur", this._onSearchBlur), c(this._searchEl, "input", this._onSearchInput), this.inputHandler) {
247
+ try {
248
+ this.inputHandler.cancel();
249
+ } catch {}
250
+ this.inputHandler = void 0;
251
+ }
252
+ this._searchEl = void 0;
253
+ }
254
+ this.filter = void 0;
255
+ }
256
+ render() {
257
+ let e = document.createDocumentFragment(), t = a("div", { class: "l-select-main" }), n = this._renderSelectedLabels();
258
+ if (t.appendChild(n), this.filterable) {
259
+ let e = this.placeholder || "请选择", n = "";
260
+ this.selectedLabels.length > 0 && (this.multiple ? e = "" : (e = this.selectedLabels[0], n = this.selectedLabels[0])), t.appendChild(a("input", {
261
+ class: "l-select-filter",
262
+ placeholder: e,
263
+ value: n
264
+ }));
265
+ }
266
+ e.appendChild(t);
267
+ let r = a("l-arrow-down-icon", { class: "l-select-arrow" });
268
+ return e.appendChild(r), e;
269
+ }
270
+ disabledChange() {
271
+ if (!this.rendered) return;
272
+ let e = this.isDisabled();
273
+ this._popover && this._popover.setOption("disabled", e), e ? this.classList.add("l-select--disabled") : this.classList.remove("l-select--disabled"), this._searchEl && (this._searchEl.disabled = e);
274
+ }
275
+ _renderTag(e, t = 0, n = !0) {
276
+ let r = a("l-tag", {
277
+ type: "info",
278
+ class: "l-selected-item",
279
+ textContent: e
280
+ });
281
+ if (n) {
282
+ let e = a("div", {
283
+ class: "l-select-tag-close",
284
+ slot: "suffix",
285
+ innerHTML: "<l-close-icon></l-close-icon>",
286
+ "data-action": `${t}`
287
+ });
288
+ r.appendChild(e);
289
+ }
290
+ return r;
291
+ }
292
+ _reRenderLabels() {
293
+ let e = o(".l-select-main", this.root);
294
+ if (e) {
295
+ let t = i(".l-selected-item", e);
296
+ t.length > 0 && s(t, (e) => {
297
+ e && e != this._searchEl && e.remove();
298
+ });
299
+ let n = this._renderSelectedLabels();
300
+ this._searchEl ? e.insertBefore(n, this._searchEl) : e.appendChild(n);
301
+ }
302
+ this._updateSearchValue();
303
+ }
304
+ _updateSearchValue() {
305
+ if (this._searchEl) {
306
+ let e = this.placeholder || "请选择", t = "";
307
+ this.selectedLabels.length > 0 && (this.multiple ? e = "" : (e = this.selectedLabels[0], t = this.selectedLabels[0])), this._searchEl.placeholder = e, this._searchEl.value = t;
308
+ }
309
+ }
310
+ _renderSelectedLabels() {
311
+ let e = document.createDocumentFragment(), t = this.selectedLabels.length;
312
+ if (t > 0) if (!this.multiple) this.filterable || e.appendChild(a("span", {
313
+ class: "l-selected-item",
314
+ textContent: this.selectedLabels[0]
315
+ }));
316
+ else if (this.collapseTags) e.appendChild(this._renderTag(this.selectedLabels[0])), t > 1 && e.appendChild(this._renderTag(`+${t - 1}`, -1, !1));
317
+ else for (let n = 0; n < t; n++) e.appendChild(this._renderTag(this.selectedLabels[n], n));
318
+ else this.filterable || e.appendChild(a("span", {
319
+ class: "l-selected-item l-select-placeholder",
320
+ textContent: this.placeholder
321
+ }));
322
+ return e;
323
+ }
324
+ };
325
+ //#endregion
326
+ export { p as t };
@@ -1,51 +1,48 @@
1
- import a from "../form/form_inner.js";
2
- import { tagAttrs as c } from "../utils/index.js";
3
- import { $one as r, on as h, off as o } from "ph-utils/dom";
4
- import { i as d } from "../index-DY6m9Wbe.js";
5
- class v extends a {
6
- static baseName = "select-ori";
7
- $select;
8
- connectedCallback() {
9
- this.loadStyleText(d), super.connectedCallback(), this.$select = r("select", this.root), this.value && (this.$select.value = this.value), h(this.$select, "change", this._handleChange);
10
- }
11
- disconnectedCallback() {
12
- super.disconnectedCallback(), this.$select && o(this.$select, "change", this._handleChange), this.$select = void 0;
13
- }
14
- render() {
15
- let e = this.innerHTML.trim();
16
- return `<select class="l-input__inner"${c([
17
- ["name", this.getName()],
18
- ["disabled", this.isDisabled()]
19
- ])}>${e}</select>`;
20
- }
21
- disabledChange() {
22
- this.$select && (this.$select.disabled = this.isDisabled());
23
- }
24
- setOptions(e) {
25
- if (!this.$select) return;
26
- const t = e.map((s) => `<option value="${s.value}">${s.label}</option>`);
27
- this.$select.innerHTML = t.join("");
28
- }
29
- appendOptions(e) {
30
- if (!this.$select) return;
31
- const t = document.createDocumentFragment();
32
- for (let s = 0, n = e.length; s < n; s++) {
33
- const l = e[s], i = document.createElement("option");
34
- i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
35
- }
36
- this.$select.appendChild(t);
37
- }
38
- reset() {
39
- super.reset(), this.$select && (this.$select.value = this.value);
40
- }
41
- setValue(e) {
42
- super.setValue(e), this.$select && (this.$select.value = this.value);
43
- }
44
- _handleChange = (e) => {
45
- const t = e.target.value;
46
- super.setValue(t), this.dispatchEvent(new CustomEvent("change", { detail: t }));
47
- };
48
- }
49
- export {
50
- v as default
1
+ import { tagAttrs as e } from "../utils/index.js";
2
+ import { t } from "../form_inner-DR9tyB_r.js";
3
+ import { t as n } from "../input-DjKxcxry.js";
4
+ import { $one as r, off as i, on as a } from "ph-utils/dom";
5
+ //#region src/components/select_ori/index.ts
6
+ var o = class extends t {
7
+ static baseName = "select-ori";
8
+ $select;
9
+ connectedCallback() {
10
+ this.loadStyleText(n), super.connectedCallback(), this.$select = r("select", this.root), this.value && (this.$select.value = this.value), a(this.$select, "change", this._handleChange);
11
+ }
12
+ disconnectedCallback() {
13
+ super.disconnectedCallback(), this.$select && i(this.$select, "change", this._handleChange), this.$select = void 0;
14
+ }
15
+ render() {
16
+ let t = this.innerHTML.trim();
17
+ return `<select class="l-input__inner"${e([["name", this.getName()], ["disabled", this.isDisabled()]])}>${t}</select>`;
18
+ }
19
+ disabledChange() {
20
+ this.$select && (this.$select.disabled = this.isDisabled());
21
+ }
22
+ setOptions(e) {
23
+ if (!this.$select) return;
24
+ let t = e.map((e) => `<option value="${e.value}">${e.label}</option>`);
25
+ this.$select.innerHTML = t.join("");
26
+ }
27
+ appendOptions(e) {
28
+ if (!this.$select) return;
29
+ let t = document.createDocumentFragment();
30
+ for (let n = 0, r = e.length; n < r; n++) {
31
+ let r = e[n], i = document.createElement("option");
32
+ i.value = r.value, i.innerHTML = r.label, t.appendChild(i);
33
+ }
34
+ this.$select.appendChild(t);
35
+ }
36
+ reset() {
37
+ super.reset(), this.$select && (this.$select.value = this.value);
38
+ }
39
+ setValue(e) {
40
+ super.setValue(e), this.$select && (this.$select.value = this.value);
41
+ }
42
+ _handleChange = (e) => {
43
+ let t = e.target.value;
44
+ super.setValue(t), this.dispatchEvent(new CustomEvent("change", { detail: t }));
45
+ };
51
46
  };
47
+ //#endregion
48
+ export { o as default };
@@ -1,35 +1,2 @@
1
- import r from "../base.js";
2
- import { kebabToCamel as p, parseAttrValue as i } from "../utils/index.js";
3
- import { isNumeric as o } from "ph-utils";
4
- const c = ":host{box-sizing:border-box;display:var(--l-space-display, flex);align-items:var(--l-space-align, center);justify-content:var(--l-space-justify, flex-start);gap:var(--l-space-gap, 10px);flex-wrap:var(--l-space-wrap, nowrap);flex-direction:var(--l-space-direction, row)}";
5
- class u extends r {
6
- static baseName = "space";
7
- connectedCallback() {
8
- this.loadStyleText(c), super.connectedCallback();
9
- }
10
- static get observedAttributes() {
11
- return ["inline", "align", "justify", "gap", "direction", "wrap"];
12
- }
13
- attributeChangedCallback(e, y, l) {
14
- e = p(e);
15
- const t = i(l, this[e], e);
16
- if (e === "inline")
17
- i(l, !1, "inline") ? this.style.setProperty("--l-space-display", "inline-flex") : this.style.removeProperty("--l-space-display");
18
- else if (e === "gap")
19
- if (t) {
20
- const s = t.split(",").map((a) => o(a) ? `${a}px` : a);
21
- this.style.setProperty("--l-space-gap", s.join(" "));
22
- } else
23
- this.style.removeProperty("--l-space-gap");
24
- else {
25
- const s = `--l-space-${e}`;
26
- t ? this.style.setProperty(s, t) : this.style.removeProperty(s);
27
- }
28
- }
29
- render() {
30
- return "<slot></slot>";
31
- }
32
- }
33
- export {
34
- u as default
35
- };
1
+ import { t as e } from "../space-Bv-p0DL8.js";
2
+ export { e as default };
@@ -0,0 +1,38 @@
1
+ import e from "./base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n } from "./utils/index.js";
3
+ import { isNumeric as r } from "ph-utils";
4
+ //#region src/components/space/index.less?inline
5
+ var i = ":host{box-sizing:border-box;display:var(--l-space-display,flex);align-items:var(--l-space-align,center);justify-content:var(--l-space-justify,flex-start);gap:var(--l-space-gap,10px);flex-wrap:var(--l-space-wrap,nowrap);flex-direction:var(--l-space-direction,row)}", a = class extends e {
6
+ static baseName = "space";
7
+ connectedCallback() {
8
+ this.loadStyleText(i), super.connectedCallback();
9
+ }
10
+ static get observedAttributes() {
11
+ return [
12
+ "inline",
13
+ "align",
14
+ "justify",
15
+ "gap",
16
+ "direction",
17
+ "wrap"
18
+ ];
19
+ }
20
+ attributeChangedCallback(e, i, a) {
21
+ e = t(e);
22
+ let o = n(a, this[e], e);
23
+ if (e === "inline") n(a, !1, "inline") ? this.style.setProperty("--l-space-display", "inline-flex") : this.style.removeProperty("--l-space-display");
24
+ else if (e === "gap") if (o) {
25
+ let e = o.split(",").map((e) => r(e) ? `${e}px` : e);
26
+ this.style.setProperty("--l-space-gap", e.join(" "));
27
+ } else this.style.removeProperty("--l-space-gap");
28
+ else {
29
+ let t = `--l-space-${e}`;
30
+ o ? this.style.setProperty(t, o) : this.style.removeProperty(t);
31
+ }
32
+ }
33
+ render() {
34
+ return "<slot></slot>";
35
+ }
36
+ };
37
+ //#endregion
38
+ export { a as t };
@@ -1,50 +1,2 @@
1
- import { on as c, off as o, addClass as h, removeClass as n, $one as i } from "ph-utils/dom";
2
- import l from "../form/form_inner.js";
3
- import { initAttr as a } from "../utils/index.js";
4
- const r = ":host{display:inline-flex;width:auto;box-sizing:border-box}: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 f extends l {
6
- static baseName = "switch";
7
- actionRender;
8
- checkedText;
9
- uncheckedText;
10
- connectedCallback() {
11
- a(this), this.loadStyleText(r), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
12
- }
13
- disconnectedCallback() {
14
- super.disconnectedCallback(), o(this, "click", this.#e), this.actionRender = void 0;
15
- }
16
- render() {
17
- this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
18
- const t = ['<div class="l-switch-action" part="action"></div>'];
19
- if (this.checkedText || this.uncheckedText) {
20
- const e = this.value ? this.checkedText || "" : this.uncheckedText || "";
21
- t.push(`<span class="l-switch-text">${e}</span>`);
22
- }
23
- return t.join("");
24
- }
25
- #e = (t) => {
26
- this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
27
- };
28
- setValue(t) {
29
- super.setValue(t), t ? h(this, "l-switch--checked") : n(this, "l-switch--checked");
30
- const e = i(".l-switch-text", this.root);
31
- e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
32
- }
33
- setActionRender(t) {
34
- this.actionRender = t, this.#t();
35
- }
36
- #t() {
37
- const t = i(".l-switch-action", this.root);
38
- if (t)
39
- if (this.actionRender) {
40
- const e = this.actionRender({ checked: this.value });
41
- typeof e == "string" ? t.innerHTML = e : t.innerHTML = e.outerHTML;
42
- } else {
43
- const e = i('[slot="checked-action"]', this), s = i('[slot="unchecked-action"]', this);
44
- this.value && e ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && s && (t.innerHTML = '<slot name="unchecked-action"></slot>');
45
- }
46
- }
47
- }
48
- export {
49
- f as default
50
- };
1
+ import { t as e } from "../switch-BaVBi5Ip.js";
2
+ export { e as default };
@@ -0,0 +1,48 @@
1
+ import { initAttr as e } from "./utils/index.js";
2
+ import { t } from "./form_inner-DR9tyB_r.js";
3
+ import { $one as n, addClass as r, off as i, on as a, removeClass as o } from "ph-utils/dom";
4
+ //#region src/components/switch/index.less?inline
5
+ var s = ":host{box-sizing:border-box;--l-switch-height:22px;--l-switch-width:40px;width:auto;width:var(--l-switch-width);height:var(--l-switch-height);border-radius:calc(var(--l-switch-height) / 2);cursor:pointer;vertical-align:middle;background-color:#dcdfe6;border:1px solid #c2c2c2;justify-content:flex-start;align-items:center;padding:2px;transition:all .3s ease-in-out;display:inline-flex;position:relative}: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{width:calc(var(--l-switch-height) - 6px);box-sizing:border-box;background-color:#fff;border-radius:50%;justify-content:center;align-items:center;padding:2px;font-size:12px;transition:all .3s ease-in-out;display:flex;position:absolute;top:2px;bottom:2px;left:2px}.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}", c = class extends t {
6
+ static baseName = "switch";
7
+ actionRender;
8
+ checkedText;
9
+ uncheckedText;
10
+ connectedCallback() {
11
+ e(this), this.loadStyleText(s), super.connectedCallback(), this.pushValueChange(), this.#t(), a(this, "click", this.#e);
12
+ }
13
+ disconnectedCallback() {
14
+ super.disconnectedCallback(), i(this, "click", this.#e), this.actionRender = void 0;
15
+ }
16
+ render() {
17
+ this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
18
+ let e = ["<div class=\"l-switch-action\" part=\"action\"></div>"];
19
+ if (this.checkedText || this.uncheckedText) {
20
+ let t = this.value ? this.checkedText || "" : this.uncheckedText || "";
21
+ e.push(`<span class="l-switch-text">${t}</span>`);
22
+ }
23
+ return e.join("");
24
+ }
25
+ #e = (e) => {
26
+ this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
27
+ };
28
+ setValue(e) {
29
+ super.setValue(e), e ? r(this, "l-switch--checked") : o(this, "l-switch--checked");
30
+ let t = n(".l-switch-text", this.root);
31
+ t && (t.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
32
+ }
33
+ setActionRender(e) {
34
+ this.actionRender = e, this.#t();
35
+ }
36
+ #t() {
37
+ let e = n(".l-switch-action", this.root);
38
+ if (e) if (this.actionRender) {
39
+ let t = this.actionRender({ checked: this.value });
40
+ typeof t == "string" ? e.innerHTML = t : e.innerHTML = t.outerHTML;
41
+ } else {
42
+ let t = n("[slot=\"checked-action\"]", this), r = n("[slot=\"unchecked-action\"]", this);
43
+ this.value && t ? e.innerHTML = "<slot name=\"checked-action\"></slot>" : !this.value && r && (e.innerHTML = "<slot name=\"unchecked-action\"></slot>");
44
+ }
45
+ }
46
+ };
47
+ //#endregion
48
+ export { c as t };