litos-ui 0.12.1 → 0.12.2
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.d.ts +1 -14
- package/lib/base.js +5 -22
- package/lib/button/index.d.ts +1 -3
- package/lib/button/index.js +19 -18
- package/lib/form/form_inner.d.ts +2 -7
- package/lib/form/form_inner.js +20 -26
- package/lib/form/form_item.d.ts +2 -0
- package/lib/form/form_item.js +9 -5
- package/lib/form/index.d.ts +2 -0
- package/lib/form/index.js +25 -23
- package/lib/icon/base.d.ts +1 -0
- package/lib/icon/base.js +17 -15
- package/lib/index.d.ts +2 -26
- package/lib/index.js +83 -106
- package/lib/input/index.d.ts +2 -1
- package/lib/input/index.js +8 -5
- package/lib/list/index.d.ts +1 -1
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -0
- package/lib/popover/index.d.ts +4 -1
- package/lib/popover/index.js +12 -6
- package/lib/radio/index.js +3 -3
- package/lib/select_ori/index.d.ts +2 -0
- package/lib/select_ori/index.js +15 -11
- package/lib/switch/index.d.ts +1 -0
- package/lib/switch/index.js +13 -8
- package/lib/tabbar/index.d.ts +1 -0
- package/lib/tabbar/index.js +63 -55
- package/lib/theme/index.d.ts +2 -1
- package/lib/theme/index.js +12 -9
- package/lib/utils/index.d.ts +5 -0
- package/lib/utils/index.js +52 -45
- package/lib/utils/transition.js +2 -3
- package/package.json +1 -1
- package/lib/date_picker/index.d.ts +0 -22
- package/lib/date_picker/index.js +0 -99
- package/lib/dialog/dialog_container.d.ts +0 -28
- package/lib/dialog/dialog_container.js +0 -100
- package/lib/dialog/index.d.ts +0 -30
- package/lib/dialog/index.js +0 -86
- package/lib/icon/close.d.ts +0 -5
- package/lib/icon/close.js +0 -10
- package/lib/loading/index.d.ts +0 -45
- package/lib/loading/index.js +0 -141
- package/lib/menu/base.js +0 -1
- package/lib/menu/index.d.ts +0 -29
- package/lib/menu/index.js +0 -90
- package/lib/menu/menu_item.d.ts +0 -6
- package/lib/menu/menu_item.js +0 -21
- package/lib/menu/sub_menu.d.ts +0 -13
- package/lib/menu/sub_menu.js +0 -64
- package/lib/modal/index.d.ts +0 -40
- package/lib/modal/index.js +0 -153
- package/lib/modal/modal_box.js +0 -95
package/lib/popover/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import x from "../base.js";
|
|
2
2
|
import { initAttr as k, useId as $, getPopoverOffsetY as C, getPopoverOffsetX as y, impactDetect as z } from "../utils/index.js";
|
|
3
|
-
import { set as T, remove as
|
|
3
|
+
import { set as T, remove as A } from "../utils/clickoutside.js";
|
|
4
4
|
import { $one as p, $$ as g, on as s, off as i } from "ph-utils/dom";
|
|
5
|
-
const
|
|
5
|
+
const P = ':host{width:max-content;position:relative}.l-popover--content{--l-popover-border-color: #e4e4e4;--l-popover-color: #666666;--l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, .12);--l-popover-background: #ffffff;--l-popover-arrow-size: 8px;--l-popover-offset: 10px;position:absolute;width:max-content;box-shadow:var(--l-popover-box-shadow);background:var(--l-popover-background);border:1px solid var(--l-popover-border-color);border-radius:4px;padding:10px;z-index:30;color:var(--l-popover-color);box-sizing:border-box}.l-popover-tooltip{--l-popover-color: #fff;--l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, .3);--l-popover-background: #383838;--l-popover-arrow-size: 6px;border-radius:5px;padding:8px;font-size:12px;line-height:1}.l-popover--arrow{position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);z-index:-1}.l-popover--arrow:before{content:"";position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);transform:rotate3d(0,0,1,45deg);background-color:var(--l-popover-background);border-width:1px;border-style:solid}.l-popover-top,.l-popover-top-start,.l-popover-top-end{bottom:calc(100% + var(--l-popover-offset, 10px))}.l-popover-bottom,.l-popover-bottom-start,.l-popover-bottom-end{top:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top-start,.l-popover-bottom-start{left:0}.l-popover-top-end,.l-popover-bottom-end{right:0}.l-popover-bottom,.l-popover-top{left:50%;transform:translate3d(-50%,0,0)}.l-popover-left-start,.l-popover-left,.l-popover-left-end{right:calc(100% + var(--l-popover-offset, 10px))}.l-popover-left-start,.l-popover-right-start{top:0}.l-popover-left-end,.l-popover-right-end{bottom:0}.l-popover-left,.l-popover-right{top:50%;transform:translate3d(0,-50%,0)}.l-popover-right-start,.l-popover-right,.l-popover-right-end{left:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top .l-popover--arrow,.l-popover-bottom .l-popover--arrow{left:50%;margin-left:-4px}.l-popover-top .l-popover--arrow:before,.l-popover-top-start .l-popover--arrow:before,.l-popover-top-end .l-popover--arrow:before{border-color:transparent var(--l-popover-border-color) var(--l-popover-border-color) transparent}.l-popover-bottom .l-popover--arrow:before,.l-popover-bottom-start .l-popover--arrow:before,.l-popover-bottom-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) transparent transparent var(--l-popover-border-color)}.l-popover-top .l-popover--arrow,.l-popover-top-start .l-popover--arrow,.l-popover-top-end .l-popover--arrow{bottom:calc((var(--l-popover-arrow-size, 8px) / -2) + 1px)}.l-popover-top-start .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow{left:10px}.l-popover-top-end .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{right:10px}.l-popover-bottom .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{top:calc((var(--l-popover-arrow-size, 8px) / -2) - 1px)}.l-popover-left .l-popover--arrow,.l-popover-left-start .l-popover--arrow,.l-popover-left-end .l-popover--arrow{margin-top:-4px;right:-4px}.l-popover-left-start .l-popover--arrow:before,.l-popover-left .l-popover--arrow:before,.l-popover-left-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) var(--l-popover-border-color) transparent transparent}.l-popover-right .l-popover--arrow,.l-popover-right-start .l-popover--arrow,.l-popover-right-end .l-popover--arrow{margin-top:-4px;left:-4px}.l-popover-right-start .l-popover--arrow:before,.l-popover-right .l-popover--arrow:before,.l-popover-right-end .l-popover--arrow:before{border-color:transparent transparent var(--l-popover-border-color) var(--l-popover-border-color)}.l-popover-left .l-popover--arrow,.l-popover-right .l-popover--arrow{top:50%}.l-popover-left-start .l-popover--arrow,.l-popover-right-start .l-popover--arrow{top:10px}.l-popover-left-end .l-popover--arrow,.l-popover-right-end .l-popover--arrow{bottom:10px}';
|
|
6
6
|
class M extends x {
|
|
7
7
|
static baseName = "popover";
|
|
8
8
|
placement = "top";
|
|
@@ -20,10 +20,15 @@ class M extends x {
|
|
|
20
20
|
/** 浮层定位方式 */
|
|
21
21
|
position = "absolute";
|
|
22
22
|
theme = "default";
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* @property inline = false
|
|
25
|
+
*/
|
|
24
26
|
_t;
|
|
27
|
+
constructor() {
|
|
28
|
+
super(), k(this);
|
|
29
|
+
}
|
|
25
30
|
connectedCallback() {
|
|
26
|
-
|
|
31
|
+
this.loadStyleText(P), this.#t(), super.connectedCallback(), this.renderContent(), this.#p();
|
|
27
32
|
}
|
|
28
33
|
disconnectedCallback() {
|
|
29
34
|
super.disconnectedCallback(), this.#l();
|
|
@@ -57,7 +62,8 @@ class M extends x {
|
|
|
57
62
|
return this.content ? `<span>${this.content}</span>` : "<slot></slot>";
|
|
58
63
|
}
|
|
59
64
|
#t() {
|
|
60
|
-
|
|
65
|
+
const o = this.getAttr("inline", !1);
|
|
66
|
+
this.style.display = o ? "inline-block" : "block", this.id || (this.id = `${$()}-popover`);
|
|
61
67
|
}
|
|
62
68
|
hideContent() {
|
|
63
69
|
const o = p(".l-popover--content", this.root);
|
|
@@ -69,7 +75,7 @@ class M extends x {
|
|
|
69
75
|
}
|
|
70
76
|
#l() {
|
|
71
77
|
const o = p('[slot="trigger"]', this);
|
|
72
|
-
o && (this.trigger === "hover" ? (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (i(o, "click", this.#e),
|
|
78
|
+
o && (this.trigger === "hover" ? (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (i(o, "click", this.#e), A(o)));
|
|
73
79
|
}
|
|
74
80
|
#s = (o) => {
|
|
75
81
|
o.target.id !== this.id && this.hide();
|
package/lib/radio/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { initAttr as $,
|
|
1
|
+
import { initAttr as $, tagAttr as s, parseAttrValue as x } from "../utils/index.js";
|
|
2
2
|
import y from "../form/form_inner.js";
|
|
3
3
|
import { $one as a, hasClass as u, addClass as n, $ as c, iterate as h, getAttr as C, removeClass as b, formatClass as A, on as E, off as I } from "ph-utils/dom";
|
|
4
4
|
import { random as p } from "ph-utils";
|
|
@@ -13,10 +13,10 @@ class T extends y {
|
|
|
13
13
|
this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
|
|
14
14
|
}
|
|
15
15
|
constructor() {
|
|
16
|
-
super(!1);
|
|
16
|
+
super(!1), $(this);
|
|
17
17
|
}
|
|
18
18
|
connectedCallback() {
|
|
19
|
-
|
|
19
|
+
super.connectedCallback(), this.loadStyleText(w), this._initEvents();
|
|
20
20
|
}
|
|
21
21
|
disconnectedCallback() {
|
|
22
22
|
super.disconnectedCallback(), this._removeEvents();
|
package/lib/select_ori/index.js
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { initAttr as c, tagAttrs as
|
|
3
|
-
import { $one as
|
|
4
|
-
import { i as
|
|
5
|
-
class
|
|
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
6
|
static baseName = "select-ori";
|
|
7
7
|
$select;
|
|
8
|
+
changeEmit;
|
|
9
|
+
constructor() {
|
|
10
|
+
super(), c(this), this.changeEmit = new CustomEvent("change");
|
|
11
|
+
}
|
|
8
12
|
connectedCallback() {
|
|
9
|
-
|
|
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);
|
|
10
14
|
}
|
|
11
15
|
disconnectedCallback() {
|
|
12
|
-
super.disconnectedCallback(), this.$select &&
|
|
16
|
+
super.disconnectedCallback(), this.$select && u(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
|
|
13
17
|
}
|
|
14
18
|
render() {
|
|
15
19
|
let e = this.innerHTML.trim();
|
|
16
|
-
return `<select class="l-input"${
|
|
20
|
+
return `<select class="l-input"${h([
|
|
17
21
|
["name", this.getName()],
|
|
18
22
|
["disabled", this.isDisabled()]
|
|
19
23
|
])}>${e}</select>`;
|
|
@@ -29,7 +33,7 @@ class g extends n {
|
|
|
29
33
|
appendOptions(e) {
|
|
30
34
|
if (!this.$select) return;
|
|
31
35
|
const t = document.createDocumentFragment();
|
|
32
|
-
for (let s = 0,
|
|
36
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
33
37
|
const l = e[s], i = document.createElement("option");
|
|
34
38
|
i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
|
|
35
39
|
}
|
|
@@ -43,9 +47,9 @@ class g extends n {
|
|
|
43
47
|
}
|
|
44
48
|
_handleChange = (e) => {
|
|
45
49
|
const t = e.target.value;
|
|
46
|
-
super.setValue(t), this.dispatchEvent(
|
|
50
|
+
super.setValue(t), this.dispatchEvent(this.changeEmit);
|
|
47
51
|
};
|
|
48
52
|
}
|
|
49
53
|
export {
|
|
50
|
-
|
|
54
|
+
f as default
|
|
51
55
|
};
|
package/lib/switch/index.d.ts
CHANGED
package/lib/switch/index.js
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import { on as c, off as h, addClass as o, removeClass as
|
|
2
|
-
import
|
|
3
|
-
import { initAttr as a } from "../utils/index.js";
|
|
4
|
-
const
|
|
5
|
-
class
|
|
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
6
|
static baseName = "switch";
|
|
7
7
|
actionRender;
|
|
8
8
|
checkedText;
|
|
9
9
|
uncheckedText;
|
|
10
|
+
constructor() {
|
|
11
|
+
super(!1), a(this);
|
|
12
|
+
const t = this.value ? r(this.value, !1, "value") : !1;
|
|
13
|
+
this._resetValue = t, this.value = t;
|
|
14
|
+
}
|
|
10
15
|
connectedCallback() {
|
|
11
|
-
|
|
16
|
+
this.loadStyleText(d), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
|
|
12
17
|
}
|
|
13
18
|
disconnectedCallback() {
|
|
14
19
|
super.disconnectedCallback(), h(this, "click", this.#e), this.actionRender = void 0;
|
|
@@ -26,7 +31,7 @@ class f extends l {
|
|
|
26
31
|
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
27
32
|
};
|
|
28
33
|
setValue(t) {
|
|
29
|
-
super.setValue(t), t ? o(this, "l-switch--checked") :
|
|
34
|
+
super.setValue(t), t ? o(this, "l-switch--checked") : l(this, "l-switch--checked");
|
|
30
35
|
const e = i(".l-switch-text", this.root);
|
|
31
36
|
e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
|
|
32
37
|
}
|
|
@@ -46,5 +51,5 @@ class f extends l {
|
|
|
46
51
|
}
|
|
47
52
|
}
|
|
48
53
|
export {
|
|
49
|
-
|
|
54
|
+
w as default
|
|
50
55
|
};
|
package/lib/tabbar/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ type TabbarItem = {
|
|
|
4
4
|
text?: string | (() => string | HTMLElement);
|
|
5
5
|
icon?: string | (() => string | HTMLElement);
|
|
6
6
|
};
|
|
7
|
+
export declare function shouldEventNext(e: Event, eventFlag: string, endRoot?: HTMLElement | ShadowRoot): [boolean, string, HTMLElement];
|
|
7
8
|
export default class Tabbar extends BaseComponent {
|
|
8
9
|
#private;
|
|
9
10
|
static baseName: string;
|
package/lib/tabbar/index.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import { isBlank as p, isNumeric as
|
|
2
|
-
import
|
|
3
|
-
import { initAttr as
|
|
4
|
-
import { addClass as h, removeClass as f, $one as l, create as b, $ as
|
|
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
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
|
-
|
|
6
|
+
function N(u, r, t) {
|
|
7
|
+
let e = u.target, a = "";
|
|
8
|
+
do
|
|
9
|
+
if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (a = e.getAttribute(r) || ""), a === "" && (e = e.parentNode), !e)) break;
|
|
10
|
+
while (a === "");
|
|
11
|
+
return [a !== "__stop__" && a !== "", a, e];
|
|
12
|
+
}
|
|
13
|
+
class S extends y {
|
|
7
14
|
static baseName = "tabbar";
|
|
8
15
|
/**
|
|
9
16
|
* 标签类型:
|
|
@@ -16,7 +23,7 @@ class R extends v {
|
|
|
16
23
|
gap;
|
|
17
24
|
$line;
|
|
18
25
|
constructor() {
|
|
19
|
-
super(),
|
|
26
|
+
super(), x(this);
|
|
20
27
|
}
|
|
21
28
|
connectedCallback() {
|
|
22
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();
|
|
@@ -24,39 +31,39 @@ class R extends v {
|
|
|
24
31
|
static get observedAttributes() {
|
|
25
32
|
return ["name", "type", "justify-content", "gap"];
|
|
26
33
|
}
|
|
27
|
-
attributeChangedCallback(
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
this.name =
|
|
31
|
-
} else if (
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
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")) {
|
|
34
41
|
let i = l(".l-tabbar-card-border", this.root);
|
|
35
42
|
i || (i = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(i));
|
|
36
43
|
}
|
|
37
44
|
} else {
|
|
38
|
-
const
|
|
39
|
-
this[
|
|
45
|
+
const a = m(e, void 0);
|
|
46
|
+
this[r] = a;
|
|
40
47
|
const i = l(".l-tabbar-wrapper", this.root);
|
|
41
|
-
i && (i.style.cssText = this.#t()),
|
|
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"));
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
disconnectedCallback() {
|
|
45
52
|
super.disconnectedCallback(), this._destroy();
|
|
46
53
|
}
|
|
47
54
|
render() {
|
|
48
|
-
const
|
|
55
|
+
const r = document.createDocumentFragment(), t = document.createElement("div");
|
|
49
56
|
if (t.className = "l-tabbar-wrapper", t.style.cssText = this.#t(), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
|
|
50
|
-
const
|
|
51
|
-
t.appendChild(
|
|
57
|
+
const a = document.createElement("slot");
|
|
58
|
+
t.appendChild(a);
|
|
52
59
|
} else {
|
|
53
|
-
const
|
|
54
|
-
|
|
60
|
+
const a = g("[l-name]", this);
|
|
61
|
+
a.length > 0 && $(a, (i) => {
|
|
55
62
|
const c = i.getAttribute("l-name");
|
|
56
63
|
if (c) {
|
|
57
64
|
const o = i.cloneNode(!0);
|
|
58
65
|
o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), c === this.name && o.classList.add("active");
|
|
59
|
-
const n = l("[l-icon]", o), s =
|
|
66
|
+
const n = l("[l-icon]", o), s = g(":not([l-icon])", o);
|
|
60
67
|
if (n) {
|
|
61
68
|
const d = b("div", {
|
|
62
69
|
class: [
|
|
@@ -70,53 +77,53 @@ class R extends v {
|
|
|
70
77
|
}
|
|
71
78
|
});
|
|
72
79
|
}
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
80
|
+
if (r.appendChild(t), this.type === "card") {
|
|
81
|
+
const a = b("div", { class: "l-tabbar-card-border" });
|
|
82
|
+
r.appendChild(a);
|
|
76
83
|
}
|
|
77
|
-
return
|
|
84
|
+
return r;
|
|
78
85
|
}
|
|
79
86
|
/**
|
|
80
87
|
* 设置选项卡栏的项目列表。
|
|
81
88
|
* @param items - 选项卡栏项目的数组。
|
|
82
89
|
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
83
90
|
*/
|
|
84
|
-
setItems(
|
|
91
|
+
setItems(r) {
|
|
85
92
|
const t = l(".l-tabbar-wrapper", this.root);
|
|
86
|
-
t && (t.innerHTML = "", t.appendChild(this.#e(
|
|
93
|
+
t && (t.innerHTML = "", t.appendChild(this.#e(r)));
|
|
87
94
|
}
|
|
88
95
|
/**
|
|
89
96
|
* 向标签栏添加项目。
|
|
90
97
|
* @param items 要添加的标签栏项目数组。
|
|
91
98
|
* @returns 无返回值。
|
|
92
99
|
*/
|
|
93
|
-
addItems(
|
|
100
|
+
addItems(r) {
|
|
94
101
|
const t = l(".l-tabbar-wrapper", this.root);
|
|
95
|
-
t && t.appendChild(this.#e(
|
|
102
|
+
t && t.appendChild(this.#e(r));
|
|
96
103
|
}
|
|
97
104
|
_init() {
|
|
98
|
-
|
|
105
|
+
C(this.root, "click", this._handleClick), setTimeout(() => {
|
|
99
106
|
this._updateLine();
|
|
100
107
|
}, 300);
|
|
101
108
|
}
|
|
102
109
|
_destroy() {
|
|
103
|
-
|
|
110
|
+
k(this.root, "click", this._handleClick), this.$line = void 0;
|
|
104
111
|
}
|
|
105
|
-
_handleClick = (
|
|
106
|
-
const [t,
|
|
107
|
-
t &&
|
|
112
|
+
_handleClick = (r) => {
|
|
113
|
+
const [t, e] = N(r, "l-name", this.root);
|
|
114
|
+
t && e !== this.name && (this.name = e, this.dispatchEvent(
|
|
108
115
|
new CustomEvent("change", {
|
|
109
116
|
detail: {
|
|
110
|
-
name:
|
|
117
|
+
name: e
|
|
111
118
|
}
|
|
112
119
|
})
|
|
113
120
|
), this._updateActive(), this._updateLine());
|
|
114
121
|
};
|
|
115
122
|
_updateActive() {
|
|
116
|
-
const t = this.getAttr("custom-content", !1) ? this : this.root,
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
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");
|
|
120
127
|
}
|
|
121
128
|
/**
|
|
122
129
|
* 初始化线条的方法,在微任务队列中执行。
|
|
@@ -125,31 +132,31 @@ class R extends v {
|
|
|
125
132
|
_updateLine() {
|
|
126
133
|
queueMicrotask(() => {
|
|
127
134
|
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
128
|
-
const
|
|
135
|
+
const r = this.getAttr("custom-content", !1), t = l(".active", r ? this : this.root);
|
|
129
136
|
if (!t) return;
|
|
130
|
-
const
|
|
137
|
+
const e = t.offsetLeft;
|
|
131
138
|
if (!this.$line) {
|
|
132
|
-
const
|
|
133
|
-
|
|
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);
|
|
134
141
|
}
|
|
135
|
-
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${
|
|
136
|
-
left:
|
|
142
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, w(t, this) || this.scrollTo({
|
|
143
|
+
left: e,
|
|
137
144
|
behavior: "smooth"
|
|
138
145
|
});
|
|
139
146
|
});
|
|
140
147
|
}
|
|
141
148
|
#t() {
|
|
142
|
-
const
|
|
143
|
-
if (p(t) || (
|
|
144
|
-
let
|
|
145
|
-
|
|
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;
|
|
146
153
|
}
|
|
147
|
-
return _(
|
|
154
|
+
return _(r);
|
|
148
155
|
}
|
|
149
|
-
#e(
|
|
156
|
+
#e(r) {
|
|
150
157
|
const t = document.createDocumentFragment();
|
|
151
|
-
for (let
|
|
152
|
-
const i = e
|
|
158
|
+
for (let e = 0, a = r.length; e < a; e++) {
|
|
159
|
+
const i = r[e], c = b("div", {
|
|
153
160
|
class: A([
|
|
154
161
|
"l-tabbar-item",
|
|
155
162
|
this.name === i.name ? "active" : void 0
|
|
@@ -173,5 +180,6 @@ class R extends v {
|
|
|
173
180
|
}
|
|
174
181
|
}
|
|
175
182
|
export {
|
|
176
|
-
|
|
183
|
+
S as default,
|
|
184
|
+
N as shouldEventNext
|
|
177
185
|
};
|
package/lib/theme/index.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export default class Theme extends BaseComponent {
|
|
|
4
4
|
static baseName: string;
|
|
5
5
|
type: "button" | "select" | "switch" | "radio";
|
|
6
6
|
label?: "text" | "icon";
|
|
7
|
-
theme
|
|
7
|
+
theme: string;
|
|
8
|
+
constructor();
|
|
8
9
|
connectedCallback(): void;
|
|
9
10
|
disconnectedCallback(): void;
|
|
10
11
|
render(): any;
|
package/lib/theme/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import l from "../base.js";
|
|
2
|
-
import { initAttr as
|
|
3
|
-
import { create as i, $one as
|
|
4
|
-
import { getTheme as
|
|
2
|
+
import { initAttr as c } from "../utils/index.js";
|
|
3
|
+
import { create as i, $one as r, on as o, off as s } from "ph-utils/dom";
|
|
4
|
+
import { getTheme as h, applyTheme as a } from "ph-utils/theme";
|
|
5
5
|
const u = ":host{display:inline-flex;width:auto}.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}", d = [
|
|
6
6
|
{ value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
|
|
7
7
|
{ value: "light", text: "浅色模式", icon: "l-sun-icon" },
|
|
@@ -13,11 +13,14 @@ class k extends l {
|
|
|
13
13
|
label = "text";
|
|
14
14
|
theme;
|
|
15
15
|
#t;
|
|
16
|
+
constructor() {
|
|
17
|
+
super(), c(this), this.theme = h();
|
|
18
|
+
}
|
|
16
19
|
connectedCallback() {
|
|
17
|
-
|
|
20
|
+
this.loadStyleText(u), super.connectedCallback(), this.#c();
|
|
18
21
|
}
|
|
19
22
|
disconnectedCallback() {
|
|
20
|
-
super.disconnectedCallback(), this.#
|
|
23
|
+
super.disconnectedCallback(), this.#r();
|
|
21
24
|
}
|
|
22
25
|
render() {
|
|
23
26
|
switch (this.type) {
|
|
@@ -75,12 +78,12 @@ class k extends l {
|
|
|
75
78
|
const n = t.target.value;
|
|
76
79
|
this.type !== "switch" ? e = n : e = n ? "dark" : "light";
|
|
77
80
|
}
|
|
78
|
-
await
|
|
81
|
+
await a(e), this.theme = e, this.type === "button" && this.#n(this.#t), this.dispatchEvent(new CustomEvent("change", { detail: e }));
|
|
79
82
|
};
|
|
80
|
-
#h() {
|
|
81
|
-
this.#t = c(".l-theme-inner", this.root), this.type === "button" ? o(this.#t, "click", this.#e) : o(this.#t, "change", this.#e);
|
|
82
|
-
}
|
|
83
83
|
#c() {
|
|
84
|
+
this.#t = r(".l-theme-inner", this.root), this.type === "button" ? o(this.#t, "click", this.#e) : o(this.#t, "change", this.#e);
|
|
85
|
+
}
|
|
86
|
+
#r() {
|
|
84
87
|
this.#t && (this.type === "button" ? s(this.#t, "click", this.#e) : s(this.#t, "change", this.#e), this.#t = void 0);
|
|
85
88
|
}
|
|
86
89
|
}
|