litos-ui 0.16.0 → 0.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/button/index.d.ts +3 -10
- package/lib/button/index.js +32 -48
- package/lib/check/check.d.ts +1 -0
- package/lib/check/check.js +26 -16
- package/lib/check/checkbox.js +4 -11
- package/lib/check/checkbox_group.d.ts +1 -5
- package/lib/check/checkbox_group.js +6 -28
- package/lib/check/index.d.ts +7 -1
- package/lib/check/index.js +47 -20
- package/lib/check/radio.js +6 -14
- package/lib/check/radio_group.d.ts +3 -2
- package/lib/check/radio_group.js +10 -17
- package/lib/check-D-KVLA1z.js +4 -0
- package/lib/form/form_inner.js +4 -18
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +12 -14
- package/lib/form/index.js +3 -3
- package/lib/input/index.js +63 -67
- package/lib/loading/index.d.ts +2 -0
- package/lib/loading/index.js +50 -64
- package/lib/message/index.js +9 -9
- package/lib/modal/index.d.ts +1 -6
- package/lib/modal/index.js +40 -46
- package/lib/tag/index.d.ts +2 -5
- package/lib/tag/index.js +35 -43
- package/package.json +67 -72
- package/styles/loading.css +5 -3
- package/lib/check-C7YSuH60.js +0 -4
package/lib/button/index.d.ts
CHANGED
|
@@ -1,24 +1,17 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
2
|
export default class Button extends BaseComponent {
|
|
3
3
|
static baseName: string;
|
|
4
|
-
htmlType: "submit" | "reset" | "button";
|
|
5
|
-
/** 加载中文本 */
|
|
6
|
-
loadingText: string;
|
|
7
|
-
_height?: string | number;
|
|
8
4
|
_disabled: boolean;
|
|
9
|
-
_loading: boolean;
|
|
10
|
-
get height(): string | number | undefined;
|
|
11
|
-
set height(height: string | number | undefined);
|
|
12
5
|
get disabled(): boolean;
|
|
13
6
|
set disabled(value: boolean);
|
|
14
|
-
|
|
15
|
-
set loading(value: boolean);
|
|
16
|
-
setLoading(value: boolean): void;
|
|
7
|
+
setLoading(loading: boolean): void;
|
|
17
8
|
setDisabled(value: boolean): void;
|
|
18
9
|
static get observedAttributes(): string[];
|
|
19
10
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
20
11
|
connectedCallback(): void;
|
|
21
12
|
disconnectedCallback(): void;
|
|
13
|
+
isFormButton(): boolean;
|
|
14
|
+
getHtmlType(): "submit" | "reset" | "button";
|
|
22
15
|
render(): void;
|
|
23
16
|
loadingBody(): string;
|
|
24
17
|
applyColor(color: string, text?: boolean, ghost?: boolean): string;
|
package/lib/button/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { initAttr as c, parseAttrValue as s } from "../utils/index.js";
|
|
2
2
|
import h from "../base.js";
|
|
3
3
|
import { $one as b, addClass as g, removeClass as f, on as p, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
|
|
4
4
|
import { adjust as d } from "ph-utils/color";
|
|
@@ -6,32 +6,15 @@ import { a as x } from "../animation-DttknHkX.js";
|
|
|
6
6
|
const y = ":host{--l-btn-padding: 0 15px;--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;--l-btn-height: var(--l-form-control-height, 32px);display:inline-flex;width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius, 3px)}:host([block]){width:100%}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:var(--l-btn-padding);line-height:1;height:100%;border-radius:inherit;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:var(--l-btn-gap, 5px);font-size:inherit;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab);--l-btn-disabled-border-color: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-background: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-color: #ffffff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-padding: 5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-control-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-control-height, 32px);padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
|
|
7
7
|
class H extends h {
|
|
8
8
|
static baseName = "button";
|
|
9
|
-
htmlType = "button";
|
|
10
|
-
/** 加载中文本 */
|
|
11
|
-
loadingText = "";
|
|
12
|
-
_height;
|
|
9
|
+
// public htmlType: "submit" | "reset" | "button" = "button";
|
|
13
10
|
_disabled = !1;
|
|
14
|
-
_loading = !1;
|
|
15
|
-
get height() {
|
|
16
|
-
return this._height;
|
|
17
|
-
}
|
|
18
|
-
set height(t) {
|
|
19
|
-
this._height = t, this.rendered && this._updateHeight();
|
|
20
|
-
}
|
|
21
11
|
get disabled() {
|
|
22
12
|
return this._disabled;
|
|
23
13
|
}
|
|
24
14
|
set disabled(t) {
|
|
25
15
|
this.setDisabled(t);
|
|
26
16
|
}
|
|
27
|
-
get loading() {
|
|
28
|
-
return this._loading;
|
|
29
|
-
}
|
|
30
|
-
set loading(t) {
|
|
31
|
-
this.setLoading(t);
|
|
32
|
-
}
|
|
33
17
|
setLoading(t) {
|
|
34
|
-
this._loading = t;
|
|
35
18
|
const r = b(".l-btn", this.root);
|
|
36
19
|
r && (t ? (g(r, "l-btn-loading"), r.disabled = !0, r.innerHTML = this.loadingBody()) : (f(r, "l-btn-loading"), r.disabled = this.disabled, r.innerHTML = "<slot></slot>"));
|
|
37
20
|
}
|
|
@@ -49,70 +32,71 @@ class H extends h {
|
|
|
49
32
|
const e = b(".l-btn", this.root);
|
|
50
33
|
if (e) {
|
|
51
34
|
if (t === "loading") {
|
|
52
|
-
const
|
|
53
|
-
this.setLoading(
|
|
35
|
+
const l = s(o, !1, t);
|
|
36
|
+
this.setLoading(l);
|
|
54
37
|
return;
|
|
55
38
|
} else if (t === "color") {
|
|
56
|
-
const
|
|
57
|
-
e.style.cssText = this.applyColor(o,
|
|
39
|
+
const l = this.getAttr("text", !1), a = this.getAttr("ghost", !1);
|
|
40
|
+
e.style.cssText = this.applyColor(o, l, a);
|
|
58
41
|
return;
|
|
59
42
|
} else if (t === "disabled") {
|
|
60
|
-
const
|
|
61
|
-
this.setDisabled(
|
|
43
|
+
const l = s(o, !1, "disabled");
|
|
44
|
+
this.setDisabled(l);
|
|
62
45
|
return;
|
|
63
46
|
}
|
|
64
47
|
}
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
t
|
|
69
|
-
);
|
|
70
|
-
l !== this[t] && (this[t] = l, t === "height" && this.rendered && this._updateHeight());
|
|
48
|
+
if (!this.rendered) return;
|
|
49
|
+
const n = o.trim();
|
|
50
|
+
t === "height" && this._updateHeight(n);
|
|
71
51
|
}
|
|
72
52
|
connectedCallback() {
|
|
73
|
-
c(this), this.loadStyleText([x, y]), this.render(),
|
|
53
|
+
c(this), this.loadStyleText([x, y]), this.render(), this.isFormButton() && p(this, "click", this._handleClick), this._updateHeight(this.getAttr("height"));
|
|
74
54
|
}
|
|
75
55
|
disconnectedCallback() {
|
|
76
|
-
super.disconnectedCallback(),
|
|
56
|
+
super.disconnectedCallback(), this.isFormButton() && v(this, "click", this._handleClick);
|
|
57
|
+
}
|
|
58
|
+
isFormButton() {
|
|
59
|
+
const t = this.getHtmlType();
|
|
60
|
+
return t === "submit" || t === "reset";
|
|
61
|
+
}
|
|
62
|
+
getHtmlType() {
|
|
63
|
+
return this.getAttr("html-type", "button");
|
|
77
64
|
}
|
|
78
65
|
render() {
|
|
79
|
-
const t = this.getAttr("type", "normal"), r = document.createElement("button"), o = this.getAttr("loading", !1), e = this.getAttr("shape", "default"),
|
|
66
|
+
const t = this.getAttr("type", "normal"), r = document.createElement("button"), o = this.getAttr("loading", !1), e = this.getAttr("shape", "default"), n = this.getAttr("text", !1), l = this.getAttr("ghost", !1), a = [
|
|
80
67
|
"l-btn",
|
|
81
68
|
`l-btn-${t}`,
|
|
82
69
|
e === "round" ? "l-btn-round" : "",
|
|
83
70
|
e === "circle" ? "l-btn-circle" : "",
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
l ? "l-btn-ghost" : "",
|
|
72
|
+
n ? "l-btn-text" : "",
|
|
86
73
|
o ? "l-btn-loading" : ""
|
|
87
74
|
];
|
|
88
75
|
r.className = u(a), (this.disabled || o) && (r.disabled = !0), r.type = this.getAttr("html-type", "button");
|
|
89
|
-
const
|
|
90
|
-
|
|
76
|
+
const i = this.applyColor(this.getAttr("color"), n, l);
|
|
77
|
+
i && (r.style.cssText = i), o ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.root.appendChild(r);
|
|
91
78
|
}
|
|
92
79
|
loadingBody() {
|
|
93
|
-
const t = this.getAttr("loading-text", ""), r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
80
|
+
const t = this.getAttr("loading-text", "加载中……"), r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
94
81
|
return t ? r.push(`<span>${t}</span>`) : r.push("<slot></slot>"), r.join("");
|
|
95
82
|
}
|
|
96
83
|
applyColor(t, r = !1, o = !1) {
|
|
97
84
|
if (!t) return "";
|
|
98
|
-
const e = d(t, 1, !0),
|
|
85
|
+
const e = d(t, 1, !0), n = d(t, 3, !1);
|
|
99
86
|
return m({
|
|
100
87
|
"--l-btn-border-color": r ? "transparent" : t,
|
|
101
88
|
"--l-btn-text-color": o || r ? t : "#ffffff",
|
|
102
89
|
"--l-btn-hover-text-color": o || r ? e : "#ffffff",
|
|
103
90
|
"--l-btn-background": o || r ? "transparent" : t,
|
|
104
|
-
"--l-btn-active-text-color": o || r ?
|
|
91
|
+
"--l-btn-active-text-color": o || r ? n : "#ffffff",
|
|
105
92
|
"--l-btn-hover-border-color": r ? "transparent" : e,
|
|
106
93
|
"--l-btn-hover-background": o || r ? "transparent" : e,
|
|
107
|
-
"--l-btn-active-background": o || r ? "transparent" :
|
|
108
|
-
"--l-btn-active-border-color": r ? "transparent" :
|
|
94
|
+
"--l-btn-active-background": o || r ? "transparent" : n,
|
|
95
|
+
"--l-btn-active-border-color": r ? "transparent" : n
|
|
109
96
|
});
|
|
110
97
|
}
|
|
111
|
-
_updateHeight() {
|
|
112
|
-
|
|
113
|
-
let t = this.height;
|
|
114
|
-
typeof t == "number" && (t = `${t}px`), this.style.setProperty("--l-btn-height", t);
|
|
115
|
-
}
|
|
98
|
+
_updateHeight(t) {
|
|
99
|
+
t && (typeof t == "number" && (t = `${t}px`), this.style.setProperty("--l-btn-height", t));
|
|
116
100
|
}
|
|
117
101
|
_handleClick = (t) => {
|
|
118
102
|
const r = t.target, o = k(r, "html-type");
|
package/lib/check/check.d.ts
CHANGED
package/lib/check/check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { initAttr as
|
|
3
|
-
import { addClass as h, on as r, off as o, $$ as
|
|
4
|
-
class m extends
|
|
1
|
+
import n from "../form/form_inner.js";
|
|
2
|
+
import { initAttr as l, parseAttrValue as d } from "../utils/index.js";
|
|
3
|
+
import { addClass as h, on as r, off as o, $$ as s, removeClass as k, $one as u, toggleClass as C } from "ph-utils/dom";
|
|
4
|
+
class m extends n {
|
|
5
5
|
/** 是否选中 */
|
|
6
6
|
_checked = !1;
|
|
7
7
|
label;
|
|
@@ -24,19 +24,19 @@ class m extends d {
|
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
static get observedAttributes() {
|
|
27
|
-
return ["disabled", "checked"];
|
|
27
|
+
return ["disabled", "checked", "value", "name"];
|
|
28
28
|
}
|
|
29
29
|
connectedCallback() {
|
|
30
|
-
|
|
30
|
+
l(this), super.connectedCallback(), this.getChecked() && h(this, "is-checked"), this.isDisabled() && h(this, "is-disabled");
|
|
31
31
|
}
|
|
32
32
|
afterInit() {
|
|
33
|
-
r(this, "click", this.#e);
|
|
33
|
+
r(this, "click", this.#e), console.log("inner value: " + this.value);
|
|
34
34
|
}
|
|
35
35
|
beforeDestroy() {
|
|
36
36
|
o(this, "click", this.#e);
|
|
37
37
|
}
|
|
38
38
|
render() {
|
|
39
|
-
const e = document.createDocumentFragment(), c =
|
|
39
|
+
const e = document.createDocumentFragment(), c = s("input", {
|
|
40
40
|
type: this._inputType,
|
|
41
41
|
class: "l-check__input",
|
|
42
42
|
name: this.getName(),
|
|
@@ -44,34 +44,44 @@ class m extends d {
|
|
|
44
44
|
checked: this.getChecked()
|
|
45
45
|
});
|
|
46
46
|
if (this.isDisabled() && (c.disabled = !0), e.appendChild(c), !this.button) {
|
|
47
|
-
const a =
|
|
47
|
+
const a = s("span", { class: "l-check__inner" });
|
|
48
48
|
e.appendChild(a);
|
|
49
49
|
}
|
|
50
|
-
const t =
|
|
50
|
+
const t = s("label", {
|
|
51
51
|
class: "l-check__label",
|
|
52
52
|
part: "label"
|
|
53
|
-
}),
|
|
53
|
+
}), i = s("slot", {
|
|
54
54
|
textContent: this.label
|
|
55
55
|
});
|
|
56
|
-
return t.appendChild(
|
|
56
|
+
return t.appendChild(i), e.appendChild(t), e;
|
|
57
57
|
}
|
|
58
58
|
attributeChange(e, c, t) {
|
|
59
59
|
if (e === "checked") {
|
|
60
|
-
const
|
|
61
|
-
|
|
60
|
+
const i = d(t, !1, "checked");
|
|
61
|
+
i !== this.getChecked() && this.setChecked(i);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
checkedChange() {
|
|
65
65
|
this.getChecked() ? h(this, "is-checked") : k(this, "is-checked");
|
|
66
66
|
const e = u("input", this.root);
|
|
67
|
-
e && (e.checked = this.
|
|
67
|
+
e && (e.checked = this.getChecked());
|
|
68
68
|
}
|
|
69
69
|
disabledChange() {
|
|
70
|
-
|
|
70
|
+
C(this, "is-disabled");
|
|
71
71
|
}
|
|
72
72
|
#e = () => {
|
|
73
73
|
this.isDisabled() || this._doChangeAction();
|
|
74
74
|
};
|
|
75
|
+
emitChange() {
|
|
76
|
+
this.emit("change", {
|
|
77
|
+
detail: {
|
|
78
|
+
value: this.value,
|
|
79
|
+
name: this.getName(),
|
|
80
|
+
checked: this.getChecked()
|
|
81
|
+
},
|
|
82
|
+
composed: !0
|
|
83
|
+
});
|
|
84
|
+
}
|
|
75
85
|
_doChangeAction() {
|
|
76
86
|
}
|
|
77
87
|
}
|
package/lib/check/checkbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "./check.js";
|
|
2
|
-
import { c as r } from "../check-
|
|
2
|
+
import { c as r } from "../check-D-KVLA1z.js";
|
|
3
3
|
const o = '.l-check__inner:after{content:"";width:calc(var(--l-check-size) * .6);height:calc(var(--l-check-size) * .3);display:block;border:solid 1px transparent;border-right:none;border-top:none;transform:rotate(-45deg);transition:border-color .2s ease-in-out;margin-top:-3px}:host([indeterminate]) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host([indeterminate]) .l-check__inner:after{content:"";width:calc(var(--l-check-size) * .4);height:1px;display:block;border:1px solid #fff;border-right:none;border-top:none;border-left:none;transform:rotate(0);margin-top:0}:host(.is-checked) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner:after{border-color:#fff}:host(.is-disabled) .l-check__inner{background-color:var(--l-disabled-color, #e6e6e6);border-color:var(--l-disabled-color, #e6e6e6)}';
|
|
4
|
-
class
|
|
4
|
+
class i extends e {
|
|
5
5
|
static baseName = "checkbox";
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this._inputType = "checkbox";
|
|
@@ -10,16 +10,9 @@ class a extends e {
|
|
|
10
10
|
this.loadStyleText([r, o]), super.connectedCallback();
|
|
11
11
|
}
|
|
12
12
|
_doChangeAction() {
|
|
13
|
-
this.getChecked() ? this.removeAttribute("checked") : this.setAttribute("checked", ""), this.
|
|
14
|
-
detail: {
|
|
15
|
-
value: this.value,
|
|
16
|
-
name: this.getName(),
|
|
17
|
-
checked: this.getChecked()
|
|
18
|
-
},
|
|
19
|
-
composed: !0
|
|
20
|
-
});
|
|
13
|
+
this.getChecked() ? this.removeAttribute("checked") : this.setAttribute("checked", ""), this.emitChange();
|
|
21
14
|
}
|
|
22
15
|
}
|
|
23
16
|
export {
|
|
24
|
-
|
|
17
|
+
i as default
|
|
25
18
|
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import CheckGroup from ".";
|
|
2
2
|
export default class CheckboxGroup extends CheckGroup {
|
|
3
3
|
static baseName: string;
|
|
4
|
-
|
|
5
|
-
get value(): string;
|
|
6
|
-
afterInit(): void;
|
|
7
|
-
protected updateChangedStatus(): void;
|
|
8
|
-
valueChange(value: string): void;
|
|
4
|
+
setValue(value: string): void;
|
|
9
5
|
}
|
|
@@ -1,33 +1,11 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
class d extends a {
|
|
1
|
+
import c from "./index.js";
|
|
2
|
+
class a extends c {
|
|
4
3
|
static baseName = "checkbox-group";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
get value() {
|
|
9
|
-
return this._value;
|
|
10
|
-
}
|
|
11
|
-
afterInit() {
|
|
12
|
-
super.afterInit(), this.updateChangedStatus();
|
|
13
|
-
}
|
|
14
|
-
updateChangedStatus() {
|
|
15
|
-
if (this.value) {
|
|
16
|
-
const e = this.value.split("&");
|
|
17
|
-
this.checkedValues.push(...e.map((s) => decodeURIComponent(s)));
|
|
18
|
-
} else
|
|
19
|
-
this.checkedValues = [];
|
|
20
|
-
const t = u("l-checkbox[value]", this);
|
|
21
|
-
i(t, (e) => {
|
|
22
|
-
let s = e.value;
|
|
23
|
-
s || (s = e.getAttribute("value")), s && (this.checkedValues.includes(s) ? e.setAttribute("checked", "") : e.removeAttribute("checked"));
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
valueChange(t) {
|
|
27
|
-
let e = this.checkedValues.indexOf(t);
|
|
28
|
-
e >= 0 ? this.checkedValues.splice(e, 1) : this.checkedValues.push(t), this.setValue(this.checkedValues.join("&"));
|
|
4
|
+
setValue(e) {
|
|
5
|
+
let s = this.checkedValues.indexOf(e);
|
|
6
|
+
s >= 0 ? this.checkedValues.splice(s, 1) : this.checkedValues.push(e), super.setValue(this.checkedValues.join("&"));
|
|
29
7
|
}
|
|
30
8
|
}
|
|
31
9
|
export {
|
|
32
|
-
|
|
10
|
+
a as default
|
|
33
11
|
};
|
package/lib/check/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import FormInner from "../form/form_inner";
|
|
|
2
2
|
export default class CheckGroup extends FormInner {
|
|
3
3
|
#private;
|
|
4
4
|
checkedValues: string[];
|
|
5
|
+
multiple: boolean;
|
|
6
|
+
set value(value: string);
|
|
7
|
+
get value(): string;
|
|
5
8
|
constructor();
|
|
6
9
|
static get observedAttributes(): string[];
|
|
7
10
|
attributeChange(name: string, oldValue: any, newValue: any): void;
|
|
@@ -9,5 +12,8 @@ export default class CheckGroup extends FormInner {
|
|
|
9
12
|
afterInit(): void;
|
|
10
13
|
beforeDestroy(): void;
|
|
11
14
|
render(): HTMLElement;
|
|
12
|
-
|
|
15
|
+
protected updatePartChild(value: string): void;
|
|
16
|
+
protected updateChecked(): void;
|
|
17
|
+
protected updateChangedStatus(): void;
|
|
18
|
+
protected updateChildren(): void;
|
|
13
19
|
}
|
package/lib/check/index.js
CHANGED
|
@@ -1,48 +1,75 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { on as
|
|
3
|
-
import {
|
|
4
|
-
import { isNumeric as
|
|
5
|
-
const
|
|
6
|
-
class
|
|
1
|
+
import l from "../form/form_inner.js";
|
|
2
|
+
import { on as u, off as r, $$ as h, iterate as d } from "ph-utils/dom";
|
|
3
|
+
import { initAttr as c, parseAttrValue as o } from "../utils/index.js";
|
|
4
|
+
import { isNumeric as p } from "ph-utils";
|
|
5
|
+
const n = ":host{display:flex;align-items:center;gap:var(--l-check-gap, 0px)}";
|
|
6
|
+
class C extends l {
|
|
7
7
|
checkedValues;
|
|
8
|
+
multiple;
|
|
9
|
+
set value(e) {
|
|
10
|
+
super.setValue(e), this.rendered && this.updateChangedStatus();
|
|
11
|
+
}
|
|
12
|
+
get value() {
|
|
13
|
+
return this._value;
|
|
14
|
+
}
|
|
8
15
|
constructor() {
|
|
9
|
-
super(!1), this.checkedValues = [];
|
|
16
|
+
super(!1), this.multiple = !0, this.checkedValues = [];
|
|
10
17
|
}
|
|
11
18
|
static get observedAttributes() {
|
|
12
19
|
return ["gap", "value"];
|
|
13
20
|
}
|
|
14
|
-
attributeChange(e,
|
|
15
|
-
if (
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
const
|
|
19
|
-
this.style.setProperty("--l-check-gap",
|
|
21
|
+
attributeChange(e, t, s) {
|
|
22
|
+
if (e === "gap") {
|
|
23
|
+
const a = o(s, void 0);
|
|
24
|
+
if (a) {
|
|
25
|
+
const i = p(a) ? `${a}px` : a;
|
|
26
|
+
this.style.setProperty("--l-check-gap", i);
|
|
20
27
|
} else
|
|
21
28
|
this.style.removeProperty("--l-check-gap");
|
|
22
29
|
return;
|
|
23
30
|
}
|
|
24
31
|
}
|
|
25
32
|
connectedCallback() {
|
|
26
|
-
|
|
33
|
+
c(this), this.loadStyleText([n]), super.connectedCallback();
|
|
27
34
|
}
|
|
28
35
|
afterInit() {
|
|
29
|
-
|
|
36
|
+
u(this.root, "change", this.#e), this.updateChangedStatus();
|
|
30
37
|
}
|
|
31
38
|
beforeDestroy() {
|
|
32
|
-
|
|
39
|
+
r(this.root, "change", this.#e), this.checkedValues = [];
|
|
33
40
|
}
|
|
34
41
|
render() {
|
|
35
|
-
return
|
|
42
|
+
return h("slot");
|
|
36
43
|
}
|
|
37
44
|
#e = (e) => {
|
|
38
|
-
this.
|
|
45
|
+
e.stopPropagation(), this.updatePartChild(e.detail.value), this.setValue(e.detail.value), this.emit("change", {
|
|
39
46
|
detail: { value: [...this.checkedValues] },
|
|
40
47
|
composed: !0
|
|
41
48
|
});
|
|
42
49
|
};
|
|
43
|
-
|
|
50
|
+
updatePartChild(e) {
|
|
51
|
+
}
|
|
52
|
+
updateChecked() {
|
|
53
|
+
if (this.value)
|
|
54
|
+
if (this.multiple) {
|
|
55
|
+
const e = this.value.split("&");
|
|
56
|
+
this.checkedValues.push(...e.map((t) => decodeURIComponent(t)));
|
|
57
|
+
} else
|
|
58
|
+
this.checkedValues = [this.value];
|
|
59
|
+
else
|
|
60
|
+
this.checkedValues = [];
|
|
61
|
+
}
|
|
62
|
+
updateChangedStatus() {
|
|
63
|
+
this.updateChecked(), this.updateChildren();
|
|
64
|
+
}
|
|
65
|
+
updateChildren() {
|
|
66
|
+
const e = this.children;
|
|
67
|
+
d(e, (t) => {
|
|
68
|
+
let s = t.value || t.getAttribute("value");
|
|
69
|
+
s && (this.checkedValues.includes(s) ? t.setAttribute("checked", "") : t.removeAttribute("checked"));
|
|
70
|
+
});
|
|
44
71
|
}
|
|
45
72
|
}
|
|
46
73
|
export {
|
|
47
|
-
|
|
74
|
+
C as default
|
|
48
75
|
};
|
package/lib/check/radio.js
CHANGED
|
@@ -1,23 +1,15 @@
|
|
|
1
1
|
import e from "./check.js";
|
|
2
|
-
import { c as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
class n extends e {
|
|
2
|
+
import { c as r } from "../check-D-KVLA1z.js";
|
|
3
|
+
const c = '.l-check__inner{border-radius:50%}.l-check__inner:after{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}:host(.is-checked) .l-check__inner:after{background-color:var(--l-primary-color, #722ed1)}:host(.is-disabled) .l-check__inner{border-color:var(--l-disabled-color, #e6e6e6)}:host(.is-disabled) .l-check__inner:after{background-color:var(--l-disabled-color, #e6e6e6)}';
|
|
4
|
+
class s extends e {
|
|
6
5
|
static baseName = "radio";
|
|
7
6
|
connectedCallback() {
|
|
8
|
-
this.loadStyleText([
|
|
7
|
+
this.loadStyleText([r, c]), super.connectedCallback();
|
|
9
8
|
}
|
|
10
9
|
_doChangeAction() {
|
|
11
|
-
|
|
12
|
-
detail: {
|
|
13
|
-
value: this.value,
|
|
14
|
-
name: this.getName(),
|
|
15
|
-
checked: this.getChecked()
|
|
16
|
-
},
|
|
17
|
-
composed: !0
|
|
18
|
-
}));
|
|
10
|
+
this.setAttribute("checked", "checked"), this.emitChange();
|
|
19
11
|
}
|
|
20
12
|
}
|
|
21
13
|
export {
|
|
22
|
-
|
|
14
|
+
s as default
|
|
23
15
|
};
|
package/lib/check/radio_group.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { $one as
|
|
3
|
-
class u extends
|
|
1
|
+
import t from "./index.js";
|
|
2
|
+
import { $one as s } from "ph-utils/dom";
|
|
3
|
+
class u extends t {
|
|
4
4
|
static baseName = "radio-group";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const e = i(`l-radio[value="${this.value}"]`, this);
|
|
8
|
-
e && e.setAttribute("checked", "");
|
|
9
|
-
}
|
|
5
|
+
constructor() {
|
|
6
|
+
super(), this.multiple = !1;
|
|
10
7
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
t && t.removeAttribute("checked");
|
|
18
|
-
}
|
|
19
|
-
this.value = e;
|
|
8
|
+
setValue(e) {
|
|
9
|
+
this.checkedValues = [e], super.setValue(e);
|
|
10
|
+
}
|
|
11
|
+
updatePartChild() {
|
|
12
|
+
s(`[value="${this.value}"]`, this)?.removeAttribute("checked");
|
|
20
13
|
}
|
|
21
14
|
}
|
|
22
15
|
export {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const r = ":host{--l-check-size: 14px;display:inline-flex;align-items:center;position:relative;cursor:pointer;width:auto;transition:color .3s,border-color .3s,background-color .3s}.l-check__input{margin:0;position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-check__inner{width:var(--l-check-size, 14px);height:var(--l-check-size, 14px);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:border-color .3s ease-in-out;position:relative;margin-right:5px;flex-shrink:0}.l-check__label{transition:color .3s;cursor:inherit;line-height:1}:host(.is-checked){color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner{border-color:var(--l-primary-color, #722ed1)}:host(.is-disabled){cursor:not-allowed}:host(.is-disabled) .l-check__label{color:var(--l-disabled-color, #e6e6e6)}:host([button]){height:var(--l-form-control-height, 32px);justify-content:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0;border-radius:inherit}:host([button]:first-child){border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}:host([button]:last-child){border-top-right-radius:3px;border-bottom-right-radius:3px}:host([button].is-checked){background-color:var(--l-primary-color, #722ed1);color:#fff;border-color:var(--l-primary-color, #722ed1);border-right-color:#fff}:host([button].is-checked:last-child){border-right-color:var(--l-primary-color, #722ed1)}";
|
|
2
|
+
export {
|
|
3
|
+
r as c
|
|
4
|
+
};
|
package/lib/form/form_inner.js
CHANGED
|
@@ -49,24 +49,16 @@ class b extends n {
|
|
|
49
49
|
}
|
|
50
50
|
connectedCallback() {
|
|
51
51
|
const t = this._getForm();
|
|
52
|
-
this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (l(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), l(this.formAttrs.id, "reset", this._resetFieldValue), this._firstPushValue && this.pushValueChange()), this.formItemAttrs.id && l(
|
|
53
|
-
this.formItemAttrs.id,
|
|
54
|
-
"attributeChanged",
|
|
55
|
-
this._formAttributeChanged
|
|
56
|
-
), super.connectedCallback();
|
|
52
|
+
this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (l(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), l(this.formAttrs.id, "reset", this._resetFieldValue), this._firstPushValue && this.pushValueChange()), this.formItemAttrs.id && l(this.formItemAttrs.id, "attributeChanged", this._formAttributeChanged), super.connectedCallback();
|
|
57
53
|
}
|
|
58
54
|
disconnectedCallback() {
|
|
59
|
-
this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(
|
|
60
|
-
this.formItemAttrs.id,
|
|
61
|
-
"attributeChanged",
|
|
62
|
-
this._formAttributeChanged
|
|
63
|
-
), super.disconnectedCallback();
|
|
55
|
+
this.formAttrs.id && (u(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), u(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && u(this.formItemAttrs.id, "attributeChanged", this._formAttributeChanged), super.disconnectedCallback();
|
|
64
56
|
}
|
|
65
57
|
isDisabled() {
|
|
66
58
|
return this.disabled === !0 || this.formItemAttrs.disabled === !0 ? !0 : this.formAttrs.disabled || !1;
|
|
67
59
|
}
|
|
68
60
|
getName() {
|
|
69
|
-
return this.name ? this.name : this.formItemAttrs.name;
|
|
61
|
+
return this.name ? this.name : this.formItemAttrs.name || "";
|
|
70
62
|
}
|
|
71
63
|
_getForm() {
|
|
72
64
|
let t = this.parentElement, e = {}, s = {};
|
|
@@ -102,13 +94,7 @@ class b extends n {
|
|
|
102
94
|
}
|
|
103
95
|
pushValueChange() {
|
|
104
96
|
const t = this.getName();
|
|
105
|
-
this.formAttrs.id && t && d(
|
|
106
|
-
this.formAttrs.id,
|
|
107
|
-
"valueChange",
|
|
108
|
-
t,
|
|
109
|
-
this._value,
|
|
110
|
-
!this._reseting
|
|
111
|
-
), this._reseting = !1;
|
|
97
|
+
this.formAttrs.id && t && d(this.formAttrs.id, "valueChange", t, this._value, !this._reseting), this._reseting = !1;
|
|
112
98
|
}
|
|
113
99
|
_resetFieldValue = () => {
|
|
114
100
|
this._reseting = !0, this.reset();
|
package/lib/form/form_item.d.ts
CHANGED
|
@@ -16,9 +16,9 @@ export default class FormItem extends BaseComponent {
|
|
|
16
16
|
/** 自定义验证的正则 */
|
|
17
17
|
pattern?: string;
|
|
18
18
|
name?: string;
|
|
19
|
-
innerBlock: boolean;
|
|
20
19
|
labelPosition?: "left" | "right" | "top";
|
|
21
20
|
private formId?;
|
|
21
|
+
innerBlock?: boolean;
|
|
22
22
|
static get observedAttributes(): string[];
|
|
23
23
|
get error(): string | undefined;
|
|
24
24
|
set error(error: string | undefined);
|