litos-ui 0.15.6 → 0.15.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/button/index.d.ts +4 -0
- package/lib/button/index.js +88 -61
- package/lib/check/check.js +6 -7
- package/lib/check/checkbox.js +1 -1
- package/lib/check/radio.js +10 -6
- package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
- package/lib/collapse/index.d.ts +19 -0
- package/lib/collapse/index.js +88 -0
- package/lib/collapse/item.d.ts +15 -0
- package/lib/collapse/item.js +115 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/date_picker/index.js +1 -1
- package/lib/description_panel/index.d.ts +4 -4
- package/lib/description_panel/index.js +59 -11
- package/lib/dialog/dialog_container.js +1 -1
- package/lib/form/form_inner.d.ts +5 -1
- package/lib/form/form_inner.js +33 -27
- package/lib/form/form_item.js +9 -9
- package/lib/icon/d_arrow_left.d.ts +6 -0
- package/lib/icon/d_arrow_left.js +13 -0
- package/lib/icon/d_arrow_right.d.ts +6 -0
- package/lib/icon/d_arrow_right.js +13 -0
- package/lib/icon/more.d.ts +6 -0
- package/lib/icon/more.js +13 -0
- package/lib/icon/select.d.ts +6 -0
- package/lib/icon/select.js +13 -0
- package/lib/icon/zoom_in.d.ts +6 -0
- package/lib/icon/zoom_in.js +13 -0
- package/lib/icon/zoom_out.d.ts +6 -0
- package/lib/icon/zoom_out.js +13 -0
- package/lib/image/image_preview.d.ts +24 -0
- package/lib/image/image_preview.js +104 -0
- package/lib/image/index.d.ts +50 -0
- package/lib/image/index.js +176 -0
- package/lib/index-D4II9KsF.js +4 -0
- package/lib/index.d.ts +36 -4
- package/lib/index.js +157 -120
- package/lib/input/index.d.ts +5 -0
- package/lib/input/index.js +93 -71
- package/lib/litos-ui.css +1 -1
- package/lib/mask/index.d.ts +23 -0
- package/lib/mask/index.js +110 -0
- package/lib/md_input/index.js +11 -11
- package/lib/message/index.js +2 -2
- package/lib/modal/index.d.ts +1 -1
- package/lib/modal/index.js +7 -7
- package/lib/modal/modal_box.js +10 -10
- package/lib/page_header/index.d.ts +20 -0
- package/lib/page_header/index.js +109 -0
- package/lib/pagination/index.d.ts +27 -0
- package/lib/pagination/index.js +248 -0
- package/lib/qrcode/index.js +4 -4
- package/lib/select/index.d.ts +79 -0
- package/lib/select/index.js +406 -0
- package/lib/select_ori/index.js +1 -1
- package/lib/switch/index.js +4 -4
- package/lib/tabbar/index.d.ts +3 -1
- package/lib/tabbar/index.js +14 -8
- package/lib/tabbar/item.js +1 -1
- package/lib/table/index.d.ts +63 -0
- package/lib/table/index.js +260 -0
- package/lib/table/types.d.ts +36 -0
- package/lib/tabs/index.d.ts +7 -0
- package/lib/tabs/index.js +43 -0
- package/lib/tag/index.d.ts +16 -0
- package/lib/tag/index.js +80 -0
- package/lib/theme/index.js +6 -6
- package/lib/utils/index.d.ts +6 -28
- package/lib/utils/index.js +61 -86
- package/lib/utils/popover.d.ts +137 -0
- package/lib/utils/popover.js +354 -0
- package/lib/utils/transition.js +26 -50
- package/package.json +71 -71
- package/styles/popover.css +66 -0
- package/styles/reset.css +1 -1
- package/styles/select.css +37 -0
- package/styles/tabs.css +13 -0
- package/styles/vars.css +2 -1
- package/lib/index-dwS1N2uN.js +0 -4
- package/lib/popconfirm/index.d.ts +0 -7
- package/lib/popconfirm/index.js +0 -30
- package/lib/popover/index.d.ts +0 -34
- package/lib/popover/index.js +0 -150
- /package/lib/{menu/base.js → table/types.js} +0 -0
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { kebabToCamel as g, parseAttrValue as v } from "../utils/index.js";
|
|
2
|
+
import { $one as c, $$ as o, shouldEventNext as m, on as h, $ as f, iterate as u, off as d } from "ph-utils/dom";
|
|
3
|
+
import x from "../form/form_inner.js";
|
|
4
|
+
import { Popover as L } from "../utils/popover.js";
|
|
5
|
+
import { debounce as w } from "ph-utils/web";
|
|
6
|
+
const C = ":host{--l-select-width: 100%;display:inline-flex;min-height:var(--l-form-control-height, 32px);width:var(--l-select-width);border:1px solid var(--l-border-color, #d9d9d9);transition:border-color .3s;font-size:14px;position:relative;cursor:pointer;align-items:center;padding:4px 10px;border-radius:4px;gap:5px;justify-content:space-between;line-height:1;box-sizing:border-box}: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:rotate3d(0,0,1,180deg)}:host(.l-select--loading) .l-select-arrow{opacity:.2}:host(.l-select--clearable) .l-select-arrow{opacity:0}.l-select-main{display:flex;flex-flow:row wrap;gap:5px;overflow:hidden;box-sizing:border-box;flex-grow:1}.l-selected-item{flex-shrink:0}.l-select-placeholder{flex-grow:1}.l-select-placeholder,.l-select-arrow{color:#a8abb2}.l-select-filter{flex-shrink:0;flex-grow:1;min-width:15px;max-width:100%;width:0;background-color:transparent;outline:none;border:none}.l-select-filter::placeholder{color:#a8abb2}.l-select-arrow{flex-shrink:0;transition:transform .3s,opacity .3s;transform:rotate3d(0,0,1,0)}.l-select-tag-close{display:inline-flex;width:14px;height:14px;border-radius:50%;box-sizing:border-box;justify-content:center;align-items:center;transition:color .3s,background-color .3s;cursor:pointer;margin-left:3px;font-size:12px}.l-select-tag-close:hover{background-color:#999;color:#fff}.l-select-clear,.l-select-loading{position:absolute;right:10px;top:50%;transform:translate3d(0,-50%,0)}.l-select-loading{color:var(--l-primary-color, #722ed1);animation:l-select-loading 1.5s infinite linear;z-index:2}.l-select-clear{color:#afafaf;z-index:1}@keyframes l-select-loading{0%{transform:translate3d(0,-50%,0) rotate3d(0,0,1,0)}to{transform:translate3d(0,-50%,0) rotate3d(0,0,1,360deg)}}";
|
|
7
|
+
class O extends x {
|
|
8
|
+
static baseName = "select";
|
|
9
|
+
/** 选中的标签 */
|
|
10
|
+
selectedLabels = [];
|
|
11
|
+
/** 是否启用过滤 */
|
|
12
|
+
filterable = !1;
|
|
13
|
+
placeholder = "请选择";
|
|
14
|
+
/** 选项 label 的字段名 */
|
|
15
|
+
labelField = "label";
|
|
16
|
+
/** 选项 value 的字段名 */
|
|
17
|
+
valueField = "value";
|
|
18
|
+
/** 是否支持多选 */
|
|
19
|
+
multiple = !1;
|
|
20
|
+
/** 多选时是否折叠标签 */
|
|
21
|
+
collapseTags = !1;
|
|
22
|
+
/** 是否加载中, 远程搜索时使用 */
|
|
23
|
+
_loading = !1;
|
|
24
|
+
/** 宽度 */
|
|
25
|
+
width;
|
|
26
|
+
/** 是否可清除 */
|
|
27
|
+
clearable = !1;
|
|
28
|
+
/** 是否展开下拉选择 */
|
|
29
|
+
_expanded = !1;
|
|
30
|
+
remote = !1;
|
|
31
|
+
filter;
|
|
32
|
+
options = [];
|
|
33
|
+
_backOptions;
|
|
34
|
+
inputHandler;
|
|
35
|
+
_popover;
|
|
36
|
+
_searchEl;
|
|
37
|
+
constructor() {
|
|
38
|
+
super(!0, !1);
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.loadStyleText(C), super.connectedCallback();
|
|
42
|
+
}
|
|
43
|
+
setInputHandler(e) {
|
|
44
|
+
this.inputHandler = e;
|
|
45
|
+
}
|
|
46
|
+
setFilter(e) {
|
|
47
|
+
this.filter = e;
|
|
48
|
+
}
|
|
49
|
+
get loading() {
|
|
50
|
+
return this._loading;
|
|
51
|
+
}
|
|
52
|
+
set loading(e) {
|
|
53
|
+
this.setLoading(e ?? !1);
|
|
54
|
+
}
|
|
55
|
+
setLoading(e) {
|
|
56
|
+
this._loading = e;
|
|
57
|
+
let t = c(".l-select-loading", this.root);
|
|
58
|
+
e && (t || this.root.appendChild(
|
|
59
|
+
o("l-loading-icon", { class: "l-select-loading" })
|
|
60
|
+
), this.classList.add("l-select--loading")), t && (this.classList.remove("l-select--loading"), t.remove(), t = null);
|
|
61
|
+
}
|
|
62
|
+
get expanded() {
|
|
63
|
+
return this._expanded;
|
|
64
|
+
}
|
|
65
|
+
set expanded(e) {
|
|
66
|
+
this.setExpanded(e);
|
|
67
|
+
}
|
|
68
|
+
setExpanded(e) {
|
|
69
|
+
this._expanded = e, e ? (this.classList.add("l-select--expand"), this._searchEl && this._searchEl.focus()) : this.classList.remove("l-select--expand");
|
|
70
|
+
}
|
|
71
|
+
setValue(e) {
|
|
72
|
+
let t = e;
|
|
73
|
+
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();
|
|
74
|
+
}
|
|
75
|
+
_updateSelectedLabels() {
|
|
76
|
+
if (this.options) {
|
|
77
|
+
this.selectedLabels = this.options.filter((e) => this._isOptionSelect(e[this.valueField])).map((e) => e[this.labelField]);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
this.selectedLabels = [];
|
|
81
|
+
}
|
|
82
|
+
static get observedAttributes() {
|
|
83
|
+
return [
|
|
84
|
+
"disabled",
|
|
85
|
+
"value",
|
|
86
|
+
"multiple",
|
|
87
|
+
"placeholder",
|
|
88
|
+
"collapse-tags",
|
|
89
|
+
"filterable",
|
|
90
|
+
"loading",
|
|
91
|
+
"label-field",
|
|
92
|
+
"value-field",
|
|
93
|
+
"width",
|
|
94
|
+
"clearable",
|
|
95
|
+
"expanded",
|
|
96
|
+
"remote"
|
|
97
|
+
];
|
|
98
|
+
}
|
|
99
|
+
attributeChange(e, t, l) {
|
|
100
|
+
e = g(e);
|
|
101
|
+
const s = v(
|
|
102
|
+
l,
|
|
103
|
+
this[e],
|
|
104
|
+
e
|
|
105
|
+
);
|
|
106
|
+
if (s !== this[e] && (this[e] = s), this.rendered)
|
|
107
|
+
switch (e) {
|
|
108
|
+
case "width":
|
|
109
|
+
s ? this.style.setProperty("--l-select-width", s) : this.style.removeProperty("--l-select-width");
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
setOptions(e) {
|
|
114
|
+
this.options = e, this._backOptions = [...e], this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
115
|
+
}
|
|
116
|
+
_isOptionSelect(e) {
|
|
117
|
+
let t = !1;
|
|
118
|
+
return e != null && this.value != null && (this.multiple ? t = this.value.includes(e) : t = e === this.value), t;
|
|
119
|
+
}
|
|
120
|
+
_updateOptionSelect(e, t) {
|
|
121
|
+
let l = c(".l-select-icon", e);
|
|
122
|
+
t ? (e.classList.add("l-select-option--selected"), l || o(
|
|
123
|
+
"l-select-icon",
|
|
124
|
+
{
|
|
125
|
+
class: "l-select-icon"
|
|
126
|
+
},
|
|
127
|
+
e
|
|
128
|
+
)) : (e.classList.remove("l-select-option--selected"), l && l.remove());
|
|
129
|
+
}
|
|
130
|
+
_renderOption() {
|
|
131
|
+
const e = [];
|
|
132
|
+
if (this.options) {
|
|
133
|
+
const t = this.options.length;
|
|
134
|
+
for (let l = 0; l < t; l++) {
|
|
135
|
+
const s = this.options[l], i = this._isOptionSelect(
|
|
136
|
+
s[this.valueField]
|
|
137
|
+
), a = o("li", {
|
|
138
|
+
class: [
|
|
139
|
+
"l-select-option",
|
|
140
|
+
i ? "l-select-option--selected" : void 0
|
|
141
|
+
],
|
|
142
|
+
"data-action": `${l}`
|
|
143
|
+
});
|
|
144
|
+
o(
|
|
145
|
+
"span",
|
|
146
|
+
{
|
|
147
|
+
class: "l-select-option-content",
|
|
148
|
+
textContent: s[this.labelField],
|
|
149
|
+
title: s[this.labelField]
|
|
150
|
+
},
|
|
151
|
+
a
|
|
152
|
+
), i && o(
|
|
153
|
+
"l-select-icon",
|
|
154
|
+
{
|
|
155
|
+
class: "l-select-icon"
|
|
156
|
+
},
|
|
157
|
+
a
|
|
158
|
+
), e.push(a.outerHTML);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
if (e.length === 0) {
|
|
162
|
+
const t = o("li", {
|
|
163
|
+
class: "l-select-option l-select-option--empty",
|
|
164
|
+
textContent: "暂无数据"
|
|
165
|
+
});
|
|
166
|
+
e.push(t.outerHTML);
|
|
167
|
+
}
|
|
168
|
+
return e.join("");
|
|
169
|
+
}
|
|
170
|
+
_calculateOffset(e, t) {
|
|
171
|
+
const l = e.getBoundingClientRect(), s = t.getBoundingClientRect();
|
|
172
|
+
return l.top - s.top + t.scrollTop;
|
|
173
|
+
}
|
|
174
|
+
isEmpty() {
|
|
175
|
+
let e = !0;
|
|
176
|
+
return !this.multiple && this.value != null && this.value !== "" && (e = !1), this.multiple && this.value && this.value.length > 0 && (e = !1), e;
|
|
177
|
+
}
|
|
178
|
+
_toggleClearable(e = !1) {
|
|
179
|
+
if (this.clearable) {
|
|
180
|
+
let t = c(".l-select-clear", this.root);
|
|
181
|
+
if (e || this.isEmpty() || this.loading) {
|
|
182
|
+
t && t.remove(), this.classList.remove("l-select--clearable");
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
t || o(
|
|
186
|
+
"l-close-filled-icon",
|
|
187
|
+
{
|
|
188
|
+
class: "l-select-clear",
|
|
189
|
+
"data-action": "clear"
|
|
190
|
+
},
|
|
191
|
+
this.root
|
|
192
|
+
), this.classList.add("l-select--clearable");
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
_onMouseEnter = () => {
|
|
196
|
+
this._toggleClearable(!1);
|
|
197
|
+
};
|
|
198
|
+
_onMouseLeave = () => {
|
|
199
|
+
this._toggleClearable(!0);
|
|
200
|
+
};
|
|
201
|
+
_togglePopover() {
|
|
202
|
+
if (this._popover) {
|
|
203
|
+
if (this._popover.isShow()) {
|
|
204
|
+
this._popover.hide();
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
this._popover.show(this);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
_updatePopoverContent() {
|
|
211
|
+
this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
212
|
+
}
|
|
213
|
+
_onRootTap = (e) => {
|
|
214
|
+
e.stopPropagation();
|
|
215
|
+
const [t, l, s] = m(
|
|
216
|
+
e,
|
|
217
|
+
"data-action",
|
|
218
|
+
e.currentTarget
|
|
219
|
+
);
|
|
220
|
+
if (t) {
|
|
221
|
+
if (l === "clear")
|
|
222
|
+
this.value = this.multiple ? [] : "", this.selectedLabels = [], this._toggleClearable(!0), this._reRenderLabels(), this._updatePopoverContent();
|
|
223
|
+
else {
|
|
224
|
+
const i = Number(l);
|
|
225
|
+
this.selectedLabels.splice(i, 1), this._value.splice(i, 1), this._updatePopoverContent(), this.collapseTags ? this._reRenderLabels() : s.parentElement && (s.parentElement.remove(), this._updateSearchValue()), this._searchEl && this._searchEl.focus();
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
this._togglePopover();
|
|
230
|
+
};
|
|
231
|
+
_onTap = () => {
|
|
232
|
+
this._togglePopover();
|
|
233
|
+
};
|
|
234
|
+
_onSearchBlur = () => {
|
|
235
|
+
this._updateSearchValue();
|
|
236
|
+
};
|
|
237
|
+
_onSearchInput = (e) => {
|
|
238
|
+
if (this.inputHandler && this.filterable) {
|
|
239
|
+
const t = e.target.value;
|
|
240
|
+
this.inputHandler(t);
|
|
241
|
+
}
|
|
242
|
+
};
|
|
243
|
+
_handleFilte = (e) => {
|
|
244
|
+
if (this.remote) {
|
|
245
|
+
this.emit("search", { detail: { value: e } });
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.options = this._filteOption(e), this._popover && this.expanded && this._popover.updatePopoverContent();
|
|
249
|
+
};
|
|
250
|
+
_filteOption(e) {
|
|
251
|
+
let t = [];
|
|
252
|
+
return this._backOptions && (t = this._backOptions.filter((l) => e ? this.filter ? this.filter(e, l) : l[this.labelField].includes(e) : !0)), t;
|
|
253
|
+
}
|
|
254
|
+
afterInit() {
|
|
255
|
+
h(this, "mouseenter", this._onMouseEnter), h(this, "mouseleave", this._onMouseLeave), h(this.root, "click", this._onRootTap), h(this, "click", this._onTap), this._searchEl = c(".l-select-filter", this.root), this._searchEl && (this.inputHandler = w(this._handleFilte, 300), h(this._searchEl, "input", this._onSearchInput), h(this._searchEl, "blur", this._onSearchBlur)), this.disabledChange(), this.width && this.style.setProperty("--l-select-width", this.width), this._popover || (this._popover = new L({
|
|
256
|
+
arrow: !1,
|
|
257
|
+
offset: 2,
|
|
258
|
+
placement: "bottom",
|
|
259
|
+
popoverWidth: "trigger",
|
|
260
|
+
trigger: "manual",
|
|
261
|
+
theme: "select",
|
|
262
|
+
disabled: this.isDisabled(),
|
|
263
|
+
contentRender() {
|
|
264
|
+
return '<ul class="l-select-list"></ul>';
|
|
265
|
+
},
|
|
266
|
+
updateContent: (e) => {
|
|
267
|
+
const t = c(".l-select-list", e);
|
|
268
|
+
t && (t.innerHTML = this._renderOption());
|
|
269
|
+
},
|
|
270
|
+
onOpenChange: (e) => {
|
|
271
|
+
this.setExpanded(e);
|
|
272
|
+
},
|
|
273
|
+
onPopoverAction: (e, t) => {
|
|
274
|
+
if (e && this.options) {
|
|
275
|
+
const l = Number(e), s = this.options[l], i = s[this.valueField], a = s[this.labelField];
|
|
276
|
+
let r = this.value, n = this.selectedLabels;
|
|
277
|
+
if (this.multiple === !0)
|
|
278
|
+
if (!r)
|
|
279
|
+
r = [i], n = [a];
|
|
280
|
+
else if (Array.isArray(r)) {
|
|
281
|
+
const p = r.indexOf(i);
|
|
282
|
+
p !== -1 ? (r.splice(p, 1), n.splice(p, 1)) : (r.push(i), n.push(a));
|
|
283
|
+
} else
|
|
284
|
+
r != i && (r = [r, i], n = [n, a]);
|
|
285
|
+
else
|
|
286
|
+
r = i, n = [a];
|
|
287
|
+
this._value = r, this.selectedLabels = n;
|
|
288
|
+
const _ = this._isOptionSelect(i);
|
|
289
|
+
if (!this.multiple) {
|
|
290
|
+
const p = f(
|
|
291
|
+
".l-select-option--selected",
|
|
292
|
+
t.parentElement
|
|
293
|
+
);
|
|
294
|
+
u(p, (b) => {
|
|
295
|
+
this._updateOptionSelect(b, !1);
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
this._updateOptionSelect(t, _), this._reRenderLabels(), !this.multiple && this._popover && this._popover.hide(), this._searchEl && this.multiple && this._searchEl.focus();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}));
|
|
302
|
+
}
|
|
303
|
+
beforeDestroy() {
|
|
304
|
+
if (d(this, "mouseenter", this._onMouseEnter), d(this, "mouseleave", this._onMouseLeave), d(this.root, "click", this._onRootTap), d(this, "click", this._onTap), this.options = void 0, this._popover && (this._popover.destroy(), this._popover = void 0), this._searchEl) {
|
|
305
|
+
if (d(this._searchEl, "blur", this._onSearchBlur), d(this._searchEl, "input", this._onSearchInput), this.inputHandler) {
|
|
306
|
+
try {
|
|
307
|
+
this.inputHandler.cancel();
|
|
308
|
+
} catch {
|
|
309
|
+
}
|
|
310
|
+
this.inputHandler = void 0;
|
|
311
|
+
}
|
|
312
|
+
this._searchEl = void 0;
|
|
313
|
+
}
|
|
314
|
+
this.filter = void 0;
|
|
315
|
+
}
|
|
316
|
+
render() {
|
|
317
|
+
const e = document.createDocumentFragment(), t = o("div", {
|
|
318
|
+
class: "l-select-main"
|
|
319
|
+
}), l = this._renderSelectedLabels();
|
|
320
|
+
if (t.appendChild(l), this.filterable) {
|
|
321
|
+
let i = this.placeholder || "请选择", a = "";
|
|
322
|
+
this.selectedLabels.length > 0 && (this.multiple ? i = "" : (i = this.selectedLabels[0], a = this.selectedLabels[0])), t.appendChild(
|
|
323
|
+
o("input", {
|
|
324
|
+
class: "l-select-filter",
|
|
325
|
+
placeholder: i,
|
|
326
|
+
value: a
|
|
327
|
+
})
|
|
328
|
+
);
|
|
329
|
+
}
|
|
330
|
+
e.appendChild(t);
|
|
331
|
+
const s = o("l-arrow-down-icon", {
|
|
332
|
+
class: "l-select-arrow"
|
|
333
|
+
});
|
|
334
|
+
return e.appendChild(s), e;
|
|
335
|
+
}
|
|
336
|
+
disabledChange() {
|
|
337
|
+
if (!this.rendered) return;
|
|
338
|
+
const e = this.isDisabled();
|
|
339
|
+
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);
|
|
340
|
+
}
|
|
341
|
+
_renderTag(e, t = 0, l = !0) {
|
|
342
|
+
const s = o("l-tag", {
|
|
343
|
+
type: "info",
|
|
344
|
+
class: "l-selected-item",
|
|
345
|
+
textContent: e
|
|
346
|
+
});
|
|
347
|
+
if (l) {
|
|
348
|
+
const i = o("div", {
|
|
349
|
+
class: "l-select-tag-close",
|
|
350
|
+
slot: "suffix",
|
|
351
|
+
innerHTML: "<l-close-icon></l-close-icon>",
|
|
352
|
+
"data-action": `${t}`
|
|
353
|
+
});
|
|
354
|
+
s.appendChild(i);
|
|
355
|
+
}
|
|
356
|
+
return s;
|
|
357
|
+
}
|
|
358
|
+
_reRenderLabels() {
|
|
359
|
+
let e = c(".l-select-main", this.root);
|
|
360
|
+
if (e) {
|
|
361
|
+
const t = f(".l-selected-item", e);
|
|
362
|
+
t.length > 0 && u(t, (s) => {
|
|
363
|
+
s && s != this._searchEl && s.remove();
|
|
364
|
+
});
|
|
365
|
+
const l = this._renderSelectedLabels();
|
|
366
|
+
this._searchEl ? e.insertBefore(l, this._searchEl) : e.appendChild(l);
|
|
367
|
+
}
|
|
368
|
+
this._updateSearchValue();
|
|
369
|
+
}
|
|
370
|
+
_updateSearchValue() {
|
|
371
|
+
if (this._searchEl) {
|
|
372
|
+
let e = this.placeholder || "请选择", t = "";
|
|
373
|
+
this.selectedLabels.length > 0 && (this.multiple ? e = "" : (e = this.selectedLabels[0], t = this.selectedLabels[0])), this._searchEl.placeholder = e, this._searchEl.value = t;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
_renderSelectedLabels() {
|
|
377
|
+
const e = document.createDocumentFragment();
|
|
378
|
+
let t = this.selectedLabels.length;
|
|
379
|
+
if (t > 0)
|
|
380
|
+
if (!this.multiple)
|
|
381
|
+
this.filterable || e.appendChild(
|
|
382
|
+
o("span", {
|
|
383
|
+
class: "l-selected-item",
|
|
384
|
+
textContent: this.selectedLabels[0]
|
|
385
|
+
})
|
|
386
|
+
);
|
|
387
|
+
else if (this.collapseTags)
|
|
388
|
+
e.appendChild(this._renderTag(this.selectedLabels[0])), t > 1 && e.appendChild(
|
|
389
|
+
this._renderTag(`+${t - 1}`, -1, !1)
|
|
390
|
+
);
|
|
391
|
+
else
|
|
392
|
+
for (let l = 0; l < t; l++)
|
|
393
|
+
e.appendChild(this._renderTag(this.selectedLabels[l], l));
|
|
394
|
+
else
|
|
395
|
+
this.filterable || e.appendChild(
|
|
396
|
+
o("span", {
|
|
397
|
+
class: "l-selected-item l-select-placeholder",
|
|
398
|
+
textContent: this.placeholder
|
|
399
|
+
})
|
|
400
|
+
);
|
|
401
|
+
return e;
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
export {
|
|
405
|
+
O as default
|
|
406
|
+
};
|
package/lib/select_ori/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import a from "../form/form_inner.js";
|
|
2
2
|
import { tagAttrs as c } from "../utils/index.js";
|
|
3
3
|
import { $one as r, on as h, off as o } from "ph-utils/dom";
|
|
4
|
-
import { i as d } from "../index-
|
|
4
|
+
import { i as d } from "../index-D4II9KsF.js";
|
|
5
5
|
class v extends a {
|
|
6
6
|
static baseName = "select-ori";
|
|
7
7
|
$select;
|
package/lib/switch/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { on as c, off as
|
|
1
|
+
import { on as c, off as o, addClass as h, removeClass as n, $one as i } from "ph-utils/dom";
|
|
2
2
|
import l from "../form/form_inner.js";
|
|
3
3
|
import { initAttr as a } from "../utils/index.js";
|
|
4
|
-
const r = ":host{display:inline-flex;width:auto}: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}";
|
|
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
5
|
class f extends l {
|
|
6
6
|
static baseName = "switch";
|
|
7
7
|
actionRender;
|
|
@@ -11,7 +11,7 @@ class f extends l {
|
|
|
11
11
|
a(this), this.loadStyleText(r), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
|
|
12
12
|
}
|
|
13
13
|
disconnectedCallback() {
|
|
14
|
-
super.disconnectedCallback(),
|
|
14
|
+
super.disconnectedCallback(), o(this, "click", this.#e), this.actionRender = void 0;
|
|
15
15
|
}
|
|
16
16
|
render() {
|
|
17
17
|
this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
|
|
@@ -26,7 +26,7 @@ class f extends l {
|
|
|
26
26
|
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
27
27
|
};
|
|
28
28
|
setValue(t) {
|
|
29
|
-
super.setValue(t), t ?
|
|
29
|
+
super.setValue(t), t ? h(this, "l-switch--checked") : n(this, "l-switch--checked");
|
|
30
30
|
const e = i(".l-switch-text", this.root);
|
|
31
31
|
e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
|
|
32
32
|
}
|
package/lib/tabbar/index.d.ts
CHANGED
|
@@ -9,9 +9,11 @@ export default class Tabbar extends BaseComponent {
|
|
|
9
9
|
* 3. card - 卡片
|
|
10
10
|
*/
|
|
11
11
|
type: "nav" | "bar" | "card";
|
|
12
|
-
|
|
12
|
+
_name: string;
|
|
13
13
|
gap?: string;
|
|
14
14
|
private $line?;
|
|
15
|
+
get name(): string;
|
|
16
|
+
set name(nameValue: string);
|
|
15
17
|
connectedCallback(): void;
|
|
16
18
|
static get observedAttributes(): string[] | null | undefined;
|
|
17
19
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
package/lib/tabbar/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isBlank as h, isNumeric as c } from "ph-utils";
|
|
2
2
|
import d from "../base.js";
|
|
3
3
|
import { parseAttrValue as l } from "../utils/index.js";
|
|
4
|
-
import { addClass as b, removeClass as
|
|
4
|
+
import { addClass as b, removeClass as s, $one as r, create as n, $$ as p, on as f, off as m, shouldEventNext as u, isVisible as v } from "ph-utils/dom";
|
|
5
5
|
const g = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:flex;flex-wrap:nowrap;align-items:stretch;gap:var(--l-tabbar-item-gap);box-sizing:border-box}:host(.l-tabbar--nav){--l-tabbar-height: 50px;--l-tabbar-item-grow: 1;width:100%}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}";
|
|
6
6
|
class _ extends d {
|
|
7
7
|
static baseName = "tabbar";
|
|
@@ -12,9 +12,15 @@ class _ extends d {
|
|
|
12
12
|
* 3. card - 卡片
|
|
13
13
|
*/
|
|
14
14
|
type = "nav";
|
|
15
|
-
|
|
15
|
+
_name = "";
|
|
16
16
|
gap;
|
|
17
17
|
$line;
|
|
18
|
+
get name() {
|
|
19
|
+
return this._name;
|
|
20
|
+
}
|
|
21
|
+
set name(t) {
|
|
22
|
+
this._name = t;
|
|
23
|
+
}
|
|
18
24
|
connectedCallback() {
|
|
19
25
|
this.loadStyleText(g), b(this, `l-tabbar--${this.type}`), this.#t(), super.connectedCallback();
|
|
20
26
|
}
|
|
@@ -27,9 +33,9 @@ class _ extends d {
|
|
|
27
33
|
this.name = i, this._updateActive(), this._updateLine();
|
|
28
34
|
} else if (t === "type") {
|
|
29
35
|
const i = l(a, "nav");
|
|
30
|
-
if (i !== this.type && (
|
|
31
|
-
let
|
|
32
|
-
|
|
36
|
+
if (i !== this.type && (s(this, `l-tabbar--${this.type}`), this.type = i, s(this, `l-tabbar--${i}`), i === "card")) {
|
|
37
|
+
let o = r(".l-tabbar-card-border", this.root);
|
|
38
|
+
o || (o = n("div", { class: "l-tabbar-card-border" }), this.root.appendChild(o));
|
|
33
39
|
}
|
|
34
40
|
} else {
|
|
35
41
|
const i = l(a, void 0);
|
|
@@ -54,7 +60,7 @@ class _ extends d {
|
|
|
54
60
|
}
|
|
55
61
|
_handleClick = (t) => {
|
|
56
62
|
const [e, a] = u(t, "name", this);
|
|
57
|
-
e && a !== this.name && (this.name = a,
|
|
63
|
+
e && a !== this.name && (this.name = a, this.dispatchEvent(
|
|
58
64
|
new CustomEvent("change", {
|
|
59
65
|
detail: {
|
|
60
66
|
name: a
|
|
@@ -64,7 +70,7 @@ class _ extends d {
|
|
|
64
70
|
};
|
|
65
71
|
_updateActive() {
|
|
66
72
|
const t = r(".active", this);
|
|
67
|
-
t &&
|
|
73
|
+
t && s(t, "active");
|
|
68
74
|
const e = r(`[name="${this.name}"]`, this);
|
|
69
75
|
e && b(e, "active");
|
|
70
76
|
}
|
|
@@ -91,7 +97,7 @@ class _ extends d {
|
|
|
91
97
|
#t() {
|
|
92
98
|
const t = this.getAttr("justify-content");
|
|
93
99
|
if (h(t) ? this.style.removeProperty("justify-content") : this.style.setProperty("justify-content", t), h(this.gap))
|
|
94
|
-
this.style.removeProperty("--l-tabbar-item-gap"),
|
|
100
|
+
this.style.removeProperty("--l-tabbar-item-gap"), s(this, "l-tabbar-gap");
|
|
95
101
|
else {
|
|
96
102
|
let e = this.gap;
|
|
97
103
|
c(e, { isPositive: !0 }) && (e = `${e}px`), b(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
|
package/lib/tabbar/item.js
CHANGED
|
@@ -11,7 +11,7 @@ class m extends l {
|
|
|
11
11
|
return ["name", "label", "icon", "only-icon"];
|
|
12
12
|
}
|
|
13
13
|
connectedCallback() {
|
|
14
|
-
this.loadStyleText(d)
|
|
14
|
+
this.loadStyleText(d);
|
|
15
15
|
const t = this.parentElement;
|
|
16
16
|
t.gap && i(this, "l-item--gap"), t.type === "card" && i(this, "l-item--card"), super.connectedCallback();
|
|
17
17
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
import type { Column, SortOption } from "./types";
|
|
3
|
+
type ChangeFixedParams = {
|
|
4
|
+
fixedColumn?: boolean;
|
|
5
|
+
fixedHead?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default class Table extends BaseComponent {
|
|
8
|
+
static baseName: string;
|
|
9
|
+
/** 斑马纹 */
|
|
10
|
+
stripe: boolean;
|
|
11
|
+
/** 是否显示四周边框 */
|
|
12
|
+
border: boolean;
|
|
13
|
+
/** 是否固定表头 */
|
|
14
|
+
fixedHead: boolean;
|
|
15
|
+
/** 是否固定列,在进行列解析时,会自动确认该属性 */
|
|
16
|
+
fixedColumn: boolean;
|
|
17
|
+
/** 最大高度 */
|
|
18
|
+
maxHeight?: number | string;
|
|
19
|
+
/** 表格布局 */
|
|
20
|
+
tableLayout?: "auto" | "fixed";
|
|
21
|
+
columns?: Column[];
|
|
22
|
+
data?: any[];
|
|
23
|
+
sortInfo?: SortOption;
|
|
24
|
+
/** 缓存列通用样式, 避免渲染数据时,重复计算 */
|
|
25
|
+
private _globalColStyles?;
|
|
26
|
+
connectedCallback(): void;
|
|
27
|
+
setColumns(columns: Column[]): void;
|
|
28
|
+
setData(data: any[]): void;
|
|
29
|
+
setDefaultSort(sortInfo: SortOption): void;
|
|
30
|
+
changeFixed(params?: ChangeFixedParams): void;
|
|
31
|
+
static get observedAttributes(): string[];
|
|
32
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
33
|
+
render(): HTMLElement;
|
|
34
|
+
rerender(partial: "head" | "body" | "all"): void;
|
|
35
|
+
private _changeCssVar;
|
|
36
|
+
private _changeMaxHeight;
|
|
37
|
+
private _classAttrChannge;
|
|
38
|
+
private _updateFixedHead;
|
|
39
|
+
private _headRender;
|
|
40
|
+
private _rendHeadRow;
|
|
41
|
+
private _headColRender;
|
|
42
|
+
private _bodyRender;
|
|
43
|
+
private _bodyRowRender;
|
|
44
|
+
/**
|
|
45
|
+
* 解析列配置,表头跨行跨列、固定列
|
|
46
|
+
* @param columns 列配置
|
|
47
|
+
* @param leftOffset 左边固定列偏移
|
|
48
|
+
* @param rightOffset 右边固定列偏移
|
|
49
|
+
* @returns
|
|
50
|
+
*/
|
|
51
|
+
private _parseColumns;
|
|
52
|
+
/**
|
|
53
|
+
* 获取多级表头的最大深度
|
|
54
|
+
* @param headers 表头配置
|
|
55
|
+
* @returns 最大深度, 最大跨行数
|
|
56
|
+
*/
|
|
57
|
+
private _getMaxDepth;
|
|
58
|
+
private _getColumnStyle;
|
|
59
|
+
private _handleTap;
|
|
60
|
+
afterInit(): void;
|
|
61
|
+
beforeDestroy(): void;
|
|
62
|
+
}
|
|
63
|
+
export {};
|