litos-ui 0.8.0 → 0.10.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.js +26 -30
- package/lib/button/index.js +55 -59
- package/lib/checkbox/index.d.ts +17 -0
- package/lib/checkbox/index.js +135 -0
- package/lib/color_picker/index.js +17 -21
- package/lib/form/form_inner.js +46 -49
- package/lib/form/form_item.js +49 -54
- package/lib/form/index.js +62 -66
- 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 -25
- 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.d.ts +4 -0
- package/lib/index.js +30 -26
- package/lib/input/index.js +66 -71
- package/lib/list/index.js +23 -27
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/md_input/index.d.ts +15 -0
- package/lib/md_input/index.js +60 -0
- package/lib/polygon/index.js +14 -18
- package/lib/popconfirm/index.js +11 -14
- package/lib/popover/index.js +107 -113
- package/lib/radio/index.js +53 -57
- package/lib/select_ori/index.js +23 -27
- package/lib/switch/index.js +34 -44
- package/lib/tabbar/index.js +117 -126
- package/lib/theme/index.js +71 -74
- package/lib/theme/theme_color.js +17 -27
- package/lib/{form/form_events.d.ts → utils/event.d.ts} +5 -7
- package/lib/utils/event.js +16 -18
- package/lib/utils/index.js +21 -21
- package/lib/utils/transition.js +23 -27
- package/package.json +1 -1
- package/lib/form/form_events.js +0 -24
package/lib/base.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
constructor(
|
|
7
|
-
super();
|
|
8
|
-
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
9
|
-
n(this, "rendered", !1);
|
|
10
|
-
e && this.attachShadow({ mode: "open" });
|
|
1
|
+
import { getAttr as r } from "ph-utils/dom";
|
|
2
|
+
class a extends HTMLElement {
|
|
3
|
+
static baseName = "base-component";
|
|
4
|
+
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
5
|
+
rendered = !1;
|
|
6
|
+
constructor(t = !0) {
|
|
7
|
+
super(), t && this.attachShadow({ mode: "open" });
|
|
11
8
|
}
|
|
12
9
|
/**
|
|
13
10
|
* 返回一个数组,表示观察的属性列表
|
|
@@ -16,7 +13,7 @@ class d extends HTMLElement {
|
|
|
16
13
|
return [];
|
|
17
14
|
}
|
|
18
15
|
// 当属性发生变化时调用的回调函数
|
|
19
|
-
attributeChangedCallback(
|
|
16
|
+
attributeChangedCallback(t, e, n) {
|
|
20
17
|
}
|
|
21
18
|
get shadow() {
|
|
22
19
|
return this.shadowRoot;
|
|
@@ -24,27 +21,27 @@ class d extends HTMLElement {
|
|
|
24
21
|
get root() {
|
|
25
22
|
return this.shadowRoot || this;
|
|
26
23
|
}
|
|
27
|
-
createStyle(
|
|
28
|
-
const
|
|
29
|
-
|
|
24
|
+
createStyle(t) {
|
|
25
|
+
const e = document.createElement("style");
|
|
26
|
+
e.textContent = t.trim(), this.root.appendChild(e);
|
|
30
27
|
}
|
|
31
|
-
createLink(
|
|
32
|
-
const
|
|
33
|
-
|
|
28
|
+
createLink(t) {
|
|
29
|
+
const e = document.createElement("link");
|
|
30
|
+
e.rel = "stylesheet", e.href = t, this.root.appendChild(e);
|
|
34
31
|
}
|
|
35
|
-
loadStyleText(
|
|
36
|
-
let
|
|
37
|
-
Array.isArray(
|
|
32
|
+
loadStyleText(t) {
|
|
33
|
+
let e = t;
|
|
34
|
+
Array.isArray(e) && (e = e.join("")), this.createStyle(e);
|
|
38
35
|
}
|
|
39
|
-
getAttr(
|
|
40
|
-
return
|
|
36
|
+
getAttr(t, e) {
|
|
37
|
+
return r(this, t, e);
|
|
41
38
|
}
|
|
42
|
-
appendToRoot(
|
|
43
|
-
if (
|
|
44
|
-
if (typeof
|
|
45
|
-
let
|
|
46
|
-
|
|
47
|
-
} else
|
|
39
|
+
appendToRoot(t) {
|
|
40
|
+
if (t)
|
|
41
|
+
if (typeof t == "string") {
|
|
42
|
+
let e = document.createElement("div");
|
|
43
|
+
e.innerHTML = t, this.root.append(...e.children), e = void 0;
|
|
44
|
+
} else t.length ? this.root.append(...t) : this.root.append(t);
|
|
48
45
|
}
|
|
49
46
|
connectedCallback() {
|
|
50
47
|
this.appendToRoot(this.render()), this.rendered = !0;
|
|
@@ -55,7 +52,6 @@ class d extends HTMLElement {
|
|
|
55
52
|
render() {
|
|
56
53
|
}
|
|
57
54
|
}
|
|
58
|
-
n(d, "baseName", "base-component");
|
|
59
55
|
export {
|
|
60
|
-
|
|
56
|
+
a as default
|
|
61
57
|
};
|
package/lib/button/index.js
CHANGED
|
@@ -1,95 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class B extends f {
|
|
1
|
+
import { initAttr as s, parseAttrValue as c } from "../utils/index.js";
|
|
2
|
+
import d from "../base.js";
|
|
3
|
+
import { $one as h, addClass as g, removeClass as p, on as v, off as f, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
|
|
4
|
+
import { adjust as b } from "ph-utils/color";
|
|
5
|
+
import { a as x } from "../animation-DttknHkX.js";
|
|
6
|
+
const y = ":host{--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;display:inline-block;width:auto}.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:0 15px;line-height:1;height:var(--l-form-edit-height, 32px);border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;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:not(.l-btn-loading):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-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;height:auto;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-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn-block{width:100%}.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
|
+
class w extends d {
|
|
8
|
+
static baseName = "button";
|
|
9
|
+
htmlType = "button";
|
|
11
10
|
constructor() {
|
|
12
|
-
super();
|
|
13
|
-
i(this, "htmlType", "button");
|
|
14
|
-
i(this, "_handleClick", (t) => {
|
|
15
|
-
const r = t.target, o = T(r, "html-type");
|
|
16
|
-
if (o === "reset" || o === "submit") {
|
|
17
|
-
const l = this._getForm();
|
|
18
|
-
l && (o === "reset" ? l.reset() : o === "submit" && l.submit());
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
p(this);
|
|
11
|
+
super(), s(this);
|
|
22
12
|
}
|
|
23
13
|
// 初始化属性观察器
|
|
24
14
|
static get observedAttributes() {
|
|
25
15
|
return ["loading", "color", "disabled"];
|
|
26
16
|
}
|
|
27
17
|
// 当属性发生变化时调用的回调函数
|
|
28
|
-
attributeChangedCallback(
|
|
29
|
-
const l =
|
|
18
|
+
attributeChangedCallback(r, t, o) {
|
|
19
|
+
const l = h(".l-btn", this.root);
|
|
30
20
|
if (l)
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
else if (
|
|
34
|
-
const e = this.getAttr("text", !1),
|
|
35
|
-
l.style.cssText = this.applyColor(o, e,
|
|
36
|
-
} else
|
|
21
|
+
if (r === "loading")
|
|
22
|
+
c(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (p(l, "l-btn-loading"), l.disabled = this.getAttr("disabled", !1), l.innerHTML = "<slot></slot>");
|
|
23
|
+
else if (r === "color") {
|
|
24
|
+
const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
|
|
25
|
+
l.style.cssText = this.applyColor(o, e, n);
|
|
26
|
+
} else r === "disabled" && (l.disabled = this.getAttr("disabled", !1));
|
|
37
27
|
}
|
|
38
28
|
connectedCallback() {
|
|
39
|
-
this.loadStyleText([
|
|
29
|
+
this.loadStyleText([y, x]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
|
|
40
30
|
}
|
|
41
31
|
disconnectedCallback() {
|
|
42
|
-
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") &&
|
|
32
|
+
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && f(this, "click", this._handleClick);
|
|
43
33
|
}
|
|
44
34
|
render() {
|
|
45
|
-
const
|
|
35
|
+
const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), i = [
|
|
46
36
|
"l-btn",
|
|
47
|
-
`l-btn-${
|
|
37
|
+
`l-btn-${r}`,
|
|
48
38
|
this.getAttr("block", !1) ? "l-btn-block" : "",
|
|
49
39
|
l === "round" ? "l-btn-round" : "",
|
|
50
40
|
l === "circle" ? "l-btn-circle" : "",
|
|
51
|
-
|
|
41
|
+
n ? "l-btn-ghost" : "",
|
|
52
42
|
e ? "l-btn-text" : "",
|
|
53
43
|
o ? "l-btn-loading" : ""
|
|
54
44
|
];
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
45
|
+
t.className = u(i), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
|
|
46
|
+
const a = this.applyColor(this.getAttr("color"), e, n);
|
|
47
|
+
a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
|
|
58
48
|
}
|
|
59
49
|
loadingBody() {
|
|
60
|
-
const
|
|
61
|
-
return
|
|
50
|
+
const r = this.getAttr("loading-text", ""), t = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
51
|
+
return r === "" ? t.push("<slot></slot>") : t.push(`<span>${r}</span>`), t.join("");
|
|
62
52
|
}
|
|
63
|
-
applyColor(
|
|
64
|
-
if (!
|
|
65
|
-
const l =
|
|
66
|
-
return
|
|
67
|
-
"--l-btn-border-color":
|
|
68
|
-
"--l-btn-text-color": o ||
|
|
69
|
-
"--l-btn-hover-text-color": o ||
|
|
70
|
-
"--l-btn-background": o ||
|
|
71
|
-
"--l-btn-active-text-color": o ||
|
|
72
|
-
"--l-btn-hover-border-color":
|
|
73
|
-
"--l-btn-hover-background": o ||
|
|
74
|
-
"--l-btn-active-background": o ||
|
|
75
|
-
"--l-btn-active-border-color":
|
|
53
|
+
applyColor(r, t = !1, o = !1) {
|
|
54
|
+
if (!r) return "";
|
|
55
|
+
const l = b(r, 1, !0), e = b(r, 3, !1);
|
|
56
|
+
return m({
|
|
57
|
+
"--l-btn-border-color": t ? "transparent" : r,
|
|
58
|
+
"--l-btn-text-color": o || t ? r : "#ffffff",
|
|
59
|
+
"--l-btn-hover-text-color": o || t ? l : "#ffffff",
|
|
60
|
+
"--l-btn-background": o || t ? "transparent" : r,
|
|
61
|
+
"--l-btn-active-text-color": o || t ? e : "#ffffff",
|
|
62
|
+
"--l-btn-hover-border-color": t ? "transparent" : l,
|
|
63
|
+
"--l-btn-hover-background": o || t ? "transparent" : l,
|
|
64
|
+
"--l-btn-active-background": o || t ? "transparent" : e,
|
|
65
|
+
"--l-btn-active-border-color": t ? "transparent" : e
|
|
76
66
|
});
|
|
77
67
|
}
|
|
68
|
+
_handleClick = (r) => {
|
|
69
|
+
const t = r.target, o = k(t, "html-type");
|
|
70
|
+
if (o === "reset" || o === "submit") {
|
|
71
|
+
const l = this._getForm();
|
|
72
|
+
l && (o === "reset" ? l.reset() : o === "submit" && l.submit());
|
|
73
|
+
}
|
|
74
|
+
};
|
|
78
75
|
_getForm() {
|
|
79
|
-
let
|
|
80
|
-
for (;
|
|
81
|
-
const o =
|
|
76
|
+
let r = this.parentElement, t;
|
|
77
|
+
for (; r != null; ) {
|
|
78
|
+
const o = r.tagName;
|
|
82
79
|
if (o === "L-FORM") {
|
|
83
|
-
|
|
80
|
+
t = r;
|
|
84
81
|
break;
|
|
85
82
|
}
|
|
86
83
|
if (o === "BODY") break;
|
|
87
|
-
|
|
84
|
+
r = r.parentElement;
|
|
88
85
|
}
|
|
89
|
-
return
|
|
86
|
+
return r = null, t;
|
|
90
87
|
}
|
|
91
88
|
}
|
|
92
|
-
i(B, "baseName", "button");
|
|
93
89
|
export {
|
|
94
|
-
|
|
90
|
+
w as default
|
|
95
91
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
export default class Checkbox extends FormInner {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
type?: "button";
|
|
6
|
+
checked: boolean;
|
|
7
|
+
label?: string;
|
|
8
|
+
indeterminate: boolean;
|
|
9
|
+
_ignoreInitAttrs: string[];
|
|
10
|
+
constructor();
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
disconnectedCallback(): void;
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
protected attributeChange(name: string, oldValue: string, newValue: string): void;
|
|
15
|
+
render(): DocumentFragment;
|
|
16
|
+
setValue(value: boolean | string[]): void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { initAttr as f, parseAttrValue as m } from "../utils/index.js";
|
|
2
|
+
import v from "../form/form_inner.js";
|
|
3
|
+
import { random as x, isBlank as _ } from "ph-utils";
|
|
4
|
+
import { $one as i, addClass as a, removeClass as s, $ as n, iterate as h, getAttr as d, $$ as b, on as g, off as C } from "ph-utils/dom";
|
|
5
|
+
const $ = ':host{--l-checkbox-size: 16px;--l-checkbox-label-color: #333;--l-checkbox-checked-color: var(--l-primary-color, #722ed1);--l-checkbox-disabled-color: #e6e6e6;--l-checkbox-disabled-label-color: #c0c4cc;--l-checkbox-item-margin: 10px;display:inline-flex;align-items:center}.l-checkbox{display:inline-flex;align-items:center;cursor:pointer}.l-checkbox__input{opacity:0;width:0;height:0;position:absolute;z-index:-1}.l-checkbox__label{color:var(--l-checkbox-label-color);transition:color .3s ease-in-out;margin-left:5px;line-height:1}.l-checkbox__inner{width:var(--l-checkbox-size);height:var(--l-checkbox-size);display:flex;justify-content:center;align-items:center;border-radius:3px;border:1px solid #dcddd9;box-sizing:border-box;transition:all .3s ease-in-out;position:relative}.l-checkbox__inner:after{content:"";width:calc(var(--l-checkbox-size) * .6);height:calc(var(--l-checkbox-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}.l-checkbox--indeterminate .l-checkbox__inner{background-color:var(--l-checkbox-checked-color)}.l-checkbox--indeterminate .l-checkbox__inner:before{content:"";width:calc(var(--l-checkbox-size) * .4);height:1px;display:block;border:solid 1px #fff;border-right:none;border-top:none;border-left:none;position:absolute}.l-checkbox:hover .l-checkbox__inner{border-color:var(--l-checkbox-checked-color)}.l-checkbox__input:checked+.l-checkbox__inner{background-color:var(--l-checkbox-checked-color)}.l-checkbox__input:checked+.l-checkbox__inner:after{border-color:#fff}.l-checkbox__input:checked~.l-checkbox__label{color:var(--l-checkbox-checked-color)}.l-checkbox--disabled{--l-checkbox-checked-color: var(--l-checkbox-disabled-color);cursor:not-allowed}.l-checkbox--disabled .l-checkbox__inner{border-color:var(--l-checkbox-disabled-color)}.l-checkbox--disabled .l-checkbox__inner:after{border-color:transparent}.l-checkbox--disabled .l-checkbox__label{color:var(--l-checkbox-disabled-label-color)}.l-checkbox+.l-checkbox{margin-left:var(--l-checkbox-item-margin)}.l-checkbox--button .l-checkbox__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-checkbox--button:first-child .l-checkbox__label{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.l-checkbox--button:last-child .l-checkbox__label{border-top-right-radius:3px;border-bottom-right-radius:3px}.l-checkbox--button .l-checkbox__input:checked~.l-checkbox__label{background-color:var(--l-checkbox-checked-color);color:#fff;border-top-color:var(--l-checkbox-checked-color);border-bottom-color:var(--l-checkbox-checked-color);border-right-color:#fff}';
|
|
6
|
+
class N extends v {
|
|
7
|
+
static baseName = "checkbox";
|
|
8
|
+
type;
|
|
9
|
+
checked = !1;
|
|
10
|
+
label;
|
|
11
|
+
indeterminate = !1;
|
|
12
|
+
_ignoreInitAttrs = ["value"];
|
|
13
|
+
constructor() {
|
|
14
|
+
super(!1);
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
f(this), this.loadStyleText($), this.getName() || (this.name = `la${x(3)}_${x(6)}`), super.connectedCallback(), this.#o();
|
|
18
|
+
}
|
|
19
|
+
disconnectedCallback() {
|
|
20
|
+
super.disconnectedCallback(), this.#t();
|
|
21
|
+
}
|
|
22
|
+
static get observedAttributes() {
|
|
23
|
+
return ["disabled", "value", "indeterminate"];
|
|
24
|
+
}
|
|
25
|
+
attributeChange(e, c, l) {
|
|
26
|
+
if (e === "indeterminate") {
|
|
27
|
+
this.indeterminate = m(l, !1);
|
|
28
|
+
const o = i("label[l-value]", this.root);
|
|
29
|
+
o && (this.indeterminate ? a(o, "l-checkbox--indeterminate") : s(o, "l-checkbox--indeterminate"));
|
|
30
|
+
} else if (e === "value") {
|
|
31
|
+
const o = l.split("&").map((t) => decodeURIComponent(t));
|
|
32
|
+
this.setValue(o);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
render() {
|
|
36
|
+
const e = document.createDocumentFragment(), c = i('[slot="label"]', this), l = n("[check-value]", this);
|
|
37
|
+
return c || this.label ? (this.value = this.checked, c ? e.appendChild(
|
|
38
|
+
this.#e("slot", void 0, this.checked, "label")
|
|
39
|
+
) : e.appendChild(
|
|
40
|
+
this.#e(
|
|
41
|
+
this.label,
|
|
42
|
+
void 0,
|
|
43
|
+
this.checked,
|
|
44
|
+
"label"
|
|
45
|
+
)
|
|
46
|
+
)) : l.length > 0 && (this.#l(), h(l, (o) => {
|
|
47
|
+
const t = o.cloneNode(!0), r = d(o, "check-value");
|
|
48
|
+
e.appendChild(
|
|
49
|
+
this.#e(
|
|
50
|
+
t.outerHTML,
|
|
51
|
+
r,
|
|
52
|
+
this.value.includes(r)
|
|
53
|
+
)
|
|
54
|
+
);
|
|
55
|
+
})), e;
|
|
56
|
+
}
|
|
57
|
+
#e(e, c, l = !1, o = void 0) {
|
|
58
|
+
const t = b("label", {
|
|
59
|
+
class: {
|
|
60
|
+
"l-checkbox": !0,
|
|
61
|
+
"l-checkbox--button": this.type === "button",
|
|
62
|
+
"is-checked": l,
|
|
63
|
+
"l-checkbox--disabled": this.isDisabled(),
|
|
64
|
+
"l-checkbox--indeterminate": this.indeterminate
|
|
65
|
+
},
|
|
66
|
+
"l-value": c
|
|
67
|
+
}), r = b("input", {
|
|
68
|
+
class: "l-checkbox__input",
|
|
69
|
+
type: "checkbox",
|
|
70
|
+
name: this.getName(),
|
|
71
|
+
value: c,
|
|
72
|
+
checked: l,
|
|
73
|
+
disabled: this.isDisabled()
|
|
74
|
+
});
|
|
75
|
+
if (t.appendChild(r), this.type !== "button") {
|
|
76
|
+
const u = b("span", {
|
|
77
|
+
class: "l-checkbox__inner"
|
|
78
|
+
});
|
|
79
|
+
t.appendChild(u);
|
|
80
|
+
}
|
|
81
|
+
let p = e === "slot" ? '<slot name="label"></slot>' : e;
|
|
82
|
+
const k = b("div", {
|
|
83
|
+
class: "l-checkbox__label",
|
|
84
|
+
part: o
|
|
85
|
+
});
|
|
86
|
+
return k.innerHTML = p, t.appendChild(k), t;
|
|
87
|
+
}
|
|
88
|
+
setValue(e) {
|
|
89
|
+
if (super.setValue(e), typeof e == "boolean") {
|
|
90
|
+
const c = i("label", this.root);
|
|
91
|
+
c && (this.checked ? a(c, "is-checked") : s(c, "is-checked"));
|
|
92
|
+
} else {
|
|
93
|
+
const c = n("label[l-value]", this.root);
|
|
94
|
+
h(c, (l) => {
|
|
95
|
+
const o = d(l, "l-value");
|
|
96
|
+
e.includes(o) ? a(l, "is-checked") : s(l, "is-checked");
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
#l() {
|
|
101
|
+
const e = d(this, "value");
|
|
102
|
+
let c = [];
|
|
103
|
+
this.hasAttribute("checked") && (c = this.checked), _(e) || (c = e.split("&").map((l) => decodeURIComponent(l))), this._resetValue = c, this.value = c;
|
|
104
|
+
}
|
|
105
|
+
#c = (e) => {
|
|
106
|
+
const c = e.target;
|
|
107
|
+
let l;
|
|
108
|
+
if (typeof this.value == "boolean")
|
|
109
|
+
this.value = c.checked, l = i("label", this.root);
|
|
110
|
+
else {
|
|
111
|
+
const o = c.value;
|
|
112
|
+
if (c.checked)
|
|
113
|
+
this.value.push(o);
|
|
114
|
+
else {
|
|
115
|
+
const t = this.value.indexOf(o);
|
|
116
|
+
t > -1 && this.value.splice(t, t);
|
|
117
|
+
}
|
|
118
|
+
this.pushValueChange(), l = i(`label[l-value="${o}"]`, this.root);
|
|
119
|
+
}
|
|
120
|
+
l && (c.checked ? a(l, "is-checked") : s(l, "is-checked"));
|
|
121
|
+
};
|
|
122
|
+
#o() {
|
|
123
|
+
h(n("input", this.root), (e) => {
|
|
124
|
+
g(e, "change", this.#c);
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
#t() {
|
|
128
|
+
h(n("input", this.root), (e) => {
|
|
129
|
+
C(e, "change", this.#c);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
N as default
|
|
135
|
+
};
|
|
@@ -1,34 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { $one as i, on as s, off as a } from "ph-utils/dom";
|
|
2
|
+
import c from "../form/form_inner.js";
|
|
3
|
+
import { initAttr as r, setAttrs as n } from "../utils/index.js";
|
|
4
|
+
import { i as l } from "../index-391POYEJ.js";
|
|
5
|
+
const o = ":host{--l-input-width: 60px}";
|
|
6
|
+
class m extends c {
|
|
7
|
+
static baseName = "color-picker";
|
|
8
|
+
$picker;
|
|
9
|
+
_value = "#000000";
|
|
10
10
|
constructor() {
|
|
11
|
-
super();
|
|
12
|
-
s(this, "$picker");
|
|
13
|
-
s(this, "_value", "#000000");
|
|
14
|
-
s(this, "_handleChange", (e) => {
|
|
15
|
-
const a = e.target.value;
|
|
16
|
-
super.setValue(a), this.dispatchEvent(new CustomEvent("change", { detail: a }));
|
|
17
|
-
});
|
|
18
|
-
p(this);
|
|
11
|
+
super(), r(this);
|
|
19
12
|
}
|
|
20
13
|
setValue(e) {
|
|
21
14
|
super.setValue(e), this.$picker && (this.$picker.value = e);
|
|
22
15
|
}
|
|
23
16
|
connectedCallback() {
|
|
24
|
-
this.loadStyleText([
|
|
17
|
+
this.loadStyleText([l, o]), super.connectedCallback(), this.$picker = i("input", this.root), s(this.$picker, "change", this._handleChange);
|
|
25
18
|
}
|
|
26
19
|
disconnectedCallback() {
|
|
27
|
-
super.disconnectedCallback(), this.$picker && (
|
|
20
|
+
super.disconnectedCallback(), this.$picker && (a(this.$picker, "change", this._handleChange), this.$picker = void 0);
|
|
28
21
|
}
|
|
29
22
|
render() {
|
|
30
23
|
const e = document.createElement("input");
|
|
31
|
-
return
|
|
24
|
+
return n(e, [
|
|
32
25
|
["value", this.value],
|
|
33
26
|
["disabled", this.isDisabled()],
|
|
34
27
|
["name", this.getName()],
|
|
@@ -39,8 +32,11 @@ class m extends h {
|
|
|
39
32
|
_changeDisabled() {
|
|
40
33
|
this.$picker && (this.$picker.disabled = this.isDisabled());
|
|
41
34
|
}
|
|
35
|
+
_handleChange = (e) => {
|
|
36
|
+
const t = e.target.value;
|
|
37
|
+
super.setValue(t), this.dispatchEvent(new CustomEvent("change", { detail: t }));
|
|
38
|
+
};
|
|
42
39
|
}
|
|
43
|
-
s(m, "baseName", "color-picker");
|
|
44
40
|
export {
|
|
45
41
|
m as default
|
|
46
42
|
};
|
package/lib/form/form_inner.js
CHANGED
|
@@ -1,31 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import d from "../base.js";
|
|
2
|
+
import { parseAttrValue as u } from "../utils/index.js";
|
|
3
|
+
import { add as l, remove as n, emit as o } from "../utils/event.js";
|
|
4
|
+
class b extends d {
|
|
5
|
+
disabled = !1;
|
|
6
|
+
name = void 0;
|
|
7
|
+
formAttrs = {};
|
|
8
|
+
formItemAttrs = {};
|
|
9
|
+
_value = "";
|
|
10
|
+
_resetValue;
|
|
11
|
+
_firstPushValue = !0;
|
|
12
|
+
_reseting = !1;
|
|
8
13
|
/**
|
|
9
14
|
*
|
|
10
15
|
* @param firstPushValue 是否第一次赋值 value 时, 推送数据到 Form, 默认: true
|
|
11
16
|
*/
|
|
12
17
|
constructor(t = !0) {
|
|
13
|
-
super();
|
|
14
|
-
e(this, "disabled", !1);
|
|
15
|
-
e(this, "name");
|
|
16
|
-
e(this, "formAttrs", {});
|
|
17
|
-
e(this, "formItemAttrs", {});
|
|
18
|
-
e(this, "_value", "");
|
|
19
|
-
e(this, "_resetValue");
|
|
20
|
-
e(this, "_firstPushValue", !0);
|
|
21
|
-
e(this, "_reseting", !1);
|
|
22
|
-
e(this, "_formAttributeChanged", (t, r, i) => {
|
|
23
|
-
i === this.formAttrs.formId ? this.formAttrs[t] = r : this.formItemAttrs[t] = r, t === "disabled" && this._changeDisabled();
|
|
24
|
-
});
|
|
25
|
-
e(this, "_resetFieldValue", () => {
|
|
26
|
-
this._reseting = !0, this.reset();
|
|
27
|
-
});
|
|
28
|
-
this._firstPushValue = t;
|
|
18
|
+
super(), this._firstPushValue = t;
|
|
29
19
|
}
|
|
30
20
|
set value(t) {
|
|
31
21
|
this.setValue(t);
|
|
@@ -42,25 +32,26 @@ class p extends A {
|
|
|
42
32
|
static get observedAttributes() {
|
|
43
33
|
return ["disabled"];
|
|
44
34
|
}
|
|
45
|
-
attributeChangedCallback(t,
|
|
46
|
-
if (
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
35
|
+
attributeChangedCallback(t, e, r) {
|
|
36
|
+
if (this.rendered)
|
|
37
|
+
if (t === "disabled") {
|
|
38
|
+
const i = u(r, !1, t);
|
|
39
|
+
i !== this.disabled && (this._changeDisabled(), this.disabled = i);
|
|
40
|
+
} else
|
|
41
|
+
this.attributeChange(t, e, r);
|
|
51
42
|
}
|
|
52
|
-
attributeChange(t,
|
|
43
|
+
attributeChange(t, e, r) {
|
|
53
44
|
}
|
|
54
45
|
connectedCallback() {
|
|
55
46
|
const t = this._getForm();
|
|
56
|
-
this.formAttrs = t.formAttr, this.formItemAttrs = t.formItemAttr, this.formAttrs.id && (
|
|
47
|
+
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(
|
|
57
48
|
this.formItemAttrs.id,
|
|
58
49
|
"attributeChanged",
|
|
59
50
|
this._formAttributeChanged
|
|
60
51
|
), super.connectedCallback();
|
|
61
52
|
}
|
|
62
53
|
disconnectedCallback() {
|
|
63
|
-
this.formAttrs.id && (
|
|
54
|
+
this.formAttrs.id && (n(this.formAttrs.id, "attributeChanged", this._formAttributeChanged), n(this.formAttrs.id, "reset", this._resetFieldValue)), this.formItemAttrs.id && n(
|
|
64
55
|
this.formItemAttrs.id,
|
|
65
56
|
"attributeChanged",
|
|
66
57
|
this._formAttributeChanged
|
|
@@ -73,38 +64,41 @@ class p extends A {
|
|
|
73
64
|
return this.name ? this.name : this.formItemAttrs.name;
|
|
74
65
|
}
|
|
75
66
|
_getForm() {
|
|
76
|
-
let t = this.parentElement,
|
|
67
|
+
let t = this.parentElement, e = {}, r = {};
|
|
77
68
|
for (; t != null; ) {
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
for (let
|
|
82
|
-
const
|
|
83
|
-
|
|
69
|
+
const i = t.tagName;
|
|
70
|
+
if (i === "L-FORM") {
|
|
71
|
+
const a = t.sharedAttrs;
|
|
72
|
+
for (let s = 0; s < a.length; s++) {
|
|
73
|
+
const h = a[s];
|
|
74
|
+
e[h] = t[h];
|
|
84
75
|
}
|
|
85
76
|
break;
|
|
86
77
|
}
|
|
87
|
-
if (
|
|
88
|
-
if (
|
|
89
|
-
const
|
|
90
|
-
for (let
|
|
91
|
-
const
|
|
92
|
-
|
|
78
|
+
if (i === "BODY") break;
|
|
79
|
+
if (i === "L-FORM-ITEM") {
|
|
80
|
+
const a = t.sharedAttrs;
|
|
81
|
+
for (let s = 0; s < a.length; s++) {
|
|
82
|
+
const h = a[s];
|
|
83
|
+
r[h] = t[h];
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
86
|
t = t.parentElement;
|
|
96
87
|
}
|
|
97
88
|
return t = null, {
|
|
98
|
-
formAttr:
|
|
99
|
-
formItemAttr:
|
|
89
|
+
formAttr: e,
|
|
90
|
+
formItemAttr: r
|
|
100
91
|
};
|
|
101
92
|
}
|
|
93
|
+
_formAttributeChanged = (t, e, r) => {
|
|
94
|
+
r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this._changeDisabled();
|
|
95
|
+
};
|
|
102
96
|
/** disable 属性改变时回调 */
|
|
103
97
|
_changeDisabled() {
|
|
104
98
|
}
|
|
105
99
|
pushValueChange() {
|
|
106
100
|
const t = this.getName();
|
|
107
|
-
this.formAttrs.id && t &&
|
|
101
|
+
this.formAttrs.id && t && o(
|
|
108
102
|
this.formAttrs.id,
|
|
109
103
|
"valueChange",
|
|
110
104
|
t,
|
|
@@ -112,10 +106,13 @@ class p extends A {
|
|
|
112
106
|
!this._reseting
|
|
113
107
|
), this._reseting = !1;
|
|
114
108
|
}
|
|
109
|
+
_resetFieldValue = () => {
|
|
110
|
+
this._reseting = !0, this.reset();
|
|
111
|
+
};
|
|
115
112
|
reset() {
|
|
116
113
|
this.value = this._resetValue || "";
|
|
117
114
|
}
|
|
118
115
|
}
|
|
119
116
|
export {
|
|
120
|
-
|
|
117
|
+
b as default
|
|
121
118
|
};
|