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.
- package/README.md +49 -49
- package/lib/animation-CTt9qgA7.js +4 -0
- package/lib/base-Dm0WS1pK.js +62 -0
- package/lib/base.js +111 -147
- package/lib/button/index.d.ts +8 -3
- package/lib/button/index.js +2 -137
- package/lib/button-CC5PmAb1.js +146 -0
- package/lib/calendar/index.d.ts +10 -5
- package/lib/calendar/index.js +2 -123
- package/lib/calendar-DeP6yZB0.js +149 -0
- package/lib/carousel/index.js +2 -280
- package/lib/carousel/item.js +2 -15
- package/lib/carousel-D4Fe3LEx.js +272 -0
- package/lib/check/checkbox.js +2 -18
- package/lib/check/checkbox_group.js +6 -6
- package/lib/check/radio.js +2 -15
- package/lib/check/radio_group.js +9 -9
- package/lib/check-B0XraJvb.js +73 -0
- package/lib/check-CvGaONEx.js +117 -0
- package/lib/checkbox-DbWsmAaL.js +16 -0
- package/lib/collapse/index.d.ts +18 -11
- package/lib/collapse/index.js +2 -88
- package/lib/collapse/item.d.ts +28 -9
- package/lib/collapse/item.js +2 -115
- package/lib/collapse/types.d.ts +7 -0
- package/lib/collapse-CeKRZ-43.js +104 -0
- package/lib/color_picker/index.js +2 -42
- package/lib/color_picker-D0brKFm-.js +41 -0
- package/lib/date_picker/index.d.ts +23 -0
- package/lib/date_picker/index.js +3 -0
- package/lib/date_picker-DQGoiN8v.js +103 -0
- package/lib/date_picker_ori/index.js +2 -129
- package/lib/date_picker_ori-aRuSSi9D.js +122 -0
- package/lib/description_panel/index.js +2 -66
- package/lib/description_panel-Df_8rVbX.js +57 -0
- package/lib/dialog/dialog_container.js +2 -131
- package/lib/dialog/index.js +67 -85
- package/lib/dialog_container-DcN87wj0.js +126 -0
- package/lib/esm-sVEoAVPu.js +244 -0
- package/lib/form/form_item.d.ts +1 -0
- package/lib/form/form_item.js +2 -136
- package/lib/form/index.js +2 -147
- package/lib/form-DdU0yK0k.js +154 -0
- package/lib/form_inner-DR9tyB_r.js +117 -0
- package/lib/form_item-Bv-YafZK.js +137 -0
- package/lib/icon/arrow_down.js +12 -12
- package/lib/icon/arrow_left.js +9 -9
- package/lib/icon/arrow_right.js +9 -9
- package/lib/icon/arrow_up.js +12 -12
- package/lib/icon/base.d.ts +16 -2
- package/lib/icon/base.js +2 -38
- package/lib/icon/calendar.d.ts +5 -0
- package/lib/icon/calendar.js +10 -0
- package/lib/icon/caret_bottom.js +9 -9
- package/lib/icon/caret_top.js +9 -9
- package/lib/icon/close.js +9 -9
- package/lib/icon/close_filled.js +12 -12
- package/lib/icon/d_arrow_left.js +12 -12
- package/lib/icon/d_arrow_right.js +12 -12
- package/lib/icon/font_icon.d.ts +2 -3
- package/lib/icon/font_icon.js +35 -39
- package/lib/icon/info.js +12 -12
- package/lib/icon/loading.js +9 -9
- package/lib/icon/moon.js +12 -12
- package/lib/icon/more.js +12 -12
- package/lib/icon/reduction.js +12 -12
- package/lib/icon/refresh.d.ts +5 -0
- package/lib/icon/refresh.js +10 -0
- package/lib/icon/refresh_left.js +12 -12
- package/lib/icon/refresh_right.js +9 -9
- package/lib/icon/search.js +9 -9
- package/lib/icon/select.js +12 -12
- package/lib/icon/sort.js +9 -9
- package/lib/icon/success.js +12 -12
- package/lib/icon/sun.js +12 -12
- package/lib/icon/theme_default.js +12 -12
- package/lib/icon/warn.js +12 -12
- package/lib/icon/zoom_in.js +12 -12
- package/lib/icon/zoom_out.js +12 -12
- package/lib/image/image_preview.js +2 -104
- package/lib/image/index.js +2 -176
- package/lib/image-CeQVfS-v.js +162 -0
- package/lib/image_preview-PzZzwo6m.js +92 -0
- package/lib/index.d.ts +10 -4
- package/lib/index.js +80 -169
- package/lib/input/index.d.ts +6 -2
- package/lib/input/index.js +188 -203
- package/lib/input-DjKxcxry.js +4 -0
- package/lib/input_inner-BKJg9n9A.js +4 -0
- package/lib/item-Cuw_ZPyn.js +14 -0
- package/lib/item-DV842Aux.js +57 -0
- package/lib/item-ZXLWFzSm.js +119 -0
- package/lib/list/index.js +2 -58
- package/lib/list-CU7vHS6s.js +51 -0
- package/lib/loading/index.d.ts +3 -2
- package/lib/loading/index.js +109 -127
- package/lib/mask/index.js +2 -105
- package/lib/mask-BlV5QfTj.js +112 -0
- package/lib/md_input/index.js +2 -60
- package/lib/md_input-DSQx5TMW.js +58 -0
- package/lib/menu/index.js +2 -105
- package/lib/menu/menu_item.js +2 -21
- package/lib/menu/sub_menu.js +2 -83
- package/lib/menu-DAtplYAH.js +91 -0
- package/lib/menu_item-BW1Tu11Q.js +20 -0
- package/lib/message/index.js +67 -60
- package/lib/modal/index.js +2 -196
- package/lib/modal/modal_box.js +87 -86
- package/lib/modal-DWyWrN-D.js +192 -0
- package/lib/page_header/index.js +2 -109
- package/lib/page_header-DdeRDN4U.js +101 -0
- package/lib/pagination/index.js +2 -248
- package/lib/pagination-BoPzSPjT.js +210 -0
- package/lib/polygon/index.js +2 -27
- package/lib/polygon-C4Ow2lxi.js +20 -0
- package/lib/qrcode/index.d.ts +13 -4
- package/lib/qrcode/index.js +2 -57
- package/lib/qrcode-BFxsD_OP.js +64 -0
- package/lib/radio-2mNSYujz.js +13 -0
- package/lib/select/index.js +3 -401
- package/lib/select-CAgggYh7.js +326 -0
- package/lib/select_ori/index.js +47 -50
- package/lib/space/index.js +2 -35
- package/lib/space-CpTmBfHP.js +38 -0
- package/lib/sub_menu-D1s8ABNu.js +75 -0
- package/lib/switch/index.js +2 -50
- package/lib/switch-BaVBi5Ip.js +48 -0
- package/lib/tabbar/index.js +2 -109
- package/lib/tabbar/item.js +2 -58
- package/lib/tabbar-4_d2Fj1n.js +91 -0
- package/lib/table/index.js +2 -269
- package/lib/table-Hifj8jAX.js +234 -0
- package/lib/tabs/index.js +38 -42
- package/lib/tag/index.js +2 -72
- package/lib/tag-DPENZf_V.js +76 -0
- package/lib/theme/index.js +2 -89
- package/lib/theme/theme_color.js +22 -26
- package/lib/theme-BRTI2-Yk.js +83 -0
- package/lib/utils/clickoutside.js +18 -18
- package/lib/utils/context_provide.js +21 -21
- package/lib/utils/event.js +13 -18
- package/lib/utils/index.js +55 -58
- package/lib/utils/popover.d.ts +4 -1
- package/lib/utils/popover.js +276 -352
- package/lib/utils/transition.js +33 -31
- package/package.json +10 -11
- package/styles/container.css +4 -0
- package/styles/datepicker.css +55 -0
- package/styles/popover.css +14 -1
- package/lib/animation-DttknHkX.js +0 -4
- package/lib/calendar/langs.js +0 -8
- package/lib/carousel/timer.js +0 -19
- package/lib/check/check.js +0 -118
- package/lib/check/index.js +0 -68
- package/lib/check-CksURvTv.js +0 -4
- package/lib/form/form_inner.js +0 -125
- package/lib/form/types.js +0 -1
- package/lib/index-CrMiSe0x.js +0 -249
- package/lib/index-DY6m9Wbe.js +0 -4
- package/lib/litos-ui.css +0 -1
- 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 };
|
package/lib/select_ori/index.js
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { i as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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 };
|
package/lib/space/index.js
CHANGED
|
@@ -1,35 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
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-CpTmBfHP.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 };
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { initAttr as t, parseAttrValue as n } from "./utils/index.js";
|
|
3
|
+
import { $$ as r, $one as i, addClass as a, off as o, on as s, removeClass as c, toggleClass as l } from "ph-utils/dom";
|
|
4
|
+
//#region src/components/menu/sub_menu.less?inline
|
|
5
|
+
var u = ":host{width:100%;display:block;overflow:hidden}.l-submenu-title{padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;text-overflow:ellipsis;border-right:2px solid #0000;align-items:center;transition:color .3s,background-color .3s,border-color .3s;display:flex;position:relative;overflow:hidden}.l-submenu-title:hover{background-color:var(--l-primary-color-light5)}.l-menu{--l-menu-level:1;width:var(--l-menu-width);height:var(--l-menu-height);color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;border-right:1px solid var(--l-border-color,#dedede);font-size:14px;transition:height .3s,width .3s;display:block;position:relative;overflow:hidden}.l-menu-icon-wrap{margin-right:5px;font-size:14px;display:inline-flex}.l-submenu-arrow-icon{color:var(--l-info-color);transition:transform .3s;position:absolute;top:50%;right:10px;transform:translateY(-50%)rotate(90deg)}:host(.collapsed) .l-submenu-arrow-icon{transform:translateY(-50%)rotate(0)}.l-menu--collapsed{display:none}.l-menu--hide{visibility:hidden;position:absolute}:host(.is-active) .l-submenu-title{color:var(--l-primary-color)}", d = class extends e {
|
|
6
|
+
static baseName = "sub-menu";
|
|
7
|
+
expanded = !1;
|
|
8
|
+
active = !1;
|
|
9
|
+
#e;
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
this.loadStyleText(u), t(this), this.expanded || a(this, "collapsed"), this.active && a(this, "is-active"), super.connectedCallback();
|
|
12
|
+
}
|
|
13
|
+
afterInit() {
|
|
14
|
+
s(i(".l-menu", this.root), "transitionend", this.#t);
|
|
15
|
+
}
|
|
16
|
+
beforeDestroy() {
|
|
17
|
+
o(i(".l-menu", this.root), "transitionend", this.#t), this.#e && clearTimeout(this.#e);
|
|
18
|
+
}
|
|
19
|
+
static get observedAttributes() {
|
|
20
|
+
return ["expanded", "active"];
|
|
21
|
+
}
|
|
22
|
+
attributeChangedCallback(e, t, r) {
|
|
23
|
+
if (this.rendered) {
|
|
24
|
+
if (e === "expanded") {
|
|
25
|
+
let e = n(r, !1, "expanded");
|
|
26
|
+
if (this.expanded !== e) {
|
|
27
|
+
this.expanded = e;
|
|
28
|
+
let t = i(".l-menu", this.root);
|
|
29
|
+
if (this.expanded) c(this, "collapsed"), a(t, "l-menu--hide"), c(t, "l-menu--collapsed"), requestAnimationFrame(() => {
|
|
30
|
+
let e = t.getBoundingClientRect();
|
|
31
|
+
t.style.height = "0", c(t, "l-menu--hide"), requestAnimationFrame(() => {
|
|
32
|
+
t.style.height = `${e.height}px`;
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
else {
|
|
36
|
+
let e = t.getBoundingClientRect();
|
|
37
|
+
t.style.height = `${e.height}px`, a(this, "collapsed"), requestAnimationFrame(() => {
|
|
38
|
+
t.style.height = "0";
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
this.#e = setTimeout(() => {
|
|
42
|
+
this.#t({
|
|
43
|
+
target: t,
|
|
44
|
+
propertyName: "height"
|
|
45
|
+
});
|
|
46
|
+
}, 350);
|
|
47
|
+
}
|
|
48
|
+
} else if (e === "active") {
|
|
49
|
+
let e = n(r, !1, "active");
|
|
50
|
+
e !== this.active && (this.active = e, l(this, "is-active"));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
render() {
|
|
55
|
+
let e = document.createDocumentFragment(), t = r("div", { class: "l-submenu-title" });
|
|
56
|
+
if (i("[slot=\"icon\"]", this)) {
|
|
57
|
+
let e = r("span", { class: "l-menu-icon-wrap" });
|
|
58
|
+
e.appendChild(r("slot", { name: "icon" })), t.appendChild(e);
|
|
59
|
+
}
|
|
60
|
+
t.appendChild(r("slot", { name: "title" }));
|
|
61
|
+
let n = r("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
|
|
62
|
+
t.appendChild(n), e.appendChild(t);
|
|
63
|
+
let a = r("div", { class: ["l-menu", this.expanded ? void 0 : "l-menu--collapsed"] });
|
|
64
|
+
return a.appendChild(r("slot")), e.appendChild(a), e;
|
|
65
|
+
}
|
|
66
|
+
#t = (e) => {
|
|
67
|
+
if (!this.expanded && e.propertyName === "height") {
|
|
68
|
+
this.#e && clearTimeout(this.#e);
|
|
69
|
+
let t = e.target;
|
|
70
|
+
t.style.removeProperty("height"), a(t, "l-menu--collapsed");
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
//#endregion
|
|
75
|
+
export { d as t };
|
package/lib/switch/index.js
CHANGED
|
@@ -1,50 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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 };
|