litos-ui 0.4.0 → 0.6.1
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 +2 -2
- package/lib/base.js +2 -1
- package/lib/browser.d.ts +2 -0
- package/lib/button/index.js +26 -25
- package/lib/color_picker/index.d.ts +0 -1
- package/lib/color_picker/index.js +15 -15
- package/lib/form/form_inner.js +25 -25
- 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/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-1Gw78Uze.js → index-Bl8lRTJd.js} +1 -1
- package/lib/index-DJ70Xyma.js +4 -0
- package/lib/index.d.ts +18 -1
- package/lib/index.js +82 -60
- 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 +27 -27
- package/lib/polygon/index.js +1 -1
- 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.js +1 -1
- package/lib/switch/index.d.ts +2 -5
- package/lib/switch/index.js +45 -48
- package/lib/tabbar/index.js +1 -1
- 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/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/event.d.ts +0 -30
- package/lib/index-CPpMuwU3.js +0 -4
- package/lib/transition.d.ts +0 -15
- package/lib/transition.js +0 -52
- package/lib/util.d.ts +0 -42
- package/lib/util.js +0 -67
- /package/lib/{event.js → utils/event.js} +0 -0
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
|
};
|
package/lib/select_ori/index.js
CHANGED
|
@@ -2,7 +2,7 @@ var r = Object.defineProperty;
|
|
|
2
2
|
var o = (i, t, e) => t in i ? r(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
3
|
var n = (i, t, e) => o(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import u from "../form/form_inner.js";
|
|
5
|
-
import { initAttr as d, tagAttrs as p } from "../
|
|
5
|
+
import { initAttr as d, tagAttrs as p } from "../utils/index.js";
|
|
6
6
|
import { $one as $, on as m, off as g } from "ph-utils/dom";
|
|
7
7
|
class v extends u {
|
|
8
8
|
constructor() {
|
package/lib/switch/index.d.ts
CHANGED
|
@@ -3,19 +3,16 @@ type ActionRenderFn = (cfg: {
|
|
|
3
3
|
checked: boolean;
|
|
4
4
|
}) => string | HTMLElement;
|
|
5
5
|
export default class Switch extends FormInner {
|
|
6
|
+
#private;
|
|
6
7
|
static baseName: string;
|
|
7
8
|
actionRender?: ActionRenderFn;
|
|
8
9
|
checkedText?: string;
|
|
9
10
|
uncheckedText?: string;
|
|
10
|
-
private _changeEmit;
|
|
11
|
-
private _$root?;
|
|
12
11
|
constructor();
|
|
13
12
|
connectedCallback(): void;
|
|
14
13
|
disconnectedCallback(): void;
|
|
15
|
-
render():
|
|
16
|
-
private _handleClick;
|
|
14
|
+
render(): string;
|
|
17
15
|
setValue(value: boolean): void;
|
|
18
16
|
setActionRender(render: ActionRenderFn): void;
|
|
19
|
-
private _renderAction;
|
|
20
17
|
}
|
|
21
18
|
export {};
|
package/lib/switch/index.js
CHANGED
|
@@ -1,67 +1,64 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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 {
|
|
8
14
|
constructor() {
|
|
9
15
|
super(!1);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(this._changeEmit));
|
|
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")));
|
|
17
22
|
});
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
this._resetValue =
|
|
23
|
+
b(this);
|
|
24
|
+
const e = this.value ? L(this.value, !1, "value") : !1;
|
|
25
|
+
this._resetValue = e, this.value = e;
|
|
21
26
|
}
|
|
22
27
|
connectedCallback() {
|
|
23
|
-
this.loadStyle(["switch"]), super.connectedCallback(), this.pushValueChange(), this
|
|
28
|
+
this.loadStyle(["switch"]), super.connectedCallback(), this.pushValueChange(), a(this, c, o).call(this), x(this, "click", d(this, h));
|
|
24
29
|
}
|
|
25
30
|
disconnectedCallback() {
|
|
26
|
-
super.disconnectedCallback(),
|
|
31
|
+
super.disconnectedCallback(), T(this, "click", d(this, h)), this.actionRender = void 0;
|
|
27
32
|
}
|
|
28
33
|
render() {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"l-switch": !0,
|
|
32
|
-
"l-switch--disabled": this.isDisabled(),
|
|
33
|
-
"l-switch--checked": this.value
|
|
34
|
-
});
|
|
35
|
-
const e = ['<div class="l-switch-action"></div>'];
|
|
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
36
|
if (this.checkedText || this.uncheckedText) {
|
|
37
|
-
const
|
|
38
|
-
e.push(`<span class="l-switch-text">${
|
|
37
|
+
const i = this.value ? this.checkedText || "" : this.uncheckedText || "";
|
|
38
|
+
e.push(`<span class="l-switch-text">${i}</span>`);
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return e.join("");
|
|
41
41
|
}
|
|
42
|
-
setValue(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this._renderAction();
|
|
47
|
-
}
|
|
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);
|
|
48
46
|
}
|
|
49
|
-
setActionRender(
|
|
50
|
-
this.actionRender =
|
|
47
|
+
setActionRender(e) {
|
|
48
|
+
this.actionRender = e, a(this, c, o).call(this);
|
|
51
49
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
50
|
+
}
|
|
51
|
+
h = new WeakMap(), c = new WeakSet(), o = function() {
|
|
52
|
+
const e = l(".l-switch-action", this.root);
|
|
53
|
+
if (e)
|
|
55
54
|
if (this.actionRender) {
|
|
56
|
-
const
|
|
57
|
-
typeof
|
|
55
|
+
const i = this.actionRender({ checked: this.value });
|
|
56
|
+
typeof i == "string" ? e.innerHTML = i : e.innerHTML = i.outerHTML;
|
|
58
57
|
} else {
|
|
59
|
-
const
|
|
60
|
-
this.value &&
|
|
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>');
|
|
61
60
|
}
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
s(m, "baseName", "switch");
|
|
61
|
+
}, n(V, "baseName", "switch");
|
|
65
62
|
export {
|
|
66
|
-
|
|
63
|
+
V as default
|
|
67
64
|
};
|
package/lib/tabbar/index.js
CHANGED
|
@@ -8,7 +8,7 @@ var x = (s, a, t) => a.has(s) ? k("Cannot add the same private member more than
|
|
|
8
8
|
var m = (s, a, t) => (w(s, a, "access private method"), t);
|
|
9
9
|
import { isBlank as u, isNumeric as T } from "ph-utils";
|
|
10
10
|
import W from "../base.js";
|
|
11
|
-
import { initAttr as j, parseAttrValue as C } from "../
|
|
11
|
+
import { initAttr as j, parseAttrValue as C } from "../utils/index.js";
|
|
12
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
13
|
function R(s, a, t) {
|
|
14
14
|
let e = s.target, i = "";
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var C = Object.defineProperty;
|
|
2
|
+
var b = (e) => {
|
|
3
|
+
throw TypeError(e);
|
|
4
|
+
};
|
|
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 r = (e, n, t) => E(e, typeof n != "symbol" ? n + "" : n, t), m = (e, n, t) => n.has(e) || b("Cannot " + t);
|
|
7
|
+
var o = (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, s) => (m(e, n, "write to private field"), s ? s.call(e, t) : n.set(e, t), t), h = (e, n, t) => (m(e, n, "access private method"), t);
|
|
8
|
+
import M from "../base.js";
|
|
9
|
+
import { initAttr as R } from "../utils/index.js";
|
|
10
|
+
import { create as d, $one as H, on as f, off as k } from "ph-utils/dom";
|
|
11
|
+
import { getTheme as L, applyTheme as j } from "ph-utils/theme";
|
|
12
|
+
const A = [
|
|
13
|
+
{ value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
|
|
14
|
+
{ value: "light", text: "浅色模式", icon: "l-sun-icon" },
|
|
15
|
+
{ value: "dark", text: "深色模式", icon: "l-moon-icon" }
|
|
16
|
+
];
|
|
17
|
+
var l, i, $, v, y, g, w, c, T, x;
|
|
18
|
+
class B extends M {
|
|
19
|
+
constructor() {
|
|
20
|
+
super();
|
|
21
|
+
u(this, i);
|
|
22
|
+
r(this, "type", "button");
|
|
23
|
+
r(this, "label", "text");
|
|
24
|
+
r(this, "theme");
|
|
25
|
+
u(this, l);
|
|
26
|
+
u(this, c, async (t) => {
|
|
27
|
+
let s;
|
|
28
|
+
if (this.type === "button")
|
|
29
|
+
s = this.theme === "dark" ? "auto" : "dark";
|
|
30
|
+
else {
|
|
31
|
+
const a = t.target.value;
|
|
32
|
+
this.type !== "switch" ? s = a : s = a ? "dark" : "light";
|
|
33
|
+
}
|
|
34
|
+
await j(s), this.theme = s, this.type === "button" && h(this, i, v).call(this, o(this, l)), this.dispatchEvent(new CustomEvent("change", { detail: s }));
|
|
35
|
+
});
|
|
36
|
+
R(this), this.theme = L();
|
|
37
|
+
}
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
this.loadStyle(["theme"]), super.connectedCallback(), h(this, i, T).call(this);
|
|
40
|
+
}
|
|
41
|
+
disconnectedCallback() {
|
|
42
|
+
super.disconnectedCallback(), h(this, i, x).call(this);
|
|
43
|
+
}
|
|
44
|
+
render() {
|
|
45
|
+
switch (this.type) {
|
|
46
|
+
case "select":
|
|
47
|
+
return h(this, i, y).call(this);
|
|
48
|
+
case "radio":
|
|
49
|
+
return h(this, i, w).call(this);
|
|
50
|
+
case "switch":
|
|
51
|
+
return h(this, i, g).call(this);
|
|
52
|
+
default:
|
|
53
|
+
return h(this, i, $).call(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
l = new WeakMap(), i = new WeakSet(), $ = function() {
|
|
58
|
+
const t = d("l-button", {
|
|
59
|
+
class: "l-theme-btn l-theme-inner"
|
|
60
|
+
});
|
|
61
|
+
return h(this, i, v).call(this, t), t;
|
|
62
|
+
}, v = function(t) {
|
|
63
|
+
const s = this.theme === "auto" ? "sun" : "moon";
|
|
64
|
+
t.innerHTML = `<l-${s}-icon></l-${s}-icon>`;
|
|
65
|
+
}, y = function() {
|
|
66
|
+
const t = d("l-select-ori", {
|
|
67
|
+
class: "l-theme-inner"
|
|
68
|
+
});
|
|
69
|
+
t.value = this.theme;
|
|
70
|
+
const s = [
|
|
71
|
+
'<option value="auto">跟随系统</option>',
|
|
72
|
+
'<option value="light">浅色模式</option>',
|
|
73
|
+
'<option value="dark">深色模式</option>'
|
|
74
|
+
];
|
|
75
|
+
return t.innerHTML = s.join(""), t;
|
|
76
|
+
}, g = function() {
|
|
77
|
+
const t = d("l-switch", {
|
|
78
|
+
class: "l-theme-switch l-theme-inner"
|
|
79
|
+
});
|
|
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
|
+
}, w = function() {
|
|
82
|
+
const t = d("l-radio", {
|
|
83
|
+
class: "l-theme-inner"
|
|
84
|
+
});
|
|
85
|
+
t.value = this.theme, t.type = "button";
|
|
86
|
+
const s = A.map((a) => this.label === "icon" ? `<${a.icon} radio-value="${a.value}"></${a.icon}>` : `<span radio-value="${a.value}">${a.text}</span>`);
|
|
87
|
+
return t.innerHTML = s.join(""), t;
|
|
88
|
+
}, c = new WeakMap(), T = function() {
|
|
89
|
+
p(this, l, H(".l-theme-inner", this.root)), this.type === "button" ? f(o(this, l), "click", o(this, c)) : f(o(this, l), "change", o(this, c));
|
|
90
|
+
}, x = function() {
|
|
91
|
+
o(this, l) && (this.type === "button" ? k(o(this, l), "click", o(this, c)) : k(o(this, l), "change", o(this, c)), p(this, l, void 0));
|
|
92
|
+
}, r(B, "baseName", "theme");
|
|
93
|
+
export {
|
|
94
|
+
B as default
|
|
95
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var s = (o) => {
|
|
3
|
+
throw TypeError(o);
|
|
4
|
+
};
|
|
5
|
+
var u = (o, t, e) => t in o ? d(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
6
|
+
var a = (o, t, e) => u(o, typeof t != "symbol" ? t + "" : t, e), i = (o, t, e) => t.has(o) || s("Cannot " + e);
|
|
7
|
+
var h = (o, t, e) => (i(o, t, "read from private field"), e ? e.call(o) : t.get(o)), l = (o, t, e) => t.has(o) ? s("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e);
|
|
8
|
+
var m = (o, t, e) => (i(o, t, "access private method"), e);
|
|
9
|
+
import { $one as C, on as k } from "ph-utils/dom";
|
|
10
|
+
import f from "../base.js";
|
|
11
|
+
import { getColorTheme as g, applyColorTheme as v } from "ph-utils/theme";
|
|
12
|
+
var c, p, r;
|
|
13
|
+
class E extends f {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
l(this, c);
|
|
17
|
+
a(this, "color");
|
|
18
|
+
l(this, r, async (e) => {
|
|
19
|
+
const n = e.detail;
|
|
20
|
+
this.color = n, await v(n), this.dispatchEvent(new CustomEvent("change", { detail: n }));
|
|
21
|
+
});
|
|
22
|
+
this.color = g() || "#722ed1";
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback(), m(this, c, p).call(this);
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
const e = document.createElement(
|
|
29
|
+
"l-color-picker"
|
|
30
|
+
);
|
|
31
|
+
return e.value = this.color, e;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
c = new WeakSet(), p = function() {
|
|
35
|
+
const e = C("l-color-picker", this.root);
|
|
36
|
+
e && k(e, "change", h(this, r));
|
|
37
|
+
}, r = new WeakMap(), a(E, "baseName", "theme-color");
|
|
38
|
+
export {
|
|
39
|
+
E as default
|
|
40
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const s = /* @__PURE__ */ new Map();
|
|
2
|
+
function o(t) {
|
|
3
|
+
for (const n of s.values())
|
|
4
|
+
for (const e of n)
|
|
5
|
+
f(t, e);
|
|
6
|
+
}
|
|
7
|
+
function f(t, n) {
|
|
8
|
+
const e = t.target, i = !e, c = n.el.contains(e), r = n.el === e;
|
|
9
|
+
i || c || r || n.handler(t);
|
|
10
|
+
}
|
|
11
|
+
function u(t, n) {
|
|
12
|
+
s.has(t) || s.set(t, []);
|
|
13
|
+
const e = s.get(t);
|
|
14
|
+
e && e.push({ el: t, handler: n }), s.size === 1 && document.addEventListener("click", o, !0);
|
|
15
|
+
}
|
|
16
|
+
function a(t) {
|
|
17
|
+
s.delete(t), s.size === 0 && document.removeEventListener("click", o, !0);
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
a as remove,
|
|
21
|
+
u as set
|
|
22
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
type UIConfig = {
|
|
2
|
+
/** 注册应用的前缀, 默认: lt */
|
|
3
|
+
prefix: string;
|
|
4
|
+
};
|
|
5
|
+
export declare function config(cfg: Partial<UIConfig>): void;
|
|
6
|
+
/**
|
|
7
|
+
* 注册 Web Components 组件
|
|
8
|
+
* @param component Web Components 组件
|
|
9
|
+
* @param name 组件名称, 如果不填, 则根据组件的 baseName 生成
|
|
10
|
+
*/
|
|
11
|
+
export declare function regist(component: any | any[], name?: string): void;
|
|
12
|
+
/**
|
|
13
|
+
* 生成一个唯一标识符,格式为:`uiConfig.prefix-递增的seed值`。
|
|
14
|
+
* 此函数用于在组件或应用中生成唯一的ID。
|
|
15
|
+
* @returns 唯一标识符字符串
|
|
16
|
+
*/
|
|
17
|
+
export declare function useId(): string;
|
|
18
|
+
export declare function parseAttrValue(value: string, defaultValue?: string): string;
|
|
19
|
+
export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
|
|
20
|
+
export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
|
|
21
|
+
/**
|
|
22
|
+
* 初始化元素的属性值。
|
|
23
|
+
* 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
|
|
24
|
+
* @param el - 要初始化属性的 HTML 元素。
|
|
25
|
+
*/
|
|
26
|
+
export declare function initAttr(el: HTMLElement): void;
|
|
27
|
+
/**
|
|
28
|
+
* 生成 HTML 标签属性字符串。
|
|
29
|
+
* @param attr - 属性名。
|
|
30
|
+
* @param value - 属性值,可以是字符串、undefined 或布尔值。
|
|
31
|
+
* @returns 返回拼接好的属性字符串。
|
|
32
|
+
*/
|
|
33
|
+
export declare function tagAttr(attr: string, value: string | undefined | boolean): string;
|
|
34
|
+
export declare function tagAttrs(attr: [string, string | undefined | boolean][]): string;
|
|
35
|
+
export declare function setAttrs(el: HTMLElement, attrs: [string, string | undefined | boolean][]): void;
|
|
36
|
+
/**
|
|
37
|
+
* 初始化元素过渡, 同时会监听 l-transition-emit 变化自动执行隐藏动画, show - 显示元素, hide - 隐藏元素
|
|
38
|
+
*
|
|
39
|
+
* 注意需要在页面结束后调用 destroy 销毁监听
|
|
40
|
+
*
|
|
41
|
+
* @param els 需要初始化的元素列表, 如果不传则会自动查找页面中带有 l-transition 属性的元素
|
|
42
|
+
* @returns
|
|
43
|
+
*
|
|
44
|
+
* @example
|
|
45
|
+
* // html
|
|
46
|
+
* <div
|
|
47
|
+
* l-transition="l-opacity"
|
|
48
|
+
* l-transition-emit="show"
|
|
49
|
+
* l-transition-method="hide"
|
|
50
|
+
* >
|
|
51
|
+
* Hello World
|
|
52
|
+
* </div>
|
|
53
|
+
* // js
|
|
54
|
+
* const trans = createTransition();
|
|
55
|
+
*
|
|
56
|
+
* // 销毁监听
|
|
57
|
+
* transition.destroy();
|
|
58
|
+
*/
|
|
59
|
+
export declare function createTransition(): {
|
|
60
|
+
destroy: () => void;
|
|
61
|
+
add: (elems: HTMLElement[]) => void;
|
|
62
|
+
init: (els?: HTMLElement[]) => void;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 获取悬浮窗 y 偏移
|
|
66
|
+
* @param targetRect
|
|
67
|
+
* @param popoverRect
|
|
68
|
+
* @param mainAlign
|
|
69
|
+
* @param crossAlign
|
|
70
|
+
* @returns
|
|
71
|
+
*/
|
|
72
|
+
export declare function getPopoverOffsetY(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, offset?: number): number;
|
|
73
|
+
type DomRectPos = {
|
|
74
|
+
x: number;
|
|
75
|
+
y: number;
|
|
76
|
+
width: number;
|
|
77
|
+
height: number;
|
|
78
|
+
left: number;
|
|
79
|
+
top: number;
|
|
80
|
+
};
|
|
81
|
+
export declare function getPopoverOffsetX(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, offset?: number): number;
|
|
82
|
+
export declare function impactDetect(targetRect: DOMRect, popoverRect: DomRectPos, mainAlign: string, crossAlign: string, scrollLeft: number, scrollTop: number, leftDiff: number, topDiff: number, offset?: number, position?: string): {
|
|
83
|
+
x: number;
|
|
84
|
+
y: number;
|
|
85
|
+
mainAlign: string;
|
|
86
|
+
crossAlign: string;
|
|
87
|
+
};
|
|
88
|
+
export {};
|