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