litos-ui 0.8.0 → 0.10.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/lib/base.js +26 -30
- package/lib/button/index.js +55 -59
- package/lib/checkbox/index.d.ts +17 -0
- package/lib/checkbox/index.js +135 -0
- package/lib/color_picker/index.js +17 -21
- package/lib/form/form_inner.js +46 -49
- package/lib/form/form_item.js +49 -54
- package/lib/form/index.js +62 -66
- package/lib/icon/arrow_down.js +4 -7
- package/lib/icon/arrow_left.js +4 -7
- package/lib/icon/arrow_right.js +4 -7
- package/lib/icon/arrow_up.js +4 -7
- package/lib/icon/base.js +21 -25
- package/lib/icon/caret_bottom.js +4 -7
- package/lib/icon/caret_top.js +4 -7
- package/lib/icon/font_icon.js +13 -17
- package/lib/icon/info.js +4 -7
- package/lib/icon/loading.js +4 -7
- package/lib/icon/mask_close.js +4 -7
- package/lib/icon/moon.js +4 -7
- package/lib/icon/reduction.js +4 -7
- package/lib/icon/refresh_left.js +4 -7
- package/lib/icon/refresh_right.js +4 -7
- package/lib/icon/search.js +4 -7
- package/lib/icon/sort.js +4 -7
- package/lib/icon/success.js +4 -7
- package/lib/icon/sun.js +4 -7
- package/lib/icon/theme_default.js +4 -7
- package/lib/icon/warn.js +4 -7
- package/lib/index.d.ts +4 -0
- package/lib/index.js +30 -26
- package/lib/input/index.js +66 -71
- package/lib/list/index.js +23 -27
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/md_input/index.d.ts +15 -0
- package/lib/md_input/index.js +60 -0
- package/lib/polygon/index.js +14 -18
- package/lib/popconfirm/index.js +11 -14
- package/lib/popover/index.js +107 -113
- package/lib/radio/index.js +53 -57
- package/lib/select_ori/index.js +23 -27
- package/lib/switch/index.js +34 -44
- package/lib/tabbar/index.js +117 -126
- package/lib/theme/index.js +71 -74
- package/lib/theme/theme_color.js +17 -27
- package/lib/{form/form_events.d.ts → utils/event.d.ts} +5 -7
- package/lib/utils/event.js +16 -18
- package/lib/utils/index.js +21 -21
- package/lib/utils/transition.js +23 -27
- package/package.json +1 -1
- package/lib/form/form_events.js +0 -24
package/lib/select_ori/index.js
CHANGED
|
@@ -1,30 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import a from "../form/form_inner.js";
|
|
2
|
+
import { initAttr as c, tagAttrs as h } from "../utils/index.js";
|
|
3
|
+
import { $one as r, on as o, off as u } from "ph-utils/dom";
|
|
4
|
+
import { i as d } from "../index-391POYEJ.js";
|
|
5
|
+
class f extends a {
|
|
6
|
+
static baseName = "select-ori";
|
|
7
|
+
$select;
|
|
8
|
+
changeEmit;
|
|
9
9
|
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
n(this, "$select");
|
|
12
|
-
n(this, "changeEmit");
|
|
13
|
-
n(this, "_handleChange", (e) => {
|
|
14
|
-
const s = e.target.value;
|
|
15
|
-
super.setValue(s), this.dispatchEvent(this.changeEmit);
|
|
16
|
-
});
|
|
17
|
-
d(this), this.changeEmit = new CustomEvent("change");
|
|
10
|
+
super(), c(this), this.changeEmit = new CustomEvent("change");
|
|
18
11
|
}
|
|
19
12
|
connectedCallback() {
|
|
20
|
-
this.loadStyleText(
|
|
13
|
+
this.loadStyleText(d), super.connectedCallback(), this.$select = r("select", this.root), this.value && (this.$select.value = this.value), o(this.$select, "change", this._handleChange);
|
|
21
14
|
}
|
|
22
15
|
disconnectedCallback() {
|
|
23
|
-
super.disconnectedCallback(), this.$select &&
|
|
16
|
+
super.disconnectedCallback(), this.$select && u(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
|
|
24
17
|
}
|
|
25
18
|
render() {
|
|
26
19
|
let e = this.innerHTML.trim();
|
|
27
|
-
return `<select class="l-input"${
|
|
20
|
+
return `<select class="l-input"${h([
|
|
28
21
|
["name", this.getName()],
|
|
29
22
|
["disabled", this.isDisabled()]
|
|
30
23
|
])}>${e}</select>`;
|
|
@@ -34,17 +27,17 @@ class f extends u {
|
|
|
34
27
|
}
|
|
35
28
|
setOptions(e) {
|
|
36
29
|
if (!this.$select) return;
|
|
37
|
-
const
|
|
38
|
-
this.$select.innerHTML =
|
|
30
|
+
const t = e.map((s) => `<option value="${s.value}">${s.label}</option>`);
|
|
31
|
+
this.$select.innerHTML = t.join("");
|
|
39
32
|
}
|
|
40
33
|
appendOptions(e) {
|
|
41
34
|
if (!this.$select) return;
|
|
42
|
-
const
|
|
43
|
-
for (let
|
|
44
|
-
const
|
|
45
|
-
|
|
35
|
+
const t = document.createDocumentFragment();
|
|
36
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
37
|
+
const l = e[s], i = document.createElement("option");
|
|
38
|
+
i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
|
|
46
39
|
}
|
|
47
|
-
this.$select.appendChild(
|
|
40
|
+
this.$select.appendChild(t);
|
|
48
41
|
}
|
|
49
42
|
reset() {
|
|
50
43
|
super.reset(), this.$select && (this.$select.value = this.value);
|
|
@@ -52,8 +45,11 @@ class f extends u {
|
|
|
52
45
|
setValue(e) {
|
|
53
46
|
super.setValue(e), this.$select && (this.$select.value = this.value);
|
|
54
47
|
}
|
|
48
|
+
_handleChange = (e) => {
|
|
49
|
+
const t = e.target.value;
|
|
50
|
+
super.setValue(t), this.dispatchEvent(this.changeEmit);
|
|
51
|
+
};
|
|
55
52
|
}
|
|
56
|
-
n(f, "baseName", "select-ori");
|
|
57
53
|
export {
|
|
58
54
|
f as default
|
|
59
55
|
};
|
package/lib/switch/index.js
CHANGED
|
@@ -1,65 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import m from "../form/form_inner.js";
|
|
11
|
-
import { initAttr as T, parseAttrValue as y } from "../utils/index.js";
|
|
12
|
-
const C = ":host{display:inline-flex}: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}";
|
|
13
|
-
var h, c, a;
|
|
14
|
-
class L extends m {
|
|
1
|
+
import { on as c, off as h, addClass as o, removeClass as l, $one as i } from "ph-utils/dom";
|
|
2
|
+
import n from "../form/form_inner.js";
|
|
3
|
+
import { initAttr as a, parseAttrValue as r } from "../utils/index.js";
|
|
4
|
+
const d = ":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}";
|
|
5
|
+
class w extends n {
|
|
6
|
+
static baseName = "switch";
|
|
7
|
+
actionRender;
|
|
8
|
+
checkedText;
|
|
9
|
+
uncheckedText;
|
|
15
10
|
constructor() {
|
|
16
|
-
super(!1);
|
|
17
|
-
|
|
18
|
-
o(this, "actionRender");
|
|
19
|
-
o(this, "checkedText");
|
|
20
|
-
o(this, "uncheckedText");
|
|
21
|
-
d(this, h, (t) => {
|
|
22
|
-
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
23
|
-
});
|
|
24
|
-
T(this);
|
|
25
|
-
const t = this.value ? y(this.value, !1, "value") : !1;
|
|
11
|
+
super(!1), a(this);
|
|
12
|
+
const t = this.value ? r(this.value, !1, "value") : !1;
|
|
26
13
|
this._resetValue = t, this.value = t;
|
|
27
14
|
}
|
|
28
15
|
connectedCallback() {
|
|
29
|
-
this.loadStyleText(
|
|
16
|
+
this.loadStyleText(d), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
|
|
30
17
|
}
|
|
31
18
|
disconnectedCallback() {
|
|
32
|
-
super.disconnectedCallback(),
|
|
19
|
+
super.disconnectedCallback(), h(this, "click", this.#e), this.actionRender = void 0;
|
|
33
20
|
}
|
|
34
21
|
render() {
|
|
35
22
|
this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
|
|
36
23
|
const t = ['<div class="l-switch-action" part="action"></div>'];
|
|
37
24
|
if (this.checkedText || this.uncheckedText) {
|
|
38
|
-
const
|
|
39
|
-
t.push(`<span class="l-switch-text">${
|
|
25
|
+
const e = this.value ? this.checkedText || "" : this.uncheckedText || "";
|
|
26
|
+
t.push(`<span class="l-switch-text">${e}</span>`);
|
|
40
27
|
}
|
|
41
28
|
return t.join("");
|
|
42
29
|
}
|
|
30
|
+
#e = (t) => {
|
|
31
|
+
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
32
|
+
};
|
|
43
33
|
setValue(t) {
|
|
44
|
-
super.setValue(t), t ?
|
|
45
|
-
const
|
|
46
|
-
|
|
34
|
+
super.setValue(t), t ? o(this, "l-switch--checked") : l(this, "l-switch--checked");
|
|
35
|
+
const e = i(".l-switch-text", this.root);
|
|
36
|
+
e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
|
|
47
37
|
}
|
|
48
38
|
setActionRender(t) {
|
|
49
|
-
this.actionRender = t,
|
|
39
|
+
this.actionRender = t, this.#t();
|
|
40
|
+
}
|
|
41
|
+
#t() {
|
|
42
|
+
const t = i(".l-switch-action", this.root);
|
|
43
|
+
if (t)
|
|
44
|
+
if (this.actionRender) {
|
|
45
|
+
const e = this.actionRender({ checked: this.value });
|
|
46
|
+
typeof e == "string" ? t.innerHTML = e : t.innerHTML = e.outerHTML;
|
|
47
|
+
} else {
|
|
48
|
+
const e = i('[slot="checked-action"]', this), s = i('[slot="unchecked-action"]', this);
|
|
49
|
+
this.value && e ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && s && (t.innerHTML = '<slot name="unchecked-action"></slot>');
|
|
50
|
+
}
|
|
50
51
|
}
|
|
51
52
|
}
|
|
52
|
-
h = new WeakMap(), c = new WeakSet(), a = function() {
|
|
53
|
-
const t = n(".l-switch-action", this.root);
|
|
54
|
-
if (t)
|
|
55
|
-
if (this.actionRender) {
|
|
56
|
-
const s = this.actionRender({ checked: this.value });
|
|
57
|
-
typeof s == "string" ? t.innerHTML = s : t.innerHTML = s.outerHTML;
|
|
58
|
-
} else {
|
|
59
|
-
const s = n('[slot="checked-action"]', this), f = n('[slot="unchecked-action"]', this);
|
|
60
|
-
this.value && s ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && f && (t.innerHTML = '<slot name="unchecked-action"></slot>');
|
|
61
|
-
}
|
|
62
|
-
}, o(L, "baseName", "switch");
|
|
63
53
|
export {
|
|
64
|
-
|
|
54
|
+
w as default
|
|
65
55
|
};
|
package/lib/tabbar/index.js
CHANGED
|
@@ -1,139 +1,129 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var u = (o, i, e) => (N(o, i, "access private method"), e);
|
|
9
|
-
import { isBlank as g, isNumeric as T } from "ph-utils";
|
|
10
|
-
import j from "../base.js";
|
|
11
|
-
import { initAttr as W, parseAttrValue as x } from "../utils/index.js";
|
|
12
|
-
import { addClass as v, removeClass as y, $one as c, create as f, $ as _, iterate as E, on as S, off as z, isVisible as B, formatStyle as D, formatClass as I } from "ph-utils/dom";
|
|
13
|
-
const M = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:block}.l-tabbar-wrapper{display:flex;flex-wrap:nowrap;height:100%;align-items:stretch;gap:var(--l-tabbar-item-gap)}.l-tabbar-item{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center}.l-tabbar-item:hover{color:var(--l-tabbar-hover-color)}.l-tabbar-item.active{color:var(--l-tabbar-active-color)}.l-tabbar-item-icon{font-size:18px;margin-bottom:5px;display:flex;justify-content:center;align-items:center}.l-tabbar-item-icon.only{font-size:24px;margin-bottom:0}:host(.l-tabbar--nav){--l-tabbar-height: 50px;width:100%}:host(.l-tabbar--nav) .l-tabbar-item{flex-grow:1;display:inline-flex;flex-direction:column;justify-content:center;align-items:center;font-size:12px;line-height:1}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}:host(.l-tabbar--card) .l-tabbar-item{padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-tabbar--card) .l-tabbar-item:first-child{border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item:last-child{border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar-gap) .l-tabbar-item{border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item.active{background:#fff}";
|
|
14
|
-
function R(o, i, e) {
|
|
15
|
-
let t = o.target, a = "";
|
|
1
|
+
import { isBlank as p, isNumeric as v } from "ph-utils";
|
|
2
|
+
import y from "../base.js";
|
|
3
|
+
import { initAttr as x, parseAttrValue as m } from "../utils/index.js";
|
|
4
|
+
import { addClass as h, removeClass as f, $one as l, create as b, $ as g, iterate as $, on as C, off as k, isVisible as w, formatStyle as _, formatClass as A } from "ph-utils/dom";
|
|
5
|
+
const L = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:block}.l-tabbar-wrapper{display:flex;flex-wrap:nowrap;height:100%;align-items:stretch;gap:var(--l-tabbar-item-gap)}.l-tabbar-item{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center}.l-tabbar-item:hover{color:var(--l-tabbar-hover-color)}.l-tabbar-item.active{color:var(--l-tabbar-active-color)}.l-tabbar-item-icon{font-size:18px;margin-bottom:5px;display:flex;justify-content:center;align-items:center}.l-tabbar-item-icon.only{font-size:24px;margin-bottom:0}:host(.l-tabbar--nav){--l-tabbar-height: 50px;width:100%}:host(.l-tabbar--nav) .l-tabbar-item{flex-grow:1;display:inline-flex;flex-direction:column;justify-content:center;align-items:center;font-size:12px;line-height:1}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}:host(.l-tabbar--card) .l-tabbar-item{padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-tabbar--card) .l-tabbar-item:first-child{border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item:last-child{border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar-gap) .l-tabbar-item{border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item.active{background:#fff}";
|
|
6
|
+
function N(u, r, t) {
|
|
7
|
+
let e = u.target, a = "";
|
|
16
8
|
do
|
|
17
|
-
if (
|
|
9
|
+
if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (a = e.getAttribute(r) || ""), a === "" && (e = e.parentNode), !e)) break;
|
|
18
10
|
while (a === "");
|
|
19
|
-
return [a !== "__stop__" && a !== "", a,
|
|
11
|
+
return [a !== "__stop__" && a !== "", a, e];
|
|
20
12
|
}
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
class S extends y {
|
|
14
|
+
static baseName = "tabbar";
|
|
15
|
+
/**
|
|
16
|
+
* 标签类型:
|
|
17
|
+
* 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
|
|
18
|
+
* 2. bar - 选项卡
|
|
19
|
+
* 3. card - 卡片
|
|
20
|
+
*/
|
|
21
|
+
type = "nav";
|
|
22
|
+
name;
|
|
23
|
+
gap;
|
|
24
|
+
$line;
|
|
23
25
|
constructor() {
|
|
24
|
-
super();
|
|
25
|
-
w(this, d);
|
|
26
|
-
/**
|
|
27
|
-
* 标签类型:
|
|
28
|
-
* 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
|
|
29
|
-
* 2. bar - 选项卡
|
|
30
|
-
* 3. card - 卡片
|
|
31
|
-
*/
|
|
32
|
-
h(this, "type", "nav");
|
|
33
|
-
h(this, "name");
|
|
34
|
-
h(this, "gap");
|
|
35
|
-
h(this, "$line");
|
|
36
|
-
h(this, "_handleClick", (e) => {
|
|
37
|
-
const [t, a] = R(e, "l-name", this.root);
|
|
38
|
-
t && a !== this.name && (this.name = a, this.dispatchEvent(
|
|
39
|
-
new CustomEvent("change", {
|
|
40
|
-
detail: {
|
|
41
|
-
name: a
|
|
42
|
-
}
|
|
43
|
-
})
|
|
44
|
-
), this._updateActive(), this._updateLine());
|
|
45
|
-
});
|
|
46
|
-
W(this);
|
|
26
|
+
super(), x(this);
|
|
47
27
|
}
|
|
48
28
|
connectedCallback() {
|
|
49
|
-
this.loadStyleText(
|
|
29
|
+
this.loadStyleText(L), h(this, `l-tabbar--${this.type}`), !p(this.gap) && !this.gap.startsWith("0") && h(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
|
|
50
30
|
}
|
|
51
31
|
static get observedAttributes() {
|
|
52
32
|
return ["name", "type", "justify-content", "gap"];
|
|
53
33
|
}
|
|
54
|
-
attributeChangedCallback(
|
|
55
|
-
if (
|
|
56
|
-
const
|
|
57
|
-
this.name =
|
|
58
|
-
} else if (
|
|
59
|
-
const
|
|
60
|
-
if (
|
|
61
|
-
let
|
|
62
|
-
|
|
34
|
+
attributeChangedCallback(r, t, e) {
|
|
35
|
+
if (r === "name") {
|
|
36
|
+
const a = m(e, void 0);
|
|
37
|
+
this.name = a, this._updateActive(), this._updateLine();
|
|
38
|
+
} else if (r === "type") {
|
|
39
|
+
const a = m(e, "nav");
|
|
40
|
+
if (a !== this.type && (f(this, `l-tabbar--${this.type}`), this.type = a, f(this, `l-tabbar--${a}`), a === "card")) {
|
|
41
|
+
let i = l(".l-tabbar-card-border", this.root);
|
|
42
|
+
i || (i = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(i));
|
|
63
43
|
}
|
|
64
44
|
} else {
|
|
65
|
-
const
|
|
66
|
-
this[
|
|
67
|
-
const
|
|
68
|
-
|
|
45
|
+
const a = m(e, void 0);
|
|
46
|
+
this[r] = a;
|
|
47
|
+
const i = l(".l-tabbar-wrapper", this.root);
|
|
48
|
+
i && (i.style.cssText = this.#t()), r === "gap" && (!p(this.gap) && !this.gap.startsWith("0") ? h(this, "l-tabbar-gap") : f(this, "l-tabbar-gap"));
|
|
69
49
|
}
|
|
70
50
|
}
|
|
71
51
|
disconnectedCallback() {
|
|
72
52
|
super.disconnectedCallback(), this._destroy();
|
|
73
53
|
}
|
|
74
54
|
render() {
|
|
75
|
-
const
|
|
76
|
-
if (t.className = "l-tabbar-wrapper", t.style.cssText =
|
|
77
|
-
const
|
|
78
|
-
t.appendChild(
|
|
55
|
+
const r = document.createDocumentFragment(), t = document.createElement("div");
|
|
56
|
+
if (t.className = "l-tabbar-wrapper", t.style.cssText = this.#t(), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
|
|
57
|
+
const a = document.createElement("slot");
|
|
58
|
+
t.appendChild(a);
|
|
79
59
|
} else {
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
const
|
|
83
|
-
if (
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
if (
|
|
88
|
-
const
|
|
60
|
+
const a = g("[l-name]", this);
|
|
61
|
+
a.length > 0 && $(a, (i) => {
|
|
62
|
+
const c = i.getAttribute("l-name");
|
|
63
|
+
if (c) {
|
|
64
|
+
const o = i.cloneNode(!0);
|
|
65
|
+
o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), c === this.name && o.classList.add("active");
|
|
66
|
+
const n = l("[l-icon]", o), s = g(":not([l-icon])", o);
|
|
67
|
+
if (n) {
|
|
68
|
+
const d = b("div", {
|
|
89
69
|
class: [
|
|
90
70
|
"l-tabbar-item-icon",
|
|
91
|
-
|
|
71
|
+
s.length === 0 ? "only" : void 0
|
|
92
72
|
]
|
|
93
73
|
});
|
|
94
|
-
|
|
74
|
+
d.appendChild(n.cloneNode(!0)), n.replaceWith(d);
|
|
95
75
|
}
|
|
96
|
-
t.appendChild(
|
|
76
|
+
t.appendChild(o);
|
|
97
77
|
}
|
|
98
78
|
});
|
|
99
79
|
}
|
|
100
|
-
if (
|
|
101
|
-
const
|
|
102
|
-
|
|
80
|
+
if (r.appendChild(t), this.type === "card") {
|
|
81
|
+
const a = b("div", { class: "l-tabbar-card-border" });
|
|
82
|
+
r.appendChild(a);
|
|
103
83
|
}
|
|
104
|
-
return
|
|
84
|
+
return r;
|
|
105
85
|
}
|
|
106
86
|
/**
|
|
107
87
|
* 设置选项卡栏的项目列表。
|
|
108
88
|
* @param items - 选项卡栏项目的数组。
|
|
109
89
|
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
110
90
|
*/
|
|
111
|
-
setItems(
|
|
112
|
-
const t =
|
|
113
|
-
t && (t.innerHTML = "", t.appendChild(
|
|
91
|
+
setItems(r) {
|
|
92
|
+
const t = l(".l-tabbar-wrapper", this.root);
|
|
93
|
+
t && (t.innerHTML = "", t.appendChild(this.#e(r)));
|
|
114
94
|
}
|
|
115
95
|
/**
|
|
116
96
|
* 向标签栏添加项目。
|
|
117
97
|
* @param items 要添加的标签栏项目数组。
|
|
118
98
|
* @returns 无返回值。
|
|
119
99
|
*/
|
|
120
|
-
addItems(
|
|
121
|
-
const t =
|
|
122
|
-
t && t.appendChild(
|
|
100
|
+
addItems(r) {
|
|
101
|
+
const t = l(".l-tabbar-wrapper", this.root);
|
|
102
|
+
t && t.appendChild(this.#e(r));
|
|
123
103
|
}
|
|
124
104
|
_init() {
|
|
125
|
-
|
|
105
|
+
C(this.root, "click", this._handleClick), setTimeout(() => {
|
|
126
106
|
this._updateLine();
|
|
127
107
|
}, 300);
|
|
128
108
|
}
|
|
129
109
|
_destroy() {
|
|
130
|
-
|
|
110
|
+
k(this.root, "click", this._handleClick), this.$line = void 0;
|
|
131
111
|
}
|
|
112
|
+
_handleClick = (r) => {
|
|
113
|
+
const [t, e] = N(r, "l-name", this.root);
|
|
114
|
+
t && e !== this.name && (this.name = e, this.dispatchEvent(
|
|
115
|
+
new CustomEvent("change", {
|
|
116
|
+
detail: {
|
|
117
|
+
name: e
|
|
118
|
+
}
|
|
119
|
+
})
|
|
120
|
+
), this._updateActive(), this._updateLine());
|
|
121
|
+
};
|
|
132
122
|
_updateActive() {
|
|
133
|
-
const t = this.getAttr("custom-content", !1) ? this : this.root,
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
123
|
+
const t = this.getAttr("custom-content", !1) ? this : this.root, e = l(".active", t);
|
|
124
|
+
e && f(e, "active");
|
|
125
|
+
const a = l(`[l-name="${this.name}"]`, t);
|
|
126
|
+
a && h(a, "active");
|
|
137
127
|
}
|
|
138
128
|
/**
|
|
139
129
|
* 初始化线条的方法,在微任务队列中执行。
|
|
@@ -142,53 +132,54 @@ class F extends j {
|
|
|
142
132
|
_updateLine() {
|
|
143
133
|
queueMicrotask(() => {
|
|
144
134
|
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
145
|
-
const
|
|
135
|
+
const r = this.getAttr("custom-content", !1), t = l(".active", r ? this : this.root);
|
|
146
136
|
if (!t) return;
|
|
147
|
-
const
|
|
137
|
+
const e = t.offsetLeft;
|
|
148
138
|
if (!this.$line) {
|
|
149
|
-
const
|
|
150
|
-
|
|
139
|
+
const a = b("div", { class: "l-tabbar--bar-line" });
|
|
140
|
+
a.part = "line", this.root.appendChild(a), this.$line = l(".l-tabbar--bar-line", this.root);
|
|
151
141
|
}
|
|
152
|
-
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${
|
|
153
|
-
left:
|
|
142
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, w(t, this) || this.scrollTo({
|
|
143
|
+
left: e,
|
|
154
144
|
behavior: "smooth"
|
|
155
145
|
});
|
|
156
146
|
});
|
|
157
147
|
}
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
T(a, { isPositive: !0 }) && (a = `${a}px`), e["--l-tabbar-item-gap"] = a;
|
|
164
|
-
}
|
|
165
|
-
return D(e);
|
|
166
|
-
}, C = function(e) {
|
|
167
|
-
const t = document.createDocumentFragment();
|
|
168
|
-
for (let a = 0, r = e.length; a < r; a++) {
|
|
169
|
-
const s = e[a], p = f("div", {
|
|
170
|
-
class: I([
|
|
171
|
-
"l-tabbar-item",
|
|
172
|
-
this.name === s.name ? "active" : void 0
|
|
173
|
-
]),
|
|
174
|
-
"l-name": s.name,
|
|
175
|
-
part: "item"
|
|
176
|
-
}), l = s.icon;
|
|
177
|
-
if (l) {
|
|
178
|
-
const n = f("div", { class: "l-tabbar-item-icon" });
|
|
179
|
-
let m = typeof l == "string" ? l : l();
|
|
180
|
-
typeof m == "string" ? n.innerHTML = m : n.appendChild(m), p.appendChild(n);
|
|
148
|
+
#t() {
|
|
149
|
+
const r = {}, t = this.getAttr("justify-content");
|
|
150
|
+
if (p(t) || (r["justify-content"] = t), !p(this.gap)) {
|
|
151
|
+
let e = this.gap;
|
|
152
|
+
v(e, { isPositive: !0 }) && (e = `${e}px`), r["--l-tabbar-item-gap"] = e;
|
|
181
153
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
154
|
+
return _(r);
|
|
155
|
+
}
|
|
156
|
+
#e(r) {
|
|
157
|
+
const t = document.createDocumentFragment();
|
|
158
|
+
for (let e = 0, a = r.length; e < a; e++) {
|
|
159
|
+
const i = r[e], c = b("div", {
|
|
160
|
+
class: A([
|
|
161
|
+
"l-tabbar-item",
|
|
162
|
+
this.name === i.name ? "active" : void 0
|
|
163
|
+
]),
|
|
164
|
+
"l-name": i.name,
|
|
165
|
+
part: "item"
|
|
166
|
+
}), o = i.icon;
|
|
167
|
+
if (o) {
|
|
168
|
+
const s = b("div", { class: "l-tabbar-item-icon" });
|
|
169
|
+
let d = typeof o == "string" ? o : o();
|
|
170
|
+
typeof d == "string" ? s.innerHTML = d : s.appendChild(d), c.appendChild(s);
|
|
171
|
+
}
|
|
172
|
+
const n = i.text;
|
|
173
|
+
if (n) {
|
|
174
|
+
let s = typeof n == "string" ? n : n();
|
|
175
|
+
typeof s == "string" ? c.appendChild(b(s)) : c.appendChild(s);
|
|
176
|
+
}
|
|
177
|
+
t.appendChild(c);
|
|
186
178
|
}
|
|
187
|
-
t
|
|
179
|
+
return t;
|
|
188
180
|
}
|
|
189
|
-
|
|
190
|
-
}, h(F, "baseName", "tabbar");
|
|
181
|
+
}
|
|
191
182
|
export {
|
|
192
|
-
|
|
193
|
-
|
|
183
|
+
S as default,
|
|
184
|
+
N as shouldEventNext
|
|
194
185
|
};
|