litos-ui 0.7.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/{animation-QfX4RtqD.js → animation-DttknHkX.js} +2 -2
- package/lib/base.d.ts +1 -3
- package/lib/base.js +26 -58
- package/lib/button/index.js +58 -62
- package/lib/color_picker/index.js +18 -20
- package/lib/form/form_events.js +15 -17
- package/lib/form/form_inner.js +43 -47
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +49 -53
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +58 -61
- package/lib/icon/arrow_down.js +4 -7
- package/lib/icon/arrow_left.js +4 -7
- package/lib/icon/arrow_right.js +4 -7
- package/lib/icon/arrow_up.js +4 -7
- package/lib/icon/base.js +21 -24
- package/lib/icon/caret_bottom.js +4 -7
- package/lib/icon/caret_top.js +4 -7
- package/lib/icon/font_icon.js +13 -17
- package/lib/icon/info.js +4 -7
- package/lib/icon/loading.js +4 -7
- package/lib/icon/mask_close.js +4 -7
- package/lib/icon/moon.js +4 -7
- package/lib/icon/reduction.js +4 -7
- package/lib/icon/refresh_left.js +4 -7
- package/lib/icon/refresh_right.js +4 -7
- package/lib/icon/search.js +4 -7
- package/lib/icon/sort.js +4 -7
- package/lib/icon/success.js +4 -7
- package/lib/icon/sun.js +4 -7
- package/lib/icon/theme_default.js +4 -7
- package/lib/icon/warn.js +4 -7
- package/lib/{index-B_9rPBWp.js → index-391POYEJ.js} +1 -1
- package/lib/index.d.ts +2 -10
- package/lib/index.js +62 -70
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +66 -70
- package/lib/list/index.d.ts +1 -1
- package/lib/list/index.js +26 -30
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/message/index.js +35 -33
- package/lib/polygon/index.d.ts +1 -1
- package/lib/polygon/index.js +14 -17
- package/lib/popconfirm/index.js +11 -17
- package/lib/popover/index.js +115 -120
- package/lib/radio/index.d.ts +2 -2
- package/lib/radio/index.js +65 -68
- package/lib/select_ori/index.d.ts +1 -1
- package/lib/select_ori/index.js +25 -29
- package/lib/switch/index.js +39 -48
- package/lib/tabbar/index.js +115 -123
- package/lib/theme/index.js +71 -74
- package/lib/theme/theme_color.js +17 -27
- package/lib/utils/event.js +16 -18
- package/lib/utils/index.js +48 -51
- package/lib/utils/transition.js +24 -34
- package/package.json +4 -1
- package/lib/browser.d.ts +0 -17
- package/lib/button/regist.d.ts +0 -2
- package/lib/button/regist.js +0 -7
- package/lib/form/types.js +0 -1
- package/lib/index-116dRdDj.js +0 -4
- package/lib/index-BUyxD_nH.js +0 -4
- package/lib/index-BeOxuMd4.js +0 -4
- package/lib/index-Bl8lRTJd.js +0 -4
- package/lib/index-BxlGVrX3.js +0 -4
- package/lib/index-C2D4YsFw.js +0 -4
- package/lib/index-C98Kx857.js +0 -4
- package/lib/index-CCcVpk6U.js +0 -4
- package/lib/index-CMz7GCCH.js +0 -4
- package/lib/index-D-Ikkdx0.js +0 -4
- package/lib/index-DJ70Xyma.js +0 -4
- package/lib/index-DKvzJmsR.js +0 -4
- package/lib/index-oNjb_IVt.js +0 -4
- package/lib/popconfirm/regist.d.ts +0 -2
- package/lib/popconfirm/regist.js +0 -7
- package/lib/popover/regist.d.ts +0 -2
- package/lib/popover/regist.js +0 -7
- package/lib/tabbar/regist.d.ts +0 -2
- package/lib/tabbar/regist.js +0 -7
package/lib/radio/index.js
CHANGED
|
@@ -1,52 +1,42 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
o(this, "label");
|
|
13
|
-
o(this, "checked", !1);
|
|
14
|
-
o(this, "_changeEvent");
|
|
15
|
-
o(this, "_radioChange", (e) => {
|
|
16
|
-
const a = e.target;
|
|
17
|
-
let t = a.parentElement;
|
|
18
|
-
for (; t != null && !f(t, "l-radio"); )
|
|
19
|
-
t = t.parentElement;
|
|
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
|
-
});
|
|
23
|
-
y(this), this._changeEvent = new CustomEvent("change");
|
|
24
|
-
}
|
|
1
|
+
import { initAttr as $, tagAttr as s, parseAttrValue as x } from "../utils/index.js";
|
|
2
|
+
import y from "../form/form_inner.js";
|
|
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
|
+
import { random as p } from "ph-utils";
|
|
5
|
+
const w = ':host{display:flex;align-items:center}.l-radio{--l-radio-size: 16px;--l-radio-label-color: #333;--l-radio-disabled-color: #e6e6e6;--l-radio-disabled-label-color: var(--l-disabled-color, #c0c4cc);--l-radio-checked-color: var(--l-primary-color, #722ed1);--l-radio-item-margin: 10px;display:inline-flex;align-items:center;position:relative;cursor:pointer}.l-radio__label{transition:color .3s ease-in-out;margin-left:5px}.l-radio__input{position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-radio__inner{display:flex;justify-content:center;align-items:center;width:var(--l-radio-size);height:var(--l-radio-size);border:1px solid #dcddd9;border-radius:50%;box-sizing:border-box;transition:border-color .3s ease-in-out}.l-radio__inner:before{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}.l-radio.is-checked .l-radio__inner{border-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__inner:before{background-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__label{color:var(--l-primary-color, #722ed1)}.l-radio--disabled{cursor:not-allowed}.l-radio--disabledd .l-radio__inner{border-color:var(--l-radio-disabled-color)}.l-radio--disabled .l-radio__label{color:var(--l-radio-disabled-label-color)}.l-radio:not(:first-child){margin-left:var(--l-radio-item-margin)}.l-radio--button .l-radio__label{display:inline-flex;height:var(--l-form-edit-height, 32px);justify-content:center;align-items:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0}.l-radio--button:not(:first-of-type){margin-left:0}.l-radio--button:first-of-type .l-radio__label{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.l-radio--button:last-of-type .l-radio__label{border-top-right-radius:3px;border-bottom-right-radius:3px}.is-checked.l-radio--button .l-radio__label{background-color:var(--l-radio-checked-color);color:#fff;border-color:var(--l-radio-checked-color)}';
|
|
6
|
+
class T extends y {
|
|
7
|
+
static baseName = "radio";
|
|
8
|
+
type;
|
|
9
|
+
label;
|
|
10
|
+
checked = !1;
|
|
11
|
+
_ignoreInitAttrs = [];
|
|
25
12
|
setItems(e) {
|
|
26
13
|
this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
|
|
27
14
|
}
|
|
15
|
+
constructor() {
|
|
16
|
+
super(!1), console.log(), $(this);
|
|
17
|
+
}
|
|
28
18
|
connectedCallback() {
|
|
29
|
-
super.connectedCallback(), this.
|
|
19
|
+
super.connectedCallback(), this.loadStyleText(w), this._initEvents();
|
|
30
20
|
}
|
|
31
21
|
disconnectedCallback() {
|
|
32
22
|
super.disconnectedCallback(), this._removeEvents();
|
|
33
23
|
}
|
|
34
|
-
attributeChange(e,
|
|
24
|
+
attributeChange(e, o, t) {
|
|
35
25
|
if (e === "checked") {
|
|
36
|
-
const
|
|
37
|
-
this.checked =
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
|
|
41
|
-
const l =
|
|
26
|
+
const i = x(t, !1, e);
|
|
27
|
+
this.checked = i, this.value = i;
|
|
28
|
+
const r = a(".l-radio", this.root);
|
|
29
|
+
if (r && !u(r, "is-checked")) {
|
|
30
|
+
n(r, "is-checked");
|
|
31
|
+
const l = a("input", r);
|
|
42
32
|
l && (l.checked = !0);
|
|
43
33
|
}
|
|
44
34
|
}
|
|
45
35
|
}
|
|
46
36
|
render() {
|
|
47
|
-
this.getName() || (this.name = `la${
|
|
48
|
-
const e = [],
|
|
49
|
-
|
|
37
|
+
this.getName() || (this.name = `la${p(3)}_${p(6)}`);
|
|
38
|
+
const e = [], o = a('[slot="label"]', this), t = c("[radio-value]", this);
|
|
39
|
+
return o != null || this.label ? (this.value = this._isChecked(), o ? e.push(
|
|
50
40
|
this._renderItem("slot", void 0, this._isChecked(), "label")
|
|
51
41
|
) : e.push(
|
|
52
42
|
this._renderItem(
|
|
@@ -55,71 +45,78 @@ class L extends V {
|
|
|
55
45
|
this._isChecked(),
|
|
56
46
|
"label"
|
|
57
47
|
)
|
|
58
|
-
)) : t.length > 0 && (
|
|
59
|
-
const
|
|
48
|
+
)) : t.length > 0 && (h(t, (i) => {
|
|
49
|
+
const r = i.cloneNode(!0), l = C(i, "radio-value");
|
|
60
50
|
e.push(
|
|
61
|
-
this._renderItem(
|
|
51
|
+
this._renderItem(r.outerHTML, l, this.value === l)
|
|
62
52
|
);
|
|
63
|
-
}), this.pushValueChange()),
|
|
53
|
+
}), this.pushValueChange()), e.join("");
|
|
64
54
|
}
|
|
65
55
|
setValue(e) {
|
|
66
56
|
super.setValue(e);
|
|
67
|
-
let
|
|
68
|
-
typeof e != "boolean" && (
|
|
69
|
-
const t =
|
|
57
|
+
let o = "";
|
|
58
|
+
typeof e != "boolean" && (o = `[l-value="${e}"]`);
|
|
59
|
+
const t = a(".is-checked", this.root);
|
|
70
60
|
t && b(t, "is-checked");
|
|
71
|
-
const
|
|
72
|
-
if (
|
|
73
|
-
const
|
|
74
|
-
typeof e == "boolean" ? (e ?
|
|
61
|
+
const i = a(`label${o}`, this.root);
|
|
62
|
+
if (i) {
|
|
63
|
+
const r = a("input", i);
|
|
64
|
+
typeof e == "boolean" ? (e ? n(i, "is-checked") : b(i, "is-checked"), r.checked = e) : (n(i, "is-checked"), r.checked = !0);
|
|
75
65
|
}
|
|
76
66
|
}
|
|
77
67
|
_renderItems(e) {
|
|
78
|
-
const
|
|
79
|
-
for (let t = 0,
|
|
80
|
-
const
|
|
81
|
-
|
|
68
|
+
const o = [];
|
|
69
|
+
for (let t = 0, i = e.length; t < i; t++) {
|
|
70
|
+
const r = e[t];
|
|
71
|
+
o.push(
|
|
82
72
|
this._renderItem(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
this.value ===
|
|
86
|
-
|
|
73
|
+
r.label,
|
|
74
|
+
r.value,
|
|
75
|
+
this.value === r.value,
|
|
76
|
+
r.labelPart
|
|
87
77
|
)
|
|
88
78
|
);
|
|
89
79
|
}
|
|
90
|
-
return
|
|
80
|
+
return o.join("");
|
|
91
81
|
}
|
|
92
|
-
_renderItem(e,
|
|
93
|
-
const
|
|
82
|
+
_renderItem(e, o, t = !1, i = void 0) {
|
|
83
|
+
const r = A({
|
|
94
84
|
"l-radio": !0,
|
|
95
85
|
"l-radio--disabled": this.isDisabled(),
|
|
96
86
|
"l-radio--button": this.type === "button",
|
|
97
87
|
"is-checked": t
|
|
98
|
-
}), l =
|
|
99
|
-
`<label class="${
|
|
100
|
-
`<input type="radio" class="l-radio__input"${
|
|
88
|
+
}), l = s("disabled", this.isDisabled()), f = s("checked", t), m = s("value", o), _ = `${s("name", this.getName())}${m}${l}${f}`, v = s("part", i), g = s("l-value", o), d = [
|
|
89
|
+
`<label class="${r}"${g}>`,
|
|
90
|
+
`<input type="radio" class="l-radio__input"${_} />`
|
|
101
91
|
];
|
|
102
92
|
this.type !== "button" && d.push('<span class="l-radio__inner"></span>');
|
|
103
|
-
let
|
|
93
|
+
let k = e === "slot" ? '<slot name="label"></slot>' : e;
|
|
104
94
|
return d.push(
|
|
105
|
-
`<div class="l-radio__label"${
|
|
95
|
+
`<div class="l-radio__label"${v}>${k}</div>`
|
|
106
96
|
), d.push("</label>"), d.join("");
|
|
107
97
|
}
|
|
108
98
|
_isChecked() {
|
|
109
99
|
return this.checked;
|
|
110
100
|
}
|
|
111
101
|
_initEvents() {
|
|
112
|
-
|
|
113
|
-
|
|
102
|
+
h(c("input", this.root), (e) => {
|
|
103
|
+
E(e, "change", this._radioChange);
|
|
114
104
|
});
|
|
115
105
|
}
|
|
116
106
|
_removeEvents() {
|
|
117
|
-
|
|
118
|
-
|
|
107
|
+
h(c("input", this.root), (e) => {
|
|
108
|
+
I(e, "change", this._radioChange);
|
|
119
109
|
});
|
|
120
110
|
}
|
|
111
|
+
_radioChange = (e) => {
|
|
112
|
+
const o = e.target;
|
|
113
|
+
let t = o.parentElement;
|
|
114
|
+
for (; t != null && !u(t, "l-radio"); )
|
|
115
|
+
t = t.parentElement;
|
|
116
|
+
const i = a(".is-checked", this.root);
|
|
117
|
+
i && b(i, "is-checked"), this.value = o.value, t && n(t, "is-checked"), this.dispatchEvent(new CustomEvent("change"));
|
|
118
|
+
};
|
|
121
119
|
}
|
|
122
|
-
o(L, "baseName", "radio");
|
|
123
120
|
export {
|
|
124
|
-
|
|
121
|
+
T as default
|
|
125
122
|
};
|
|
@@ -10,7 +10,7 @@ export default class SelectOri extends FormInner {
|
|
|
10
10
|
constructor();
|
|
11
11
|
connectedCallback(): void;
|
|
12
12
|
disconnectedCallback(): void;
|
|
13
|
-
render():
|
|
13
|
+
render(): string;
|
|
14
14
|
protected _changeDisabled(): void;
|
|
15
15
|
setOptions(options: Option[]): void;
|
|
16
16
|
appendOptions(options: Option[]): void;
|
package/lib/select_ori/index.js
CHANGED
|
@@ -1,50 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
+
static baseName = "select-ori";
|
|
7
|
+
$select;
|
|
8
|
+
changeEmit;
|
|
8
9
|
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");
|
|
10
|
+
super(), c(this), this.changeEmit = new CustomEvent("change");
|
|
17
11
|
}
|
|
18
12
|
connectedCallback() {
|
|
19
|
-
this.
|
|
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);
|
|
20
14
|
}
|
|
21
15
|
disconnectedCallback() {
|
|
22
|
-
super.disconnectedCallback(), this.$select &&
|
|
16
|
+
super.disconnectedCallback(), this.$select && u(this.$select, "change", this._handleChange), this.changeEmit = void 0, this.$select = void 0;
|
|
23
17
|
}
|
|
24
18
|
render() {
|
|
25
19
|
let e = this.innerHTML.trim();
|
|
26
|
-
|
|
20
|
+
return `<select class="l-input"${h([
|
|
27
21
|
["name", this.getName()],
|
|
28
22
|
["disabled", this.isDisabled()]
|
|
29
|
-
])
|
|
30
|
-
this.root.innerHTML = `<select class="l-input"${s}>${e}</select>`;
|
|
23
|
+
])}>${e}</select>`;
|
|
31
24
|
}
|
|
32
25
|
_changeDisabled() {
|
|
33
26
|
this.$select && (this.$select.disabled = this.isDisabled());
|
|
34
27
|
}
|
|
35
28
|
setOptions(e) {
|
|
36
29
|
if (!this.$select) return;
|
|
37
|
-
const
|
|
38
|
-
this.$select.innerHTML =
|
|
30
|
+
const t = e.map((s) => `<option value="${s.value}">${s.label}</option>`);
|
|
31
|
+
this.$select.innerHTML = t.join("");
|
|
39
32
|
}
|
|
40
33
|
appendOptions(e) {
|
|
41
34
|
if (!this.$select) return;
|
|
42
|
-
const
|
|
43
|
-
for (let
|
|
44
|
-
const
|
|
45
|
-
|
|
35
|
+
const t = document.createDocumentFragment();
|
|
36
|
+
for (let s = 0, n = e.length; s < n; s++) {
|
|
37
|
+
const l = e[s], i = document.createElement("option");
|
|
38
|
+
i.value = l.value, i.innerHTML = l.label, t.appendChild(i);
|
|
46
39
|
}
|
|
47
|
-
this.$select.appendChild(
|
|
40
|
+
this.$select.appendChild(t);
|
|
48
41
|
}
|
|
49
42
|
reset() {
|
|
50
43
|
super.reset(), this.$select && (this.$select.value = this.value);
|
|
@@ -52,8 +45,11 @@ class v extends u {
|
|
|
52
45
|
setValue(e) {
|
|
53
46
|
super.setValue(e), this.$select && (this.$select.value = this.value);
|
|
54
47
|
}
|
|
48
|
+
_handleChange = (e) => {
|
|
49
|
+
const t = e.target.value;
|
|
50
|
+
super.setValue(t), this.dispatchEvent(this.changeEmit);
|
|
51
|
+
};
|
|
55
52
|
}
|
|
56
|
-
n(v, "baseName", "select-ori");
|
|
57
53
|
export {
|
|
58
|
-
|
|
54
|
+
f as default
|
|
59
55
|
};
|
package/lib/switch/index.js
CHANGED
|
@@ -1,64 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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 {
|
|
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}: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
|
+
static baseName = "switch";
|
|
7
|
+
actionRender;
|
|
8
|
+
checkedText;
|
|
9
|
+
uncheckedText;
|
|
14
10
|
constructor() {
|
|
15
|
-
super(!1);
|
|
16
|
-
r(this,
|
|
17
|
-
|
|
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;
|
|
11
|
+
super(!1), a(this);
|
|
12
|
+
const t = this.value ? r(this.value, !1, "value") : !1;
|
|
13
|
+
this._resetValue = t, this.value = t;
|
|
26
14
|
}
|
|
27
15
|
connectedCallback() {
|
|
28
|
-
this.
|
|
16
|
+
this.loadStyleText(d), super.connectedCallback(), this.pushValueChange(), this.#t(), c(this, "click", this.#e);
|
|
29
17
|
}
|
|
30
18
|
disconnectedCallback() {
|
|
31
|
-
super.disconnectedCallback(),
|
|
19
|
+
super.disconnectedCallback(), h(this, "click", this.#e), this.actionRender = void 0;
|
|
32
20
|
}
|
|
33
21
|
render() {
|
|
34
22
|
this.isDisabled() && this.classList.add("l-switch--disabled"), this.value && this.classList.add("l-switch--checked");
|
|
35
|
-
const
|
|
23
|
+
const t = ['<div class="l-switch-action" part="action"></div>'];
|
|
36
24
|
if (this.checkedText || this.uncheckedText) {
|
|
37
|
-
const
|
|
38
|
-
|
|
25
|
+
const e = this.value ? this.checkedText || "" : this.uncheckedText || "";
|
|
26
|
+
t.push(`<span class="l-switch-text">${e}</span>`);
|
|
39
27
|
}
|
|
40
|
-
return
|
|
28
|
+
return t.join("");
|
|
29
|
+
}
|
|
30
|
+
#e = (t) => {
|
|
31
|
+
this.isDisabled() || (this.setValue(!this.value), this.dispatchEvent(new CustomEvent("change")));
|
|
32
|
+
};
|
|
33
|
+
setValue(t) {
|
|
34
|
+
super.setValue(t), t ? o(this, "l-switch--checked") : l(this, "l-switch--checked");
|
|
35
|
+
const e = i(".l-switch-text", this.root);
|
|
36
|
+
e && (e.textContent = this.value ? this.checkedText || "" : this.uncheckedText || ""), this.#t();
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
|
|
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);
|
|
38
|
+
setActionRender(t) {
|
|
39
|
+
this.actionRender = t, this.#t();
|
|
46
40
|
}
|
|
47
|
-
|
|
48
|
-
|
|
41
|
+
#t() {
|
|
42
|
+
const t = i(".l-switch-action", this.root);
|
|
43
|
+
if (t)
|
|
44
|
+
if (this.actionRender) {
|
|
45
|
+
const e = this.actionRender({ checked: this.value });
|
|
46
|
+
typeof e == "string" ? t.innerHTML = e : t.innerHTML = e.outerHTML;
|
|
47
|
+
} else {
|
|
48
|
+
const e = i('[slot="checked-action"]', this), s = i('[slot="unchecked-action"]', this);
|
|
49
|
+
this.value && e ? t.innerHTML = '<slot name="checked-action"></slot>' : !this.value && s && (t.innerHTML = '<slot name="unchecked-action"></slot>');
|
|
50
|
+
}
|
|
49
51
|
}
|
|
50
52
|
}
|
|
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
53
|
export {
|
|
63
|
-
|
|
54
|
+
w as default
|
|
64
55
|
};
|