litos-ui 0.3.0 → 0.6.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 +3 -3
- package/lib/base.js +29 -27
- package/lib/browser.d.ts +7 -0
- package/lib/button/index.js +10 -11
- package/lib/color_picker/index.d.ts +13 -0
- package/lib/color_picker/index.js +44 -0
- package/lib/form/form_inner.js +26 -26
- package/lib/form/form_item.js +1 -1
- package/lib/form/index.js +1 -1
- package/lib/icon/arrow_left.d.ts +5 -0
- package/lib/icon/arrow_left.js +13 -0
- package/lib/icon/arrow_right.d.ts +5 -0
- package/lib/icon/arrow_right.js +13 -0
- package/lib/icon/arrow_up.d.ts +6 -0
- package/lib/icon/arrow_up.js +16 -0
- package/lib/icon/base.js +13 -13
- package/lib/icon/moon.d.ts +6 -0
- package/lib/icon/moon.js +16 -0
- package/lib/icon/reduction.d.ts +6 -0
- package/lib/icon/reduction.js +16 -0
- package/lib/icon/refresh_left.d.ts +6 -0
- package/lib/icon/refresh_left.js +16 -0
- package/lib/icon/refresh_right.d.ts +5 -0
- package/lib/icon/refresh_right.js +13 -0
- package/lib/icon/sort.d.ts +5 -0
- package/lib/icon/sort.js +13 -0
- package/lib/icon/sun.d.ts +6 -0
- package/lib/icon/sun.js +16 -0
- package/lib/icon/theme_default.d.ts +6 -0
- package/lib/icon/theme_default.js +16 -0
- package/lib/index-116dRdDj.js +4 -0
- package/lib/index-BUyxD_nH.js +4 -0
- package/lib/index-BeOxuMd4.js +4 -0
- package/lib/index-Bl8lRTJd.js +4 -0
- package/lib/index-BxlGVrX3.js +4 -0
- package/lib/index-C98Kx857.js +4 -0
- package/lib/index-CMz7GCCH.js +4 -0
- package/lib/index-DJ70Xyma.js +4 -0
- package/lib/index-DKvzJmsR.js +4 -0
- package/lib/index.d.ts +40 -1
- package/lib/index.js +82 -36
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +14 -14
- package/lib/list/index.js +1 -1
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/message/index.js +32 -32
- package/lib/polygon/index.d.ts +9 -0
- package/lib/polygon/index.js +30 -0
- package/lib/popover/index.d.ts +34 -0
- package/lib/popover/index.js +153 -0
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/index.js +61 -49
- package/lib/select_ori/index.d.ts +21 -0
- package/lib/select_ori/index.js +59 -0
- package/lib/switch/index.d.ts +18 -0
- package/lib/switch/index.js +64 -0
- package/lib/tabbar/index.d.ts +50 -0
- package/lib/tabbar/index.js +186 -0
- package/lib/theme/index.d.ts +12 -0
- package/lib/theme/index.js +95 -0
- package/lib/theme/theme_color.d.ts +9 -0
- package/lib/theme/theme_color.js +40 -0
- package/lib/utils/clickoutside.d.ts +5 -0
- package/lib/utils/clickoutside.js +22 -0
- package/lib/utils/event.js +24 -0
- package/lib/utils/index.d.ts +88 -0
- package/lib/utils/index.js +139 -0
- package/lib/utils/transition.js +58 -0
- package/package.json +69 -68
- package/styles/animation.css +13 -0
- package/styles/container.css +51 -0
- package/styles/scrollbar.css +23 -0
- package/styles/transition.css +33 -0
- package/lib/index-Boq1Q7q9.js +0 -4
- package/lib/index-ColsUDnt.js +0 -4
- package/lib/transition.d.ts +0 -15
- package/lib/transition.js +0 -52
- package/lib/util.d.ts +0 -40
- package/lib/util.js +0 -56
package/lib/radio/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { initAttr as
|
|
5
|
-
import
|
|
6
|
-
import { $one as
|
|
7
|
-
import { random as
|
|
8
|
-
class L extends
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var I = (c, n, e) => n in c ? A(c, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[n] = e;
|
|
3
|
+
var o = (c, n, e) => I(c, typeof n != "symbol" ? n + "" : n, e);
|
|
4
|
+
import { initAttr as y, tagAttr as h, parseAttrValue as N } from "../utils/index.js";
|
|
5
|
+
import V from "../form/form_inner.js";
|
|
6
|
+
import { $one as r, hasClass as f, addClass as u, $ as p, iterate as m, getAttr as S, removeClass as b, formatClass as j, on as D, off as H } from "ph-utils/dom";
|
|
7
|
+
import { random as v } from "ph-utils";
|
|
8
|
+
class L extends V {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(!1);
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
o(this, "type");
|
|
12
|
+
o(this, "label");
|
|
13
|
+
o(this, "checked", !1);
|
|
14
|
+
o(this, "_changeEvent");
|
|
15
|
+
o(this, "_radioChange", (e) => {
|
|
16
16
|
const a = e.target;
|
|
17
17
|
let t = a.parentElement;
|
|
18
|
-
for (; t != null && !
|
|
18
|
+
for (; t != null && !f(t, "l-radio"); )
|
|
19
19
|
t = t.parentElement;
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const s = r(".is-checked", this.root);
|
|
21
|
+
s && b(s, "is-checked"), this.value = a.value, t && u(t, "is-checked"), this.dispatchEvent(this._changeEvent);
|
|
22
22
|
});
|
|
23
|
-
|
|
23
|
+
y(this), this._changeEvent = new CustomEvent("change");
|
|
24
24
|
}
|
|
25
25
|
setItems(e) {
|
|
26
26
|
this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
|
|
@@ -33,19 +33,19 @@ class L extends N {
|
|
|
33
33
|
}
|
|
34
34
|
attributeChange(e, a, t) {
|
|
35
35
|
if (e === "checked") {
|
|
36
|
-
const
|
|
37
|
-
this.checked =
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
const l =
|
|
36
|
+
const s = N(t, !1, e);
|
|
37
|
+
this.checked = s, this.value = s;
|
|
38
|
+
const i = r(".l-radio", this.root);
|
|
39
|
+
if (i && !f(i, "is-checked")) {
|
|
40
|
+
u(i, "is-checked");
|
|
41
|
+
const l = r("input", i);
|
|
42
42
|
l && (l.checked = !0);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
render() {
|
|
47
|
-
this.getName() || (this.name = `la${
|
|
48
|
-
const e = [], a =
|
|
47
|
+
this.getName() || (this.name = `la${v(3)}_${v(6)}`);
|
|
48
|
+
const e = [], a = r('[slot="label"]', this), t = p("[radio-value]", this);
|
|
49
49
|
a != null || this.label ? (this.value = this._isChecked(), a ? e.push(
|
|
50
50
|
this._renderItem("slot", void 0, this._isChecked(), "label")
|
|
51
51
|
) : e.push(
|
|
@@ -55,59 +55,71 @@ class L extends N {
|
|
|
55
55
|
this._isChecked(),
|
|
56
56
|
"label"
|
|
57
57
|
)
|
|
58
|
-
)) : t.length > 0 && (m(t, (
|
|
59
|
-
const
|
|
58
|
+
)) : t.length > 0 && (m(t, (s) => {
|
|
59
|
+
const i = s.cloneNode(!0), l = S(s, "radio-value");
|
|
60
60
|
e.push(
|
|
61
|
-
this._renderItem(
|
|
61
|
+
this._renderItem(i.outerHTML, l, this.value === l)
|
|
62
62
|
);
|
|
63
63
|
}), this.pushValueChange()), this.root.innerHTML = e.join("");
|
|
64
64
|
}
|
|
65
|
+
setValue(e) {
|
|
66
|
+
super.setValue(e);
|
|
67
|
+
let a = "";
|
|
68
|
+
typeof e != "boolean" && (a = `[l-value="${e}"]`);
|
|
69
|
+
const t = r(".is-checked", this.root);
|
|
70
|
+
t && b(t, "is-checked");
|
|
71
|
+
const s = r(`label${a}`, this.root);
|
|
72
|
+
if (s) {
|
|
73
|
+
const i = r("input", s);
|
|
74
|
+
typeof e == "boolean" ? (e ? u(s, "is-checked") : b(s, "is-checked"), i.checked = e) : (u(s, "is-checked"), i.checked = !0);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
65
77
|
_renderItems(e) {
|
|
66
78
|
const a = [];
|
|
67
|
-
for (let t = 0,
|
|
68
|
-
const
|
|
79
|
+
for (let t = 0, s = e.length; t < s; t++) {
|
|
80
|
+
const i = e[t];
|
|
69
81
|
a.push(
|
|
70
82
|
this._renderItem(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
this.value ===
|
|
74
|
-
|
|
83
|
+
i.label,
|
|
84
|
+
i.value,
|
|
85
|
+
this.value === i.value,
|
|
86
|
+
i.labelPart
|
|
75
87
|
)
|
|
76
88
|
);
|
|
77
89
|
}
|
|
78
90
|
return a.join("");
|
|
79
91
|
}
|
|
80
|
-
_renderItem(e, a, t = !1,
|
|
81
|
-
const
|
|
92
|
+
_renderItem(e, a, t = !1, s = void 0) {
|
|
93
|
+
const i = j({
|
|
82
94
|
"l-radio": !0,
|
|
83
95
|
"l-radio--disabled": this.isDisabled(),
|
|
84
96
|
"l-radio--button": this.type === "button",
|
|
85
97
|
"is-checked": t
|
|
86
|
-
}), l = h("disabled", this.isDisabled()), _ = h("checked", t),
|
|
87
|
-
`<label class="${
|
|
88
|
-
`<input type="radio" class="l-radio__input"${
|
|
98
|
+
}), l = h("disabled", this.isDisabled()), _ = h("checked", t), k = h("value", a), $ = `${h("name", this.getName())}${k}${l}${_}`, g = h("part", s), C = h("l-value", a), d = [
|
|
99
|
+
`<label class="${i}"${C}>`,
|
|
100
|
+
`<input type="radio" class="l-radio__input"${$} />`
|
|
89
101
|
];
|
|
90
|
-
this.type !== "button" &&
|
|
91
|
-
let
|
|
92
|
-
return
|
|
93
|
-
`<div class="l-radio__label"${
|
|
94
|
-
),
|
|
102
|
+
this.type !== "button" && d.push('<span class="l-radio__inner"></span>');
|
|
103
|
+
let E = e === "slot" ? '<slot name="label"></slot>' : e;
|
|
104
|
+
return d.push(
|
|
105
|
+
`<div class="l-radio__label"${g}>${E}</div>`
|
|
106
|
+
), d.push("</label>"), d.join("");
|
|
95
107
|
}
|
|
96
108
|
_isChecked() {
|
|
97
109
|
return this.checked;
|
|
98
110
|
}
|
|
99
111
|
_initEvents() {
|
|
100
|
-
m(
|
|
101
|
-
|
|
112
|
+
m(p("input", this.root), (e) => {
|
|
113
|
+
D(e, "change", this._radioChange);
|
|
102
114
|
});
|
|
103
115
|
}
|
|
104
116
|
_removeEvents() {
|
|
105
|
-
m(
|
|
106
|
-
|
|
117
|
+
m(p("input", this.root), (e) => {
|
|
118
|
+
H(e, "change", this._radioChange);
|
|
107
119
|
});
|
|
108
120
|
}
|
|
109
121
|
}
|
|
110
|
-
|
|
122
|
+
o(L, "baseName", "radio");
|
|
111
123
|
export {
|
|
112
124
|
L as default
|
|
113
125
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
type Option = {
|
|
3
|
+
label: string;
|
|
4
|
+
value: string;
|
|
5
|
+
};
|
|
6
|
+
export default class SelectOri extends FormInner {
|
|
7
|
+
static baseName: string;
|
|
8
|
+
private $select?;
|
|
9
|
+
private changeEmit;
|
|
10
|
+
constructor();
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
render(): void;
|
|
14
|
+
protected _changeDisabled(): void;
|
|
15
|
+
setOptions(options: Option[]): void;
|
|
16
|
+
appendOptions(options: Option[]): void;
|
|
17
|
+
reset(): void;
|
|
18
|
+
setValue(value: any): void;
|
|
19
|
+
private _handleChange;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var r = Object.defineProperty;
|
|
2
|
+
var o = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var n = (i, t, e) => o(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import u from "../form/form_inner.js";
|
|
5
|
+
import { initAttr as d, tagAttrs as p } from "../utils/index.js";
|
|
6
|
+
import { $one as $, on as m, off as g } from "ph-utils/dom";
|
|
7
|
+
class v extends u {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
n(this, "$select");
|
|
11
|
+
n(this, "changeEmit");
|
|
12
|
+
n(this, "_handleChange", (e) => {
|
|
13
|
+
const s = e.target.value;
|
|
14
|
+
super.setValue(s), this.dispatchEvent(this.changeEmit);
|
|
15
|
+
});
|
|
16
|
+
d(this), this.changeEmit = new CustomEvent("change");
|
|
17
|
+
}
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
this.loadStyle(["input"]), super.connectedCallback(), this.$select = $("select", this.root), this.value && (this.$select.value = this.value), m(this.$select, "change", this._handleChange);
|
|
20
|
+
}
|
|
21
|
+
disconnectedCallback() {
|
|
22
|
+
super.disconnectedCallback(), this.$select && g(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
let e = this.innerHTML.trim();
|
|
26
|
+
const s = p([
|
|
27
|
+
["name", this.getName()],
|
|
28
|
+
["disabled", this.isDisabled()]
|
|
29
|
+
]);
|
|
30
|
+
this.root.innerHTML = `<select class="l-input"${s}>${e}</select>`;
|
|
31
|
+
}
|
|
32
|
+
_changeDisabled() {
|
|
33
|
+
this.$select && (this.$select.disabled = this.isDisabled());
|
|
34
|
+
}
|
|
35
|
+
setOptions(e) {
|
|
36
|
+
if (!this.$select) return;
|
|
37
|
+
const s = e.map((l) => `<option value="${l.value}">${l.label}</option>`);
|
|
38
|
+
this.$select.innerHTML = s.join("");
|
|
39
|
+
}
|
|
40
|
+
appendOptions(e) {
|
|
41
|
+
if (!this.$select) return;
|
|
42
|
+
const s = document.createDocumentFragment();
|
|
43
|
+
for (let l = 0, h = e.length; l < h; l++) {
|
|
44
|
+
const c = e[l], a = document.createElement("option");
|
|
45
|
+
a.value = c.value, a.innerHTML = c.label, s.appendChild(a);
|
|
46
|
+
}
|
|
47
|
+
this.$select.appendChild(s);
|
|
48
|
+
}
|
|
49
|
+
reset() {
|
|
50
|
+
super.reset(), this.$select && (this.$select.value = this.value);
|
|
51
|
+
}
|
|
52
|
+
setValue(e) {
|
|
53
|
+
super.setValue(e), this.$select && (this.$select.value = this.value);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
n(v, "baseName", "select-ori");
|
|
57
|
+
export {
|
|
58
|
+
v as default
|
|
59
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
type ActionRenderFn = (cfg: {
|
|
3
|
+
checked: boolean;
|
|
4
|
+
}) => string | HTMLElement;
|
|
5
|
+
export default class Switch extends FormInner {
|
|
6
|
+
#private;
|
|
7
|
+
static baseName: string;
|
|
8
|
+
actionRender?: ActionRenderFn;
|
|
9
|
+
checkedText?: string;
|
|
10
|
+
uncheckedText?: string;
|
|
11
|
+
constructor();
|
|
12
|
+
connectedCallback(): void;
|
|
13
|
+
disconnectedCallback(): void;
|
|
14
|
+
render(): string;
|
|
15
|
+
setValue(value: boolean): void;
|
|
16
|
+
setActionRender(render: ActionRenderFn): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var p = Object.defineProperty;
|
|
2
|
+
var u = (t) => {
|
|
3
|
+
throw TypeError(t);
|
|
4
|
+
};
|
|
5
|
+
var v = (t, s, e) => s in t ? p(t, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[s] = e;
|
|
6
|
+
var n = (t, s, e) => v(t, typeof s != "symbol" ? s + "" : s, e), k = (t, s, e) => s.has(t) || u("Cannot " + e);
|
|
7
|
+
var d = (t, s, e) => (k(t, s, "read from private field"), e ? e.call(t) : s.get(t)), r = (t, s, e) => s.has(t) ? u("Cannot add the same private member more than once") : s instanceof WeakSet ? s.add(t) : s.set(t, e);
|
|
8
|
+
var a = (t, s, e) => (k(t, s, "access private method"), e);
|
|
9
|
+
import { on as x, off as T, addClass as m, removeClass as w, $one as l } from "ph-utils/dom";
|
|
10
|
+
import C from "../form/form_inner.js";
|
|
11
|
+
import { initAttr as b, parseAttrValue as L } from "../utils/index.js";
|
|
12
|
+
var h, c, o;
|
|
13
|
+
class V extends C {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(!1);
|
|
16
|
+
r(this, c);
|
|
17
|
+
n(this, "actionRender");
|
|
18
|
+
n(this, "checkedText");
|
|
19
|
+
n(this, "uncheckedText");
|
|
20
|
+
r(this, h, (e) => {
|
|
21
|
+
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
22
|
+
});
|
|
23
|
+
b(this);
|
|
24
|
+
const e = this.value ? L(this.value, !1, "value") : !1;
|
|
25
|
+
this._resetValue = e, this.value = e;
|
|
26
|
+
}
|
|
27
|
+
connectedCallback() {
|
|
28
|
+
this.loadStyle(["switch"]), super.connectedCallback(), this.pushValueChange(), a(this, c, o).call(this), x(this, "click", d(this, h));
|
|
29
|
+
}
|
|
30
|
+
disconnectedCallback() {
|
|
31
|
+
super.disconnectedCallback(), T(this, "click", d(this, h)), this.actionRender = void 0;
|
|
32
|
+
}
|
|
33
|
+
render() {
|
|
34
|
+
this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
|
|
35
|
+
const e = ['<div class="l-switch-action" part="action"></div>'];
|
|
36
|
+
if (this.checkedText || this.uncheckedText) {
|
|
37
|
+
const i = this.value ? this.checkedText || "" : this.uncheckedText || "";
|
|
38
|
+
e.push(`<span class="l-switch-text">${i}</span>`);
|
|
39
|
+
}
|
|
40
|
+
return e.join("");
|
|
41
|
+
}
|
|
42
|
+
setValue(e) {
|
|
43
|
+
super.setValue(e), e ? m(this, "l-switch--checked") : w(this, "l-switch--checked");
|
|
44
|
+
const i = l(".l-switch-text", this.root);
|
|
45
|
+
i && (i.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), a(this, c, o).call(this);
|
|
46
|
+
}
|
|
47
|
+
setActionRender(e) {
|
|
48
|
+
this.actionRender = e, a(this, c, o).call(this);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
h = new WeakMap(), c = new WeakSet(), o = function() {
|
|
52
|
+
const e = l(".l-switch-action", this.root);
|
|
53
|
+
if (e)
|
|
54
|
+
if (this.actionRender) {
|
|
55
|
+
const i = this.actionRender({ checked: this.value });
|
|
56
|
+
typeof i == "string" ? e.innerHTML = i : e.innerHTML = i.outerHTML;
|
|
57
|
+
} else {
|
|
58
|
+
const i = l('[slot="checked-action"]', this), f = l('[slot="unchecked-action"]', this);
|
|
59
|
+
this.value && i ? e.innerHTML = '<slot name="checked-action"></slot>' : !this.value && f && (e.innerHTML = '<slot name="unchecked-action"></slot>');
|
|
60
|
+
}
|
|
61
|
+
}, n(V, "baseName", "switch");
|
|
62
|
+
export {
|
|
63
|
+
V as default
|
|
64
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
type TabbarItem = {
|
|
3
|
+
name: string;
|
|
4
|
+
text?: string | (() => string | HTMLElement);
|
|
5
|
+
icon?: string | (() => string | HTMLElement);
|
|
6
|
+
};
|
|
7
|
+
export declare function shouldEventNext(e: Event, eventFlag: string, endRoot?: HTMLElement | ShadowRoot): [boolean, string, HTMLElement];
|
|
8
|
+
export default class Tabbar extends BaseComponent {
|
|
9
|
+
#private;
|
|
10
|
+
static baseName: string;
|
|
11
|
+
/**
|
|
12
|
+
* 标签类型:
|
|
13
|
+
* 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
|
|
14
|
+
* 2. bar - 选项卡
|
|
15
|
+
* 3. card - 卡片
|
|
16
|
+
*/
|
|
17
|
+
type: "nav" | "bar" | "card";
|
|
18
|
+
name?: string;
|
|
19
|
+
justifyContent?: string;
|
|
20
|
+
gap?: string;
|
|
21
|
+
private $line?;
|
|
22
|
+
constructor();
|
|
23
|
+
connectedCallback(): void;
|
|
24
|
+
static get observedAttributes(): string[] | null | undefined;
|
|
25
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
26
|
+
disconnectedCallback(): void;
|
|
27
|
+
render(): any;
|
|
28
|
+
/**
|
|
29
|
+
* 设置选项卡栏的项目列表。
|
|
30
|
+
* @param items - 选项卡栏项目的数组。
|
|
31
|
+
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
32
|
+
*/
|
|
33
|
+
setItems(items: TabbarItem[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* 向标签栏添加项目。
|
|
36
|
+
* @param items 要添加的标签栏项目数组。
|
|
37
|
+
* @returns 无返回值。
|
|
38
|
+
*/
|
|
39
|
+
addItems(items: TabbarItem[]): void;
|
|
40
|
+
private _init;
|
|
41
|
+
private _destroy;
|
|
42
|
+
private _handleClick;
|
|
43
|
+
private _updateActive;
|
|
44
|
+
/**
|
|
45
|
+
* 初始化线条的方法,在微任务队列中执行。
|
|
46
|
+
* 该方法用于设置或更新标签栏中的线条位置或样式。
|
|
47
|
+
*/
|
|
48
|
+
private _updateLine;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
var A = Object.defineProperty;
|
|
2
|
+
var k = (s) => {
|
|
3
|
+
throw TypeError(s);
|
|
4
|
+
};
|
|
5
|
+
var N = (s, a, t) => a in s ? A(s, a, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[a] = t;
|
|
6
|
+
var p = (s, a, t) => N(s, typeof a != "symbol" ? a + "" : a, t), w = (s, a, t) => a.has(s) || k("Cannot " + t);
|
|
7
|
+
var x = (s, a, t) => a.has(s) ? k("Cannot add the same private member more than once") : a instanceof WeakSet ? a.add(s) : a.set(s, t);
|
|
8
|
+
var m = (s, a, t) => (w(s, a, "access private method"), t);
|
|
9
|
+
import { isBlank as u, isNumeric as T } from "ph-utils";
|
|
10
|
+
import W from "../base.js";
|
|
11
|
+
import { initAttr as j, parseAttrValue as C } from "../utils/index.js";
|
|
12
|
+
import { addClass as g, removeClass as v, $one as c, create as b, $ as L, iterate as E, on as S, off as B, isVisible as D, formatStyle as I, formatClass as M } from "ph-utils/dom";
|
|
13
|
+
function R(s, a, t) {
|
|
14
|
+
let e = s.target, i = "";
|
|
15
|
+
do
|
|
16
|
+
if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (i = e.getAttribute(a) || ""), i === "" && (e = e.parentNode), !e)) break;
|
|
17
|
+
while (i === "");
|
|
18
|
+
return [i !== "__stop__" && i !== "", i, e];
|
|
19
|
+
}
|
|
20
|
+
var h, y, _;
|
|
21
|
+
class F extends W {
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
x(this, h);
|
|
25
|
+
/**
|
|
26
|
+
* 标签类型:
|
|
27
|
+
* 1. nav - 每一项等分排列, 类似于移动端底部的标签栏
|
|
28
|
+
* 2. bar - 选项卡
|
|
29
|
+
* 3. card - 卡片
|
|
30
|
+
*/
|
|
31
|
+
p(this, "type", "nav");
|
|
32
|
+
p(this, "name");
|
|
33
|
+
p(this, "justifyContent");
|
|
34
|
+
p(this, "gap");
|
|
35
|
+
p(this, "$line");
|
|
36
|
+
p(this, "_handleClick", (t) => {
|
|
37
|
+
const [e, i] = R(t, "l-name", this.root);
|
|
38
|
+
e && i !== this.name && (this.name = i, this.dispatchEvent(
|
|
39
|
+
new CustomEvent("change", {
|
|
40
|
+
detail: {
|
|
41
|
+
name: i
|
|
42
|
+
}
|
|
43
|
+
})
|
|
44
|
+
), this._updateActive(), this._updateLine());
|
|
45
|
+
});
|
|
46
|
+
j(this), this.root;
|
|
47
|
+
}
|
|
48
|
+
connectedCallback() {
|
|
49
|
+
this.loadStyle(["tabbar"]), g(this, `l-tabbar--${this.type}`), !u(this.gap) && !this.gap.startsWith("0") && g(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
|
|
50
|
+
}
|
|
51
|
+
static get observedAttributes() {
|
|
52
|
+
return ["name", "type", "justify-content", "gap"];
|
|
53
|
+
}
|
|
54
|
+
attributeChangedCallback(t, e, i) {
|
|
55
|
+
if (t === "name") {
|
|
56
|
+
const r = C(i, void 0);
|
|
57
|
+
this.name = r, this._updateActive(), this._updateLine();
|
|
58
|
+
} else if (t === "type") {
|
|
59
|
+
const r = C(i, "nav");
|
|
60
|
+
if (r !== this.type && (v(this, `l-tabbar--${this.type}`), this.type = r, v(this, `l-tabbar--${r}`), r === "card")) {
|
|
61
|
+
let n = c(".l-tabbar-card-border", this.root);
|
|
62
|
+
n || (n = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(n));
|
|
63
|
+
}
|
|
64
|
+
} else {
|
|
65
|
+
const r = C(i, void 0);
|
|
66
|
+
this[t] = r;
|
|
67
|
+
const n = c(".l-tabbar-wrapper", this.root);
|
|
68
|
+
n && (n.style.cssText = m(this, h, y).call(this)), t === "gap" && (!u(this.gap) && !this.gap.startsWith("0") ? g(this, "l-tabbar-gap") : v(this, "l-tabbar-gap"));
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
disconnectedCallback() {
|
|
72
|
+
super.disconnectedCallback(), this._destroy();
|
|
73
|
+
}
|
|
74
|
+
render() {
|
|
75
|
+
const t = L("[l-name]", this), e = document.createDocumentFragment(), i = document.createElement("div");
|
|
76
|
+
if (i.className = "l-tabbar-wrapper", i.style.cssText = m(this, h, y).call(this), i.setAttribute("part", "default"), t.length > 0 && E(t, (r) => {
|
|
77
|
+
const n = r.getAttribute("l-name");
|
|
78
|
+
if (n) {
|
|
79
|
+
const o = r.cloneNode(!0);
|
|
80
|
+
o.classList.add("l-tabbar-item"), n === this.name && o.classList.add("active");
|
|
81
|
+
const d = c("[l-icon]", o), f = L(":not([l-icon])", o);
|
|
82
|
+
if (d) {
|
|
83
|
+
const l = b("div", {
|
|
84
|
+
class: [
|
|
85
|
+
"l-tabbar-item-icon",
|
|
86
|
+
f.length === 0 ? "only" : void 0
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
l.appendChild(d.cloneNode(!0)), d.replaceWith(l);
|
|
90
|
+
}
|
|
91
|
+
i.appendChild(o);
|
|
92
|
+
}
|
|
93
|
+
}), e.appendChild(i), this.type === "card") {
|
|
94
|
+
const r = b("div", { class: "l-tabbar-card-border" });
|
|
95
|
+
e.appendChild(r);
|
|
96
|
+
}
|
|
97
|
+
return e;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 设置选项卡栏的项目列表。
|
|
101
|
+
* @param items - 选项卡栏项目的数组。
|
|
102
|
+
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
103
|
+
*/
|
|
104
|
+
setItems(t) {
|
|
105
|
+
const e = c(".l-tabbar-wrapper", this.root);
|
|
106
|
+
e && (e.innerHTML = "", e.appendChild(m(this, h, _).call(this, t)));
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* 向标签栏添加项目。
|
|
110
|
+
* @param items 要添加的标签栏项目数组。
|
|
111
|
+
* @returns 无返回值。
|
|
112
|
+
*/
|
|
113
|
+
addItems(t) {
|
|
114
|
+
const e = c(".l-tabbar-wrapper", this.root);
|
|
115
|
+
e && e.appendChild(m(this, h, _).call(this, t));
|
|
116
|
+
}
|
|
117
|
+
_init() {
|
|
118
|
+
S(this.root, "click", this._handleClick), setTimeout(() => {
|
|
119
|
+
this._updateLine();
|
|
120
|
+
}, 300);
|
|
121
|
+
}
|
|
122
|
+
_destroy() {
|
|
123
|
+
B(this.root, "click", this._handleClick), this.$line = void 0;
|
|
124
|
+
}
|
|
125
|
+
_updateActive() {
|
|
126
|
+
const t = c(".active", this.root);
|
|
127
|
+
t && v(t, "active");
|
|
128
|
+
const e = c(`[l-name="${this.name}"]`, this.root);
|
|
129
|
+
e && g(e, "active");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* 初始化线条的方法,在微任务队列中执行。
|
|
133
|
+
* 该方法用于设置或更新标签栏中的线条位置或样式。
|
|
134
|
+
*/
|
|
135
|
+
_updateLine() {
|
|
136
|
+
queueMicrotask(() => {
|
|
137
|
+
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
138
|
+
const t = c(".active", this.root);
|
|
139
|
+
if (!t) return;
|
|
140
|
+
const e = t.offsetLeft;
|
|
141
|
+
if (!this.$line) {
|
|
142
|
+
const i = b("div", { class: "l-tabbar--bar-line" });
|
|
143
|
+
this.root.appendChild(i), this.$line = c(".l-tabbar--bar-line", this.root);
|
|
144
|
+
}
|
|
145
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, D(t, this) || this.scrollTo({
|
|
146
|
+
left: e,
|
|
147
|
+
behavior: "smooth"
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
h = new WeakSet(), y = function() {
|
|
153
|
+
const t = {};
|
|
154
|
+
if (u(this.justifyContent) || (t["justify-content"] = this.justifyContent), !u(this.gap)) {
|
|
155
|
+
let e = this.gap;
|
|
156
|
+
T(e, { isPositive: !0 }) && (e = `${e}px`), t["--l-tabbar-item-gap"] = e;
|
|
157
|
+
}
|
|
158
|
+
return I(t);
|
|
159
|
+
}, _ = function(t) {
|
|
160
|
+
const e = document.createDocumentFragment();
|
|
161
|
+
for (let i = 0, r = t.length; i < r; i++) {
|
|
162
|
+
const n = t[i], o = b("div", {
|
|
163
|
+
class: M([
|
|
164
|
+
"l-tabbar-item",
|
|
165
|
+
this.name === n.name ? "active" : void 0
|
|
166
|
+
]),
|
|
167
|
+
"l-name": n.name
|
|
168
|
+
}), d = n.icon;
|
|
169
|
+
if (d) {
|
|
170
|
+
const l = b("div", { class: "l-tabbar-item-icon" });
|
|
171
|
+
let $ = typeof d == "string" ? d : d();
|
|
172
|
+
typeof $ == "string" ? l.innerHTML = $ : l.appendChild($), o.appendChild(l);
|
|
173
|
+
}
|
|
174
|
+
const f = n.text;
|
|
175
|
+
if (f) {
|
|
176
|
+
let l = typeof f == "string" ? f : f();
|
|
177
|
+
typeof l == "string" ? o.appendChild(b(l)) : o.appendChild(l);
|
|
178
|
+
}
|
|
179
|
+
e.appendChild(o);
|
|
180
|
+
}
|
|
181
|
+
return e;
|
|
182
|
+
}, p(F, "baseName", "tabbar");
|
|
183
|
+
export {
|
|
184
|
+
F as default,
|
|
185
|
+
R as shouldEventNext
|
|
186
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Theme extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
type: "button" | "select" | "switch" | "radio";
|
|
6
|
+
label?: "text" | "icon";
|
|
7
|
+
theme: string;
|
|
8
|
+
constructor();
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
disconnectedCallback(): void;
|
|
11
|
+
render(): any;
|
|
12
|
+
}
|