litos-ui 0.6.3 → 0.8.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/{animation-QfX4RtqD.js → animation-DttknHkX.js} +2 -2
- package/lib/base.d.ts +1 -3
- package/lib/base.js +12 -40
- package/lib/button/index.js +49 -49
- package/lib/color_picker/index.js +6 -4
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +26 -25
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +42 -41
- package/lib/icon/base.js +19 -18
- package/lib/{index-B_9rPBWp.js → index-391POYEJ.js} +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +64 -62
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +16 -15
- package/lib/list/index.d.ts +1 -1
- package/lib/list/index.js +13 -13
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/message/index.js +35 -33
- package/lib/polygon/index.d.ts +1 -1
- package/lib/polygon/index.js +17 -16
- package/lib/popconfirm/index.d.ts +7 -0
- package/lib/popconfirm/index.js +33 -0
- package/lib/popover/index.d.ts +5 -2
- package/lib/popover/index.js +106 -97
- package/lib/radio/index.d.ts +2 -2
- package/lib/radio/index.js +69 -68
- package/lib/select_ori/index.d.ts +1 -1
- package/lib/select_ori/index.js +8 -8
- package/lib/switch/index.js +42 -41
- package/lib/tabbar/index.js +94 -92
- package/lib/theme/index.js +39 -39
- package/lib/utils/index.js +54 -54
- package/lib/utils/transition.js +5 -6
- package/package.json +4 -1
- package/lib/browser.d.ts +0 -16
- package/lib/form/types.js +0 -1
- package/lib/index-116dRdDj.js +0 -4
- package/lib/index-BUyxD_nH.js +0 -4
- package/lib/index-BeOxuMd4.js +0 -4
- package/lib/index-Bl8lRTJd.js +0 -4
- package/lib/index-BxlGVrX3.js +0 -4
- package/lib/index-C98Kx857.js +0 -4
- package/lib/index-CCcVpk6U.js +0 -4
- package/lib/index-CMz7GCCH.js +0 -4
- package/lib/index-D-Ikkdx0.js +0 -4
- package/lib/index-DJ70Xyma.js +0 -4
- package/lib/index-DKvzJmsR.js +0 -4
- package/lib/index-oNjb_IVt.js +0 -4
package/lib/switch/index.js
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
|
-
var
|
|
2
|
-
var u = (
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var u = (e) => {
|
|
3
|
+
throw TypeError(e);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
import { on as
|
|
10
|
-
import
|
|
11
|
-
import { initAttr as
|
|
12
|
-
var
|
|
13
|
-
|
|
5
|
+
var w = (e, i, t) => i in e ? x(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
|
|
6
|
+
var o = (e, i, t) => w(e, typeof i != "symbol" ? i + "" : i, t), p = (e, i, t) => i.has(e) || u("Cannot " + t);
|
|
7
|
+
var r = (e, i, t) => (p(e, i, "read from private field"), t ? t.call(e) : i.get(e)), d = (e, i, t) => i.has(e) ? u("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(e) : i.set(e, t);
|
|
8
|
+
var l = (e, i, t) => (p(e, i, "access private method"), t);
|
|
9
|
+
import { on as k, off as v, addClass as b, removeClass as g, $one as n } from "ph-utils/dom";
|
|
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 {
|
|
14
15
|
constructor() {
|
|
15
16
|
super(!1);
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
d(this, c);
|
|
18
|
+
o(this, "actionRender");
|
|
19
|
+
o(this, "checkedText");
|
|
20
|
+
o(this, "uncheckedText");
|
|
21
|
+
d(this, h, (t) => {
|
|
21
22
|
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
22
23
|
});
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
this._resetValue =
|
|
24
|
+
T(this);
|
|
25
|
+
const t = this.value ? y(this.value, !1, "value") : !1;
|
|
26
|
+
this._resetValue = t, this.value = t;
|
|
26
27
|
}
|
|
27
28
|
connectedCallback() {
|
|
28
|
-
this.
|
|
29
|
+
this.loadStyleText(C), super.connectedCallback(), this.pushValueChange(), l(this, c, a).call(this), k(this, "click", r(this, h));
|
|
29
30
|
}
|
|
30
31
|
disconnectedCallback() {
|
|
31
|
-
super.disconnectedCallback(),
|
|
32
|
+
super.disconnectedCallback(), v(this, "click", r(this, h)), this.actionRender = void 0;
|
|
32
33
|
}
|
|
33
34
|
render() {
|
|
34
35
|
this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
|
|
35
|
-
const
|
|
36
|
+
const t = ['<div class="l-switch-action" part="action"></div>'];
|
|
36
37
|
if (this.checkedText || this.uncheckedText) {
|
|
37
|
-
const
|
|
38
|
-
|
|
38
|
+
const s = this.value ? this.checkedText || "" : this.uncheckedText || "";
|
|
39
|
+
t.push(`<span class="l-switch-text">${s}</span>`);
|
|
39
40
|
}
|
|
40
|
-
return
|
|
41
|
+
return t.join("");
|
|
41
42
|
}
|
|
42
|
-
setValue(
|
|
43
|
-
super.setValue(
|
|
44
|
-
const
|
|
45
|
-
|
|
43
|
+
setValue(t) {
|
|
44
|
+
super.setValue(t), t ? b(this, "l-switch--checked") : g(this, "l-switch--checked");
|
|
45
|
+
const s = n(".l-switch-text", this.root);
|
|
46
|
+
s && (s.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), l(this, c, a).call(this);
|
|
46
47
|
}
|
|
47
|
-
setActionRender(
|
|
48
|
-
this.actionRender =
|
|
48
|
+
setActionRender(t) {
|
|
49
|
+
this.actionRender = t, l(this, c, a).call(this);
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
h = new WeakMap(), c = new WeakSet(),
|
|
52
|
-
const
|
|
53
|
-
if (
|
|
52
|
+
h = new WeakMap(), c = new WeakSet(), a = function() {
|
|
53
|
+
const t = n(".l-switch-action", this.root);
|
|
54
|
+
if (t)
|
|
54
55
|
if (this.actionRender) {
|
|
55
|
-
const
|
|
56
|
-
typeof
|
|
56
|
+
const s = this.actionRender({ checked: this.value });
|
|
57
|
+
typeof s == "string" ? t.innerHTML = s : t.innerHTML = s.outerHTML;
|
|
57
58
|
} else {
|
|
58
|
-
const
|
|
59
|
-
this.value &&
|
|
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>');
|
|
60
61
|
}
|
|
61
|
-
},
|
|
62
|
+
}, o(L, "baseName", "switch");
|
|
62
63
|
export {
|
|
63
|
-
|
|
64
|
+
L as default
|
|
64
65
|
};
|
package/lib/tabbar/index.js
CHANGED
|
@@ -1,70 +1,71 @@
|
|
|
1
|
-
var
|
|
2
|
-
var k = (
|
|
3
|
-
throw TypeError(
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var k = (o) => {
|
|
3
|
+
throw TypeError(o);
|
|
4
4
|
};
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var u = (
|
|
5
|
+
var L = (o, i, e) => i in o ? A(o, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[i] = e;
|
|
6
|
+
var h = (o, i, e) => L(o, typeof i != "symbol" ? i + "" : i, e), N = (o, i, e) => i.has(o) || k("Cannot " + e);
|
|
7
|
+
var w = (o, i, e) => i.has(o) ? k("Cannot add the same private member more than once") : i instanceof WeakSet ? i.add(o) : i.set(o, e);
|
|
8
|
+
var u = (o, i, e) => (N(o, i, "access private method"), e);
|
|
9
9
|
import { isBlank as g, isNumeric as T } from "ph-utils";
|
|
10
|
-
import
|
|
11
|
-
import { initAttr as
|
|
12
|
-
import { addClass as v, removeClass as
|
|
13
|
-
|
|
14
|
-
|
|
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 = "";
|
|
15
16
|
do
|
|
16
|
-
if (e && e.isSameNode(t) || t.tagName === "BODY" || (t.getAttribute && (
|
|
17
|
-
while (
|
|
18
|
-
return [
|
|
17
|
+
if (e && e.isSameNode(t) || t.tagName === "BODY" || (t.getAttribute && (a = t.getAttribute(i) || ""), a === "" && (t = t.parentNode), !t)) break;
|
|
18
|
+
while (a === "");
|
|
19
|
+
return [a !== "__stop__" && a !== "", a, t];
|
|
19
20
|
}
|
|
20
|
-
var
|
|
21
|
-
class F extends
|
|
21
|
+
var d, $, C;
|
|
22
|
+
class F extends j {
|
|
22
23
|
constructor() {
|
|
23
24
|
super();
|
|
24
|
-
|
|
25
|
+
w(this, d);
|
|
25
26
|
/**
|
|
26
27
|
* 标签类型:
|
|
27
28
|
* 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
|
|
28
29
|
* 2. bar - 选项卡
|
|
29
30
|
* 3. card - 卡片
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const [t,
|
|
37
|
-
t &&
|
|
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(
|
|
38
39
|
new CustomEvent("change", {
|
|
39
40
|
detail: {
|
|
40
|
-
name:
|
|
41
|
+
name: a
|
|
41
42
|
}
|
|
42
43
|
})
|
|
43
44
|
), this._updateActive(), this._updateLine());
|
|
44
45
|
});
|
|
45
|
-
|
|
46
|
+
W(this);
|
|
46
47
|
}
|
|
47
48
|
connectedCallback() {
|
|
48
|
-
this.
|
|
49
|
+
this.loadStyleText(M), v(this, `l-tabbar--${this.type}`), !g(this.gap) && !this.gap.startsWith("0") && v(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
|
|
49
50
|
}
|
|
50
51
|
static get observedAttributes() {
|
|
51
52
|
return ["name", "type", "justify-content", "gap"];
|
|
52
53
|
}
|
|
53
|
-
attributeChangedCallback(e, t,
|
|
54
|
+
attributeChangedCallback(e, t, a) {
|
|
54
55
|
if (e === "name") {
|
|
55
|
-
const
|
|
56
|
-
this.name =
|
|
56
|
+
const r = x(a, void 0);
|
|
57
|
+
this.name = r, this._updateActive(), this._updateLine();
|
|
57
58
|
} else if (e === "type") {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
let
|
|
61
|
-
|
|
59
|
+
const r = x(a, "nav");
|
|
60
|
+
if (r !== this.type && (y(this, `l-tabbar--${this.type}`), this.type = r, y(this, `l-tabbar--${r}`), r === "card")) {
|
|
61
|
+
let s = c(".l-tabbar-card-border", this.root);
|
|
62
|
+
s || (s = f("div", { class: "l-tabbar-card-border" }), this.root.appendChild(s));
|
|
62
63
|
}
|
|
63
64
|
} else {
|
|
64
|
-
const
|
|
65
|
-
this[e] =
|
|
66
|
-
const
|
|
67
|
-
|
|
65
|
+
const r = x(a, void 0);
|
|
66
|
+
this[e] = r;
|
|
67
|
+
const s = c(".l-tabbar-wrapper", this.root);
|
|
68
|
+
s && (s.style.cssText = u(this, d, $).call(this)), e === "gap" && (!g(this.gap) && !this.gap.startsWith("0") ? v(this, "l-tabbar-gap") : y(this, "l-tabbar-gap"));
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
71
|
disconnectedCallback() {
|
|
@@ -72,33 +73,33 @@ class F extends W {
|
|
|
72
73
|
}
|
|
73
74
|
render() {
|
|
74
75
|
const e = document.createDocumentFragment(), t = document.createElement("div");
|
|
75
|
-
if (t.className = "l-tabbar-wrapper", t.style.cssText = u(this,
|
|
76
|
-
const
|
|
77
|
-
t.appendChild(
|
|
76
|
+
if (t.className = "l-tabbar-wrapper", t.style.cssText = u(this, d, $).call(this), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
|
|
77
|
+
const r = document.createElement("slot");
|
|
78
|
+
t.appendChild(r);
|
|
78
79
|
} else {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
if (
|
|
87
|
-
const m =
|
|
80
|
+
const r = _("[l-name]", this);
|
|
81
|
+
r.length > 0 && E(r, (s) => {
|
|
82
|
+
const p = s.getAttribute("l-name");
|
|
83
|
+
if (p) {
|
|
84
|
+
const l = s.cloneNode(!0);
|
|
85
|
+
l.classList.add("l-tabbar-item"), l.setAttribute("part", "item"), p === this.name && l.classList.add("active");
|
|
86
|
+
const b = c("[l-icon]", l), n = _(":not([l-icon])", l);
|
|
87
|
+
if (b) {
|
|
88
|
+
const m = f("div", {
|
|
88
89
|
class: [
|
|
89
90
|
"l-tabbar-item-icon",
|
|
90
|
-
|
|
91
|
+
n.length === 0 ? "only" : void 0
|
|
91
92
|
]
|
|
92
93
|
});
|
|
93
|
-
m.appendChild(
|
|
94
|
+
m.appendChild(b.cloneNode(!0)), b.replaceWith(m);
|
|
94
95
|
}
|
|
95
|
-
t.appendChild(
|
|
96
|
+
t.appendChild(l);
|
|
96
97
|
}
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
100
|
if (e.appendChild(t), this.type === "card") {
|
|
100
|
-
const
|
|
101
|
-
e.appendChild(
|
|
101
|
+
const r = f("div", { class: "l-tabbar-card-border" });
|
|
102
|
+
e.appendChild(r);
|
|
102
103
|
}
|
|
103
104
|
return e;
|
|
104
105
|
}
|
|
@@ -108,8 +109,8 @@ class F extends W {
|
|
|
108
109
|
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
109
110
|
*/
|
|
110
111
|
setItems(e) {
|
|
111
|
-
const t =
|
|
112
|
-
t && (t.innerHTML = "", t.appendChild(u(this,
|
|
112
|
+
const t = c(".l-tabbar-wrapper", this.root);
|
|
113
|
+
t && (t.innerHTML = "", t.appendChild(u(this, d, C).call(this, e)));
|
|
113
114
|
}
|
|
114
115
|
/**
|
|
115
116
|
* 向标签栏添加项目。
|
|
@@ -117,8 +118,8 @@ class F extends W {
|
|
|
117
118
|
* @returns 无返回值。
|
|
118
119
|
*/
|
|
119
120
|
addItems(e) {
|
|
120
|
-
const t =
|
|
121
|
-
t && t.appendChild(u(this,
|
|
121
|
+
const t = c(".l-tabbar-wrapper", this.root);
|
|
122
|
+
t && t.appendChild(u(this, d, C).call(this, e));
|
|
122
123
|
}
|
|
123
124
|
_init() {
|
|
124
125
|
S(this.root, "click", this._handleClick), setTimeout(() => {
|
|
@@ -126,13 +127,13 @@ class F extends W {
|
|
|
126
127
|
}, 300);
|
|
127
128
|
}
|
|
128
129
|
_destroy() {
|
|
129
|
-
|
|
130
|
+
z(this.root, "click", this._handleClick), this.$line = void 0;
|
|
130
131
|
}
|
|
131
132
|
_updateActive() {
|
|
132
|
-
const t = this.getAttr("custom-content", !1) ? this : this.root,
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
133
|
+
const t = this.getAttr("custom-content", !1) ? this : this.root, a = c(".active", t);
|
|
134
|
+
a && y(a, "active");
|
|
135
|
+
const r = c(`[l-name="${this.name}"]`, t);
|
|
136
|
+
r && v(r, "active");
|
|
136
137
|
}
|
|
137
138
|
/**
|
|
138
139
|
* 初始化线条的方法,在微任务队列中执行。
|
|
@@ -141,51 +142,52 @@ class F extends W {
|
|
|
141
142
|
_updateLine() {
|
|
142
143
|
queueMicrotask(() => {
|
|
143
144
|
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
144
|
-
const e = this.getAttr("custom-content", !1), t =
|
|
145
|
+
const e = this.getAttr("custom-content", !1), t = c(".active", e ? this : this.root);
|
|
145
146
|
if (!t) return;
|
|
146
|
-
const
|
|
147
|
+
const a = t.offsetLeft;
|
|
147
148
|
if (!this.$line) {
|
|
148
|
-
const
|
|
149
|
-
|
|
149
|
+
const r = f("div", { class: "l-tabbar--bar-line" });
|
|
150
|
+
r.part = "line", this.root.appendChild(r), this.$line = c(".l-tabbar--bar-line", this.root);
|
|
150
151
|
}
|
|
151
|
-
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${
|
|
152
|
-
left:
|
|
152
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${a}px`, B(t, this) || this.scrollTo({
|
|
153
|
+
left: a,
|
|
153
154
|
behavior: "smooth"
|
|
154
155
|
});
|
|
155
156
|
});
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
|
-
|
|
159
|
+
d = new WeakSet(), $ = function() {
|
|
159
160
|
const e = {}, t = this.getAttr("justify-content");
|
|
160
161
|
if (g(t) || (e["justify-content"] = t), !g(this.gap)) {
|
|
161
|
-
let
|
|
162
|
-
T(
|
|
162
|
+
let a = this.gap;
|
|
163
|
+
T(a, { isPositive: !0 }) && (a = `${a}px`), e["--l-tabbar-item-gap"] = a;
|
|
163
164
|
}
|
|
164
|
-
return
|
|
165
|
-
},
|
|
165
|
+
return D(e);
|
|
166
|
+
}, C = function(e) {
|
|
166
167
|
const t = document.createDocumentFragment();
|
|
167
|
-
for (let
|
|
168
|
-
const
|
|
169
|
-
class:
|
|
168
|
+
for (let a = 0, r = e.length; a < r; a++) {
|
|
169
|
+
const s = e[a], p = f("div", {
|
|
170
|
+
class: I([
|
|
170
171
|
"l-tabbar-item",
|
|
171
|
-
this.name ===
|
|
172
|
+
this.name === s.name ? "active" : void 0
|
|
172
173
|
]),
|
|
173
|
-
"l-name":
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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);
|
|
179
181
|
}
|
|
180
|
-
const
|
|
181
|
-
if (
|
|
182
|
-
let
|
|
183
|
-
typeof
|
|
182
|
+
const b = s.text;
|
|
183
|
+
if (b) {
|
|
184
|
+
let n = typeof b == "string" ? b : b();
|
|
185
|
+
typeof n == "string" ? p.appendChild(f(n)) : p.appendChild(n);
|
|
184
186
|
}
|
|
185
|
-
t.appendChild(
|
|
187
|
+
t.appendChild(p);
|
|
186
188
|
}
|
|
187
189
|
return t;
|
|
188
|
-
},
|
|
190
|
+
}, h(F, "baseName", "tabbar");
|
|
189
191
|
export {
|
|
190
192
|
F as default,
|
|
191
193
|
R as shouldEventNext
|
package/lib/theme/index.js
CHANGED
|
@@ -3,93 +3,93 @@ var b = (e) => {
|
|
|
3
3
|
throw TypeError(e);
|
|
4
4
|
};
|
|
5
5
|
var E = (e, n, t) => n in e ? C(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
6
|
-
var
|
|
7
|
-
var
|
|
6
|
+
var a = (e, n, t) => E(e, typeof n != "symbol" ? n + "" : n, t), m = (e, n, t) => n.has(e) || b("Cannot " + t);
|
|
7
|
+
var s = (e, n, t) => (m(e, n, "read from private field"), t ? t.call(e) : n.get(e)), u = (e, n, t) => n.has(e) ? b("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(e) : n.set(e, t), p = (e, n, t, o) => (m(e, n, "write to private field"), o ? o.call(e, t) : n.set(e, t), t), c = (e, n, t) => (m(e, n, "access private method"), t);
|
|
8
8
|
import M from "../base.js";
|
|
9
9
|
import { initAttr as R } from "../utils/index.js";
|
|
10
|
-
import { create as d, $one as H, on as
|
|
10
|
+
import { create as d, $one as H, on as v, off as k } from "ph-utils/dom";
|
|
11
11
|
import { getTheme as L, applyTheme as j } from "ph-utils/theme";
|
|
12
|
-
const A = [
|
|
12
|
+
const A = ":host{display:inline-flex}.l-theme-btn::part(default){--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-text-color: #9ca3af;--l-btn-hover-text-color: #666666;width:var(--l-form-edit-height, 32px);padding:0;font-size:18px}.l-theme-switch.l-switch--checked{background-color:#65757129;border-color:#3c3f44}.l-theme-switch.l-switch--checked::part(action){background-color:#000;color:#fff}html.dark .l-theme-btn{--l-btn-hover-text-color: #ffffff}", B = [
|
|
13
13
|
{ value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
|
|
14
14
|
{ value: "light", text: "浅色模式", icon: "l-sun-icon" },
|
|
15
15
|
{ value: "dark", text: "深色模式", icon: "l-moon-icon" }
|
|
16
16
|
];
|
|
17
|
-
var l, i,
|
|
18
|
-
class
|
|
17
|
+
var l, i, g, f, w, x, $, h, y, T;
|
|
18
|
+
class I extends M {
|
|
19
19
|
constructor() {
|
|
20
20
|
super();
|
|
21
21
|
u(this, i);
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
a(this, "type", "button");
|
|
23
|
+
a(this, "label", "text");
|
|
24
|
+
a(this, "theme");
|
|
25
25
|
u(this, l);
|
|
26
|
-
u(this,
|
|
27
|
-
let
|
|
26
|
+
u(this, h, async (t) => {
|
|
27
|
+
let o;
|
|
28
28
|
if (this.type === "button")
|
|
29
|
-
|
|
29
|
+
o = this.theme === "dark" ? "auto" : "dark";
|
|
30
30
|
else {
|
|
31
|
-
const
|
|
32
|
-
this.type !== "switch" ?
|
|
31
|
+
const r = t.target.value;
|
|
32
|
+
this.type !== "switch" ? o = r : o = r ? "dark" : "light";
|
|
33
33
|
}
|
|
34
|
-
await j(
|
|
34
|
+
await j(o), this.theme = o, this.type === "button" && c(this, i, f).call(this, s(this, l)), this.dispatchEvent(new CustomEvent("change", { detail: o }));
|
|
35
35
|
});
|
|
36
36
|
R(this), this.theme = L();
|
|
37
37
|
}
|
|
38
38
|
connectedCallback() {
|
|
39
|
-
this.
|
|
39
|
+
this.loadStyleText(A), super.connectedCallback(), c(this, i, y).call(this);
|
|
40
40
|
}
|
|
41
41
|
disconnectedCallback() {
|
|
42
|
-
super.disconnectedCallback(),
|
|
42
|
+
super.disconnectedCallback(), c(this, i, T).call(this);
|
|
43
43
|
}
|
|
44
44
|
render() {
|
|
45
45
|
switch (this.type) {
|
|
46
46
|
case "select":
|
|
47
|
-
return
|
|
47
|
+
return c(this, i, w).call(this);
|
|
48
48
|
case "radio":
|
|
49
|
-
return
|
|
49
|
+
return c(this, i, $).call(this);
|
|
50
50
|
case "switch":
|
|
51
|
-
return
|
|
51
|
+
return c(this, i, x).call(this);
|
|
52
52
|
default:
|
|
53
|
-
return
|
|
53
|
+
return c(this, i, g).call(this);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
l = new WeakMap(), i = new WeakSet(),
|
|
57
|
+
l = new WeakMap(), i = new WeakSet(), g = function() {
|
|
58
58
|
const t = d("l-button", {
|
|
59
59
|
class: "l-theme-btn l-theme-inner"
|
|
60
60
|
});
|
|
61
|
-
return
|
|
62
|
-
},
|
|
63
|
-
const
|
|
64
|
-
t.innerHTML = `<l-${
|
|
65
|
-
},
|
|
61
|
+
return c(this, i, f).call(this, t), t;
|
|
62
|
+
}, f = function(t) {
|
|
63
|
+
const o = this.theme === "auto" ? "sun" : "moon";
|
|
64
|
+
t.innerHTML = `<l-${o}-icon></l-${o}-icon>`;
|
|
65
|
+
}, w = function() {
|
|
66
66
|
const t = d("l-select-ori", {
|
|
67
67
|
class: "l-theme-inner"
|
|
68
68
|
});
|
|
69
69
|
t.value = this.theme;
|
|
70
|
-
const
|
|
70
|
+
const o = [
|
|
71
71
|
'<option value="auto">跟随系统</option>',
|
|
72
72
|
'<option value="light">浅色模式</option>',
|
|
73
73
|
'<option value="dark">深色模式</option>'
|
|
74
74
|
];
|
|
75
|
-
return t.innerHTML =
|
|
76
|
-
},
|
|
75
|
+
return t.innerHTML = o.join(""), t;
|
|
76
|
+
}, x = function() {
|
|
77
77
|
const t = d("l-switch", {
|
|
78
78
|
class: "l-theme-switch l-theme-inner"
|
|
79
79
|
});
|
|
80
80
|
return t.value = this.theme === "dark", t.innerHTML = '<l-sun-icon slot="unchecked-action"></l-sun-icon><l-moon-icon slot="checked-action"></l-moon-icon>', t;
|
|
81
|
-
},
|
|
81
|
+
}, $ = function() {
|
|
82
82
|
const t = d("l-radio", {
|
|
83
83
|
class: "l-theme-inner"
|
|
84
84
|
});
|
|
85
85
|
t.value = this.theme, t.type = "button";
|
|
86
|
-
const
|
|
87
|
-
return t.innerHTML =
|
|
88
|
-
},
|
|
89
|
-
p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ?
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
},
|
|
86
|
+
const o = B.map((r) => this.label === "icon" ? `<${r.icon} radio-value="${r.value}"></${r.icon}>` : `<span radio-value="${r.value}">${r.text}</span>`);
|
|
87
|
+
return t.innerHTML = o.join(""), t;
|
|
88
|
+
}, h = new WeakMap(), y = function() {
|
|
89
|
+
p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ? v(s(this, l), "click", s(this, h)) : v(s(this, l), "change", s(this, h));
|
|
90
|
+
}, T = function() {
|
|
91
|
+
s(this, l) && (this.type === "button" ? k(s(this, l), "click", s(this, h)) : k(s(this, l), "change", s(this, h)), p(this, l, void 0));
|
|
92
|
+
}, a(I, "baseName", "theme");
|
|
93
93
|
export {
|
|
94
|
-
|
|
94
|
+
I as default
|
|
95
95
|
};
|