litos-ui 0.6.3 → 0.8.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 +12 -40
- package/lib/button/index.js +49 -49
- package/lib/color_picker/index.js +6 -4
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +26 -25
- package/lib/form/index.d.ts +1 -1
- package/lib/form/index.js +42 -41
- package/lib/icon/base.js +19 -18
- package/lib/{index-B_9rPBWp.js → index-391POYEJ.js} +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +64 -62
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +16 -15
- package/lib/list/index.d.ts +1 -1
- package/lib/list/index.js +13 -13
- 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 +17 -16
- package/lib/popconfirm/index.d.ts +7 -0
- package/lib/popconfirm/index.js +33 -0
- package/lib/popover/index.d.ts +5 -2
- package/lib/popover/index.js +106 -97
- package/lib/radio/index.d.ts +2 -2
- package/lib/radio/index.js +69 -68
- package/lib/select_ori/index.d.ts +1 -1
- package/lib/select_ori/index.js +8 -8
- package/lib/switch/index.js +42 -41
- package/lib/tabbar/index.js +94 -92
- package/lib/theme/index.js +39 -39
- package/lib/utils/index.js +54 -54
- package/lib/utils/transition.js +5 -6
- package/package.json +4 -1
- package/lib/browser.d.ts +0 -16
- 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-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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const a = "@keyframes l-rotate-frame{0%{transform:rotate3d(0,0,1,0)}to{transform:rotate3d(0,0,1,360deg)}}.l-rotate-anim{animation:l-rotate-frame 1.5s infinite linear}";
|
|
2
2
|
export {
|
|
3
|
-
|
|
3
|
+
a
|
|
4
4
|
};
|
package/lib/base.d.ts
CHANGED
|
@@ -12,9 +12,7 @@ export default class BaseComponent extends HTMLElement {
|
|
|
12
12
|
get root(): ShadowRoot | HTMLElement;
|
|
13
13
|
createStyle(text: string): void;
|
|
14
14
|
createLink(href: string): void;
|
|
15
|
-
|
|
16
|
-
loadExternalStyle(styleNames: string[]): void;
|
|
17
|
-
loadStyleText(styleText: string): void;
|
|
15
|
+
loadStyleText(styleText: string | string[]): void;
|
|
18
16
|
/**
|
|
19
17
|
* 获取属性值
|
|
20
18
|
* @param key 属性名称
|
package/lib/base.js
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { getAttr as
|
|
5
|
-
|
|
6
|
-
const t = o[n];
|
|
7
|
-
return t ? typeof t == "function" ? t() : Promise.resolve(t) : new Promise((s, i) => {
|
|
8
|
-
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
9
|
-
i.bind(
|
|
10
|
-
null,
|
|
11
|
-
new Error(
|
|
12
|
-
"Unknown variable dynamic import: " + n + (n.split("/").length !== e ? ". Note that variables only represent file names one level deep." : "")
|
|
13
|
-
)
|
|
14
|
-
)
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
};
|
|
18
|
-
class m extends HTMLElement {
|
|
1
|
+
var s = Object.defineProperty;
|
|
2
|
+
var a = (o, r, e) => r in o ? s(o, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[r] = e;
|
|
3
|
+
var n = (o, r, e) => a(o, typeof r != "symbol" ? r + "" : r, e);
|
|
4
|
+
import { getAttr as i } from "ph-utils/dom";
|
|
5
|
+
class d extends HTMLElement {
|
|
19
6
|
constructor(e = !0) {
|
|
20
7
|
super();
|
|
21
8
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
22
|
-
|
|
9
|
+
n(this, "rendered", !1);
|
|
23
10
|
e && this.attachShadow({ mode: "open" });
|
|
24
11
|
}
|
|
25
12
|
/**
|
|
@@ -29,7 +16,7 @@ class m extends HTMLElement {
|
|
|
29
16
|
return [];
|
|
30
17
|
}
|
|
31
18
|
// 当属性发生变化时调用的回调函数
|
|
32
|
-
attributeChangedCallback(e, t,
|
|
19
|
+
attributeChangedCallback(e, t, l) {
|
|
33
20
|
}
|
|
34
21
|
get shadow() {
|
|
35
22
|
return this.shadowRoot;
|
|
@@ -45,27 +32,12 @@ class m extends HTMLElement {
|
|
|
45
32
|
const t = document.createElement("link");
|
|
46
33
|
t.rel = "stylesheet", t.href = e, this.root.appendChild(t);
|
|
47
34
|
}
|
|
48
|
-
loadStyle(e) {
|
|
49
|
-
for (let t = 0, s = e.length; t < s; t++) {
|
|
50
|
-
const i = e[t];
|
|
51
|
-
a(/* @__PURE__ */ Object.assign({ "./button/index.less": () => import("./index-Bl8lRTJd.js"), "./color_picker/index.less": () => import("./index-BeOxuMd4.js"), "./form/index.less": () => import("./index-BxlGVrX3.js"), "./icon/index.less": () => import("./index-oNjb_IVt.js"), "./input/index.less": () => import("./index-B_9rPBWp.js"), "./list/index.less": () => import("./index-D-Ikkdx0.js"), "./polygon/index.less": () => import("./index-CMz7GCCH.js"), "./popover/index.less": () => import("./index-BUyxD_nH.js"), "./radio/index.less": () => import("./index-CCcVpk6U.js"), "./select_ori/index.less": () => import("./index-C98Kx857.js"), "./switch/index.less": () => import("./index-116dRdDj.js"), "./tabbar/index.less": () => import("./index-DKvzJmsR.js"), "./theme/index.less": () => import("./index-DJ70Xyma.js") }), `./${i}/index.less`, 3).then((r) => {
|
|
52
|
-
this.createStyle(r.default);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
loadExternalStyle(e) {
|
|
57
|
-
for (let t = 0, s = e.length; t < s; t++) {
|
|
58
|
-
const i = e[t];
|
|
59
|
-
a(/* @__PURE__ */ Object.assign({ "./styles/animation.css": () => import("./animation-QfX4RtqD.js") }), `./styles/${i}.css`, 3).then((r) => {
|
|
60
|
-
this.createStyle(r.default);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
35
|
loadStyleText(e) {
|
|
65
|
-
|
|
36
|
+
let t = e;
|
|
37
|
+
Array.isArray(t) && (t = t.join("")), this.createStyle(t);
|
|
66
38
|
}
|
|
67
39
|
getAttr(e, t) {
|
|
68
|
-
return
|
|
40
|
+
return i(this, e, t);
|
|
69
41
|
}
|
|
70
42
|
appendToRoot(e) {
|
|
71
43
|
if (e)
|
|
@@ -83,7 +55,7 @@ class m extends HTMLElement {
|
|
|
83
55
|
render() {
|
|
84
56
|
}
|
|
85
57
|
}
|
|
86
|
-
|
|
58
|
+
n(d, "baseName", "base-component");
|
|
87
59
|
export {
|
|
88
|
-
|
|
60
|
+
d as default
|
|
89
61
|
};
|
package/lib/button/index.js
CHANGED
|
@@ -1,95 +1,95 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (a,
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { $one as
|
|
7
|
-
import L from "../icon/loading.js";
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var g = (a, n, t) => n in a ? h(a, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[n] = t;
|
|
3
|
+
var i = (a, n, t) => g(a, typeof n != "symbol" ? n + "" : n, t);
|
|
4
|
+
import { initAttr as p, parseAttrValue as v } from "../utils/index.js";
|
|
5
|
+
import f from "../base.js";
|
|
6
|
+
import { $one as u, addClass as m, removeClass as k, on as x, off as y, formatClass as A, formatStyle as C, getAttr as T } from "ph-utils/dom";
|
|
8
7
|
import { adjust as c } from "ph-utils/color";
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { a as $ } from "../animation-DttknHkX.js";
|
|
9
|
+
const L = ":host{display:inline-flex}: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}.l-btn{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)}";
|
|
10
|
+
class B extends f {
|
|
11
11
|
constructor() {
|
|
12
12
|
super();
|
|
13
13
|
i(this, "htmlType", "button");
|
|
14
14
|
i(this, "_handleClick", (t) => {
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
15
|
+
const r = t.target, o = T(r, "html-type");
|
|
16
|
+
if (o === "reset" || o === "submit") {
|
|
17
17
|
const l = this._getForm();
|
|
18
|
-
l && (
|
|
18
|
+
l && (o === "reset" ? l.reset() : o === "submit" && l.submit());
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
|
|
21
|
+
p(this);
|
|
22
22
|
}
|
|
23
23
|
// 初始化属性观察器
|
|
24
24
|
static get observedAttributes() {
|
|
25
25
|
return ["loading", "color", "disabled"];
|
|
26
26
|
}
|
|
27
27
|
// 当属性发生变化时调用的回调函数
|
|
28
|
-
attributeChangedCallback(t,
|
|
29
|
-
const l =
|
|
28
|
+
attributeChangedCallback(t, r, o) {
|
|
29
|
+
const l = u(".l-btn", this.root);
|
|
30
30
|
if (l)
|
|
31
31
|
if (t === "loading")
|
|
32
|
-
|
|
32
|
+
v(o, !1, t) ? (m(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (k(l, "l-btn-loading"), l.disabled = this.getAttr("disabled", !1), l.innerHTML = "<slot></slot>");
|
|
33
33
|
else if (t === "color") {
|
|
34
|
-
const
|
|
35
|
-
l.style.cssText = this.applyColor(
|
|
34
|
+
const e = this.getAttr("text", !1), b = this.getAttr("ghost", !1);
|
|
35
|
+
l.style.cssText = this.applyColor(o, e, b);
|
|
36
36
|
} else t === "disabled" && (l.disabled = this.getAttr("disabled", !1));
|
|
37
37
|
}
|
|
38
38
|
connectedCallback() {
|
|
39
|
-
this.
|
|
39
|
+
this.loadStyleText([L, $]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && x(this, "click", this._handleClick);
|
|
40
40
|
}
|
|
41
41
|
disconnectedCallback() {
|
|
42
|
-
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") &&
|
|
42
|
+
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && y(this, "click", this._handleClick);
|
|
43
43
|
}
|
|
44
44
|
render() {
|
|
45
|
-
const t = this.getAttr("type", "normal"),
|
|
45
|
+
const t = this.getAttr("type", "normal"), r = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), b = this.getAttr("ghost", !1), d = [
|
|
46
46
|
"l-btn",
|
|
47
47
|
`l-btn-${t}`,
|
|
48
48
|
this.getAttr("block", !1) ? "l-btn-block" : "",
|
|
49
49
|
l === "round" ? "l-btn-round" : "",
|
|
50
50
|
l === "circle" ? "l-btn-circle" : "",
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
51
|
+
b ? "l-btn-ghost" : "",
|
|
52
|
+
e ? "l-btn-text" : "",
|
|
53
|
+
o ? "l-btn-loading" : ""
|
|
54
54
|
];
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
55
|
+
r.className = A(d), r.disabled = this.getAttr("disabled", !1) || o, r.type = this.getAttr("html-type", "button");
|
|
56
|
+
const s = this.applyColor(this.getAttr("color"), e, b);
|
|
57
|
+
s && (r.style.cssText = s), o ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.root.appendChild(r);
|
|
58
58
|
}
|
|
59
59
|
loadingBody() {
|
|
60
|
-
const t = this.getAttr("loading-text", ""),
|
|
61
|
-
return t === "" ?
|
|
60
|
+
const t = this.getAttr("loading-text", ""), r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
61
|
+
return t === "" ? r.push("<slot></slot>") : r.push(`<span>${t}</span>`), r.join("");
|
|
62
62
|
}
|
|
63
|
-
applyColor(t,
|
|
63
|
+
applyColor(t, r = !1, o = !1) {
|
|
64
64
|
if (!t) return "";
|
|
65
|
-
const l = c(t, 1, !0),
|
|
66
|
-
return
|
|
67
|
-
"--l-btn-border-color":
|
|
68
|
-
"--l-btn-text-color":
|
|
69
|
-
"--l-btn-hover-text-color":
|
|
70
|
-
"--l-btn-background":
|
|
71
|
-
"--l-btn-active-text-color":
|
|
72
|
-
"--l-btn-hover-border-color":
|
|
73
|
-
"--l-btn-hover-background":
|
|
74
|
-
"--l-btn-active-background":
|
|
75
|
-
"--l-btn-active-border-color":
|
|
65
|
+
const l = c(t, 1, !0), e = c(t, 3, !1);
|
|
66
|
+
return C({
|
|
67
|
+
"--l-btn-border-color": r ? "transparent" : t,
|
|
68
|
+
"--l-btn-text-color": o || r ? t : "#ffffff",
|
|
69
|
+
"--l-btn-hover-text-color": o || r ? l : "#ffffff",
|
|
70
|
+
"--l-btn-background": o || r ? "transparent" : t,
|
|
71
|
+
"--l-btn-active-text-color": o || r ? e : "#ffffff",
|
|
72
|
+
"--l-btn-hover-border-color": r ? "transparent" : l,
|
|
73
|
+
"--l-btn-hover-background": o || r ? "transparent" : l,
|
|
74
|
+
"--l-btn-active-background": o || r ? "transparent" : e,
|
|
75
|
+
"--l-btn-active-border-color": r ? "transparent" : e
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
_getForm() {
|
|
79
|
-
let t = this.parentElement,
|
|
79
|
+
let t = this.parentElement, r;
|
|
80
80
|
for (; t != null; ) {
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
|
|
81
|
+
const o = t.tagName;
|
|
82
|
+
if (o === "L-FORM") {
|
|
83
|
+
r = t;
|
|
84
84
|
break;
|
|
85
85
|
}
|
|
86
|
-
if (
|
|
86
|
+
if (o === "BODY") break;
|
|
87
87
|
t = t.parentElement;
|
|
88
88
|
}
|
|
89
|
-
return t = null,
|
|
89
|
+
return t = null, r;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
i(
|
|
92
|
+
i(B, "baseName", "button");
|
|
93
93
|
export {
|
|
94
|
-
|
|
94
|
+
B as default
|
|
95
95
|
};
|
|
@@ -4,7 +4,9 @@ var s = (i, t, e) => r(i, typeof t != "symbol" ? t + "" : t, e);
|
|
|
4
4
|
import { $one as n, on as l, off as o } from "ph-utils/dom";
|
|
5
5
|
import h from "../form/form_inner.js";
|
|
6
6
|
import { initAttr as p, setAttrs as d } from "../utils/index.js";
|
|
7
|
-
|
|
7
|
+
import { i as u } from "../index-391POYEJ.js";
|
|
8
|
+
const k = ":host{--l-input-width: 60px}";
|
|
9
|
+
class m extends h {
|
|
8
10
|
constructor() {
|
|
9
11
|
super();
|
|
10
12
|
s(this, "$picker");
|
|
@@ -19,7 +21,7 @@ class u extends h {
|
|
|
19
21
|
super.setValue(e), this.$picker && (this.$picker.value = e);
|
|
20
22
|
}
|
|
21
23
|
connectedCallback() {
|
|
22
|
-
this.
|
|
24
|
+
this.loadStyleText([u, k]), super.connectedCallback(), this.$picker = n("input", this.root), l(this.$picker, "change", this._handleChange);
|
|
23
25
|
}
|
|
24
26
|
disconnectedCallback() {
|
|
25
27
|
super.disconnectedCallback(), this.$picker && (o(this.$picker, "change", this._handleChange), this.$picker = void 0);
|
|
@@ -38,7 +40,7 @@ class u extends h {
|
|
|
38
40
|
this.$picker && (this.$picker.disabled = this.isDisabled());
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
|
-
s(
|
|
43
|
+
s(m, "baseName", "color-picker");
|
|
42
44
|
export {
|
|
43
|
-
|
|
45
|
+
m as default
|
|
44
46
|
};
|
package/lib/form/form_item.d.ts
CHANGED
package/lib/form/form_item.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (
|
|
4
|
-
import { formatClass as
|
|
5
|
-
import { initAttr as b, parseAttrValue as
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var f = (o, l, e) => l in o ? d(o, l, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[l] = e;
|
|
3
|
+
var i = (o, l, e) => f(o, typeof l != "symbol" ? l + "" : l, e);
|
|
4
|
+
import { formatClass as h, $one as s, addClass as c, removeClass as p } from "ph-utils/dom";
|
|
5
|
+
import { initAttr as b, parseAttrValue as u } from "../utils/index.js";
|
|
6
6
|
import v from "../base.js";
|
|
7
|
-
import { emit as
|
|
8
|
-
import { random as
|
|
9
|
-
|
|
7
|
+
import { emit as n, add as g, clear as _, remove as C } from "./form_events.js";
|
|
8
|
+
import { random as m } from "ph-utils";
|
|
9
|
+
const y = ':host{display:contents}.l-form-item{display:var(--l-form-item-display, contents);font-size:14px;grid-template-columns:1fr}.l-form-item__label{text-align:var(--l-form-label-align, right);display:inline-block;width:var(--l-form-label-width, auto);height:var(--l-form-edit-height, 32px);line-height:var(--l-form-edit-height, 32px);color:#606266;padding:0 10px 0 0}.l-form-item__label:empty{display:var(--l-form-label-empty-display, inline-block)}.l-form-item.is-required .l-form-item__label:before{content:"*";margin-right:4px;color:var(--l-warn-color, #f56c6c);vertical-align:middle}.l-form-item__content{flex:1;position:relative;display:flex;align-items:center}.l-form-item__error{font-size:12px;line-height:1;position:absolute;top:100%;left:0;color:var(--nt-error-color, #ed3f13);padding-top:3px}.l-form-item.l-form-item--left{--l-form-label-align: left}.l-form-item.l-form-item--top{--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}';
|
|
10
|
+
class x extends v {
|
|
10
11
|
constructor() {
|
|
11
12
|
super();
|
|
12
13
|
i(this, "disabled", !1);
|
|
@@ -31,7 +32,7 @@ class $ extends v {
|
|
|
31
32
|
const r = e === !0 ? void 0 : e[this.name];
|
|
32
33
|
(t == null || t === this.name && this.error != r) && (this.error = r, this._updateError());
|
|
33
34
|
});
|
|
34
|
-
b(this), this.id == null && (this.id = `l-fi${
|
|
35
|
+
b(this), this.id == null && (this.id = `l-fi${m(3)}-${m(6)}`);
|
|
35
36
|
}
|
|
36
37
|
static get observedAttributes() {
|
|
37
38
|
return ["error", "label", "disabled"];
|
|
@@ -42,13 +43,13 @@ class $ extends v {
|
|
|
42
43
|
else if (e === "label")
|
|
43
44
|
this.label = r, this._updateLabel();
|
|
44
45
|
else if (e === "disabled") {
|
|
45
|
-
const a =
|
|
46
|
-
a !== this.disabled && (
|
|
46
|
+
const a = u(r, !1, e);
|
|
47
|
+
a !== this.disabled && (n(this.id, "attributeChanged", e, a, this.id), this.disabled = a);
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
connectedCallback() {
|
|
50
51
|
var e;
|
|
51
|
-
if (super.connectedCallback(), this.
|
|
52
|
+
if (super.connectedCallback(), this.loadStyleText([y]), this.formId = this._getFormId(), this.name && this.formId) {
|
|
52
53
|
let t = ((e = this.verify) == null ? void 0 : e.split("|")) || [];
|
|
53
54
|
this.pattern && t.push(new RegExp(this.pattern));
|
|
54
55
|
const r = {
|
|
@@ -57,15 +58,15 @@ class $ extends v {
|
|
|
57
58
|
message: this.validity,
|
|
58
59
|
rules: t
|
|
59
60
|
};
|
|
60
|
-
|
|
61
|
+
n(this.formId, "ruleChange", r), g(this.formId, "validateChange", this._validateChange);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
64
|
disconnectedCallback() {
|
|
64
|
-
|
|
65
|
+
_(this.id), this.formId && C(this.formId, "validateChange", this._validateChange);
|
|
65
66
|
}
|
|
66
67
|
setRules(e) {
|
|
67
68
|
const t = { ...e, key: this.name };
|
|
68
|
-
t.required != null && this.required && (t.required = !0), this.formId &&
|
|
69
|
+
t.required != null && this.required && (t.required = !0), this.formId && n(this.formId, "ruleChange", t);
|
|
69
70
|
}
|
|
70
71
|
setError(e) {
|
|
71
72
|
this.error = e;
|
|
@@ -77,32 +78,32 @@ class $ extends v {
|
|
|
77
78
|
this.error ? "is-error" : void 0,
|
|
78
79
|
`l-form-item--${this.labelPosition}`
|
|
79
80
|
], t = this.label != null ? `<label class="l-form-item__label">${this.label}</label>` : "", r = this.error ? `<div class="l-form-item__error">${this.error}</div>` : "";
|
|
80
|
-
|
|
81
|
-
`<div class="${
|
|
81
|
+
return [
|
|
82
|
+
`<div class="${h(e)}">${t}`,
|
|
82
83
|
'<div class="l-form-item__content">',
|
|
83
84
|
`<slot></slot>${r}</div></div>`
|
|
84
85
|
].join("");
|
|
85
86
|
}
|
|
86
87
|
_updateError() {
|
|
87
88
|
if (!this.rendered) return;
|
|
88
|
-
let e =
|
|
89
|
+
let e = s(".l-form-item__error", this.root);
|
|
89
90
|
if (e)
|
|
90
91
|
this.error ? e.textContent = this.error : e.remove();
|
|
91
92
|
else if (this.error) {
|
|
92
93
|
e = document.createElement("div"), e.className = "l-form-item__error", e.textContent = this.error;
|
|
93
|
-
const r =
|
|
94
|
+
const r = s(".l-form-item__content", this.root);
|
|
94
95
|
r && r.appendChild(e);
|
|
95
96
|
}
|
|
96
|
-
const t =
|
|
97
|
-
t && (this.error ? c(t, "is-error") :
|
|
97
|
+
const t = s(".l-form-item", this.root);
|
|
98
|
+
t && (this.error ? c(t, "is-error") : p(t, "is-error"));
|
|
98
99
|
}
|
|
99
100
|
_updateLabel() {
|
|
100
101
|
if (!this.rendered) return;
|
|
101
|
-
let e =
|
|
102
|
+
let e = s(".l-form-item__label", this.root);
|
|
102
103
|
if (e == null) {
|
|
103
104
|
if (this.label != null) {
|
|
104
105
|
e = document.createElement("div"), e.className = "l-form-item__label", e.textContent = this.label;
|
|
105
|
-
const t =
|
|
106
|
+
const t = s(".l-form-item", this.root);
|
|
106
107
|
t && t.appendChild(e);
|
|
107
108
|
}
|
|
108
109
|
} else
|
|
@@ -122,7 +123,7 @@ class $ extends v {
|
|
|
122
123
|
return e = null, t;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
125
|
-
i(
|
|
126
|
+
i(x, "baseName", "form-item");
|
|
126
127
|
export {
|
|
127
|
-
|
|
128
|
+
x as default
|
|
128
129
|
};
|
package/lib/form/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default class Form extends BaseComponent {
|
|
|
20
20
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
21
21
|
connectedCallback(): void;
|
|
22
22
|
disconnectedCallback(): void;
|
|
23
|
-
render():
|
|
23
|
+
render(): string;
|
|
24
24
|
ruleChange: (schema: SchemaType) => void;
|
|
25
25
|
_valueChange: (name: string, value: any, valid?: boolean) => void;
|
|
26
26
|
validateField(field: string | string[]): void;
|
package/lib/form/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var i = (d, r, t) =>
|
|
4
|
-
import { $one as
|
|
5
|
-
import
|
|
6
|
-
import { initAttr as g, parseAttrValue as
|
|
7
|
-
import { random as
|
|
8
|
-
import { emit as
|
|
9
|
-
import
|
|
10
|
-
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var u = (d, r, t) => r in d ? c(d, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[r] = t;
|
|
3
|
+
var i = (d, r, t) => u(d, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
+
import { $one as v, formatClass as n, formatStyle as p } from "ph-utils/dom";
|
|
5
|
+
import b from "../base.js";
|
|
6
|
+
import { initAttr as g, parseAttrValue as C } from "../utils/index.js";
|
|
7
|
+
import { random as f } from "ph-utils";
|
|
8
|
+
import { emit as s, add as m, clear as y } from "./form_events.js";
|
|
9
|
+
import _ from "ph-utils/validator";
|
|
10
|
+
const k = ":host{display:block}.l-form{display:grid;grid-template-columns:var(--l-form-label-width, auto) 1fr;row-gap:20px}.l-form-inline{display:flex;gap:20px;flex-flow:row wrap}.l-form.l-form-inline{--l-form-item-display: flex}.l-form.l-form--left{--l-form-label-align: left}.l-form.l-form--top{--l-form-item-display: grid;--l-form-label-align: left;--l-form-label-empty-display: none;grid-template-columns:1fr}";
|
|
11
|
+
class w extends b {
|
|
11
12
|
constructor() {
|
|
12
13
|
super();
|
|
13
14
|
/** 是否行内表单 */
|
|
@@ -25,26 +26,26 @@ class k extends C {
|
|
|
25
26
|
i(this, "ruleChange", (t) => {
|
|
26
27
|
this.validator.addSchema(t);
|
|
27
28
|
});
|
|
28
|
-
i(this, "_valueChange", (t,
|
|
29
|
+
i(this, "_valueChange", (t, l, e = !0) => {
|
|
29
30
|
this._data == null && (this._data = {});
|
|
30
31
|
const a = Object.hasOwn(this._data, t);
|
|
31
|
-
this._data[t] =
|
|
32
|
-
|
|
33
|
-
}).catch((
|
|
34
|
-
|
|
32
|
+
this._data[t] = l, !this.novalidate && a && e && this.validator.validateKey(t, l, this._data).then(() => {
|
|
33
|
+
s(this.id, "validateChange", !0, t);
|
|
34
|
+
}).catch((o) => {
|
|
35
|
+
s(this.id, "validateChange", o.detail, t);
|
|
35
36
|
});
|
|
36
37
|
});
|
|
37
|
-
g(this), this.id == null && (this.id = `l-f${
|
|
38
|
+
g(this), this.id == null && (this.id = `l-f${f(3)}-${f(6)}`), this.validator = new _([]), this.emit = new CustomEvent("submit");
|
|
38
39
|
}
|
|
39
40
|
static get observedAttributes() {
|
|
40
41
|
return ["disabled", "label-position"];
|
|
41
42
|
}
|
|
42
|
-
attributeChangedCallback(t,
|
|
43
|
+
attributeChangedCallback(t, l, e) {
|
|
43
44
|
if (t === "disabled") {
|
|
44
|
-
const a =
|
|
45
|
-
a !== this.disabled && (
|
|
45
|
+
const a = C(e, !1, t);
|
|
46
|
+
a !== this.disabled && (s(this.id, "attributeChanged", t, a, this.id), this.disabled = a);
|
|
46
47
|
} else if (t === "label-position") {
|
|
47
|
-
const a =
|
|
48
|
+
const a = v("form", this.root);
|
|
48
49
|
a && (a.className = n([
|
|
49
50
|
"l-form",
|
|
50
51
|
this.inline ? "l-form-inline" : void 0,
|
|
@@ -53,51 +54,51 @@ class k extends C {
|
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
56
|
connectedCallback() {
|
|
56
|
-
this.
|
|
57
|
+
this.loadStyleText([k]), super.connectedCallback(), m(this.id, "ruleChange", this.ruleChange), m(this.id, "valueChange", this._valueChange);
|
|
57
58
|
}
|
|
58
59
|
disconnectedCallback() {
|
|
59
|
-
|
|
60
|
+
y(this.id), this.validator = void 0;
|
|
60
61
|
}
|
|
61
62
|
render() {
|
|
62
63
|
const t = n([
|
|
63
64
|
"l-form",
|
|
64
65
|
this.inline ? "l-form-inline" : void 0,
|
|
65
66
|
`l-form--${this.labelPosition}`
|
|
66
|
-
]),
|
|
67
|
+
]), l = p({
|
|
67
68
|
"--l-form-label-width": this.labelWidth ? this.labelWidth : ""
|
|
68
69
|
});
|
|
69
|
-
|
|
70
|
+
return `<form class="${t}" style="${l}"><slot></slot></form>`;
|
|
70
71
|
}
|
|
71
72
|
validateField(t) {
|
|
72
|
-
const
|
|
73
|
+
const l = [];
|
|
73
74
|
if (this._data != null) {
|
|
74
75
|
if (Array.isArray(t))
|
|
75
76
|
for (let e = 0, a = t.length; e < a; e++) {
|
|
76
|
-
const
|
|
77
|
-
|
|
77
|
+
const o = t[e];
|
|
78
|
+
l.push(this.validator.validateKey(o, this._data[o], this._data));
|
|
78
79
|
}
|
|
79
80
|
else
|
|
80
|
-
|
|
81
|
+
l.push(
|
|
81
82
|
this.validator.validateKey(t, this._data[t], this._data)
|
|
82
83
|
);
|
|
83
|
-
Promise.allSettled(
|
|
84
|
-
for (let a = 0,
|
|
85
|
-
const
|
|
86
|
-
|
|
84
|
+
Promise.allSettled(l).then((e) => {
|
|
85
|
+
for (let a = 0, o = e.length; a < o; a++) {
|
|
86
|
+
const h = e[a];
|
|
87
|
+
h.status === "rejected" ? s(
|
|
87
88
|
this.id,
|
|
88
89
|
"validateChange",
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
) :
|
|
90
|
+
h.reason.detail,
|
|
91
|
+
h.reason.key
|
|
92
|
+
) : s(this.id, "validateChange", !0, h.value.key);
|
|
92
93
|
}
|
|
93
94
|
});
|
|
94
95
|
}
|
|
95
96
|
}
|
|
96
97
|
clearValidate() {
|
|
97
|
-
|
|
98
|
+
s(this.id, "validateChange", !0);
|
|
98
99
|
}
|
|
99
100
|
reset() {
|
|
100
|
-
this.clearValidate(),
|
|
101
|
+
this.clearValidate(), s(this.id, "reset");
|
|
101
102
|
}
|
|
102
103
|
submit() {
|
|
103
104
|
this.novalidate ? this.dispatchEvent(this.emit) : this.validate().then((t) => {
|
|
@@ -110,9 +111,9 @@ class k extends C {
|
|
|
110
111
|
async validate() {
|
|
111
112
|
if (this._data != null)
|
|
112
113
|
try {
|
|
113
|
-
return await this.validator.validate(this._data),
|
|
114
|
+
return await this.validator.validate(this._data), s(this.id, "validateChange", !0), Promise.resolve(!0);
|
|
114
115
|
} catch (t) {
|
|
115
|
-
return
|
|
116
|
+
return s(this.id, "validateChange", t.detail), Promise.resolve(!1);
|
|
116
117
|
}
|
|
117
118
|
return Promise.resolve(!0);
|
|
118
119
|
}
|
|
@@ -120,7 +121,7 @@ class k extends C {
|
|
|
120
121
|
return { ...this._data };
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
|
-
i(
|
|
124
|
+
i(w, "baseName", "form");
|
|
124
125
|
export {
|
|
125
|
-
|
|
126
|
+
w as default
|
|
126
127
|
};
|
package/lib/icon/base.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
|
-
var p = (
|
|
3
|
-
var n = (
|
|
2
|
+
var p = (i, t, e) => t in i ? u(i, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : i[t] = e;
|
|
3
|
+
var n = (i, t, e) => p(i, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import w from "../base.js";
|
|
5
|
-
|
|
5
|
+
const f = ":host{display:inline-flex}.l-icon{width:1em;height:1em;fill:currentColor;vertical-align:middle;display:inline-block}";
|
|
6
|
+
class g extends w {
|
|
6
7
|
constructor() {
|
|
7
8
|
super();
|
|
8
9
|
n(this, "useLink");
|
|
@@ -10,24 +11,24 @@ class v extends w {
|
|
|
10
11
|
this.useLink = !1, this.viewBox = "0 0 1024 1024";
|
|
11
12
|
}
|
|
12
13
|
connectedCallback() {
|
|
13
|
-
this.
|
|
14
|
+
this.loadStyleText([f]), this.render(), this.rendered = !0;
|
|
14
15
|
}
|
|
15
16
|
render() {
|
|
16
|
-
const e = this.createEl("svg"),
|
|
17
|
-
e.classList.add("l-icon"),
|
|
18
|
-
const
|
|
19
|
-
if (typeof
|
|
20
|
-
if (
|
|
21
|
-
const
|
|
22
|
-
for (let r = 0,
|
|
23
|
-
const a =
|
|
24
|
-
|
|
17
|
+
const e = this.createEl("svg"), c = this.getAttr("useLink", this.useLink), d = this.getAttr("viewBox", this.viewBox);
|
|
18
|
+
e.classList.add("l-icon"), c || e.setAttribute("viewBox", d);
|
|
19
|
+
const s = this.renderChildren();
|
|
20
|
+
if (typeof s == "string")
|
|
21
|
+
if (s === "") {
|
|
22
|
+
const l = this.children, o = [];
|
|
23
|
+
for (let r = 0, h = l.length; r < h; r++) {
|
|
24
|
+
const a = l[r];
|
|
25
|
+
o.push(a.outerHTML);
|
|
25
26
|
}
|
|
26
|
-
e.innerHTML =
|
|
27
|
+
e.innerHTML = o.join("");
|
|
27
28
|
} else
|
|
28
|
-
e.innerHTML =
|
|
29
|
+
e.innerHTML = s;
|
|
29
30
|
else
|
|
30
|
-
e.append(
|
|
31
|
+
e.append(s);
|
|
31
32
|
this.shadow.appendChild(e);
|
|
32
33
|
}
|
|
33
34
|
renderChildren() {
|
|
@@ -37,7 +38,7 @@ class v extends w {
|
|
|
37
38
|
return document.createElementNS("http://www.w3.org/2000/svg", e);
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
|
-
n(
|
|
41
|
+
n(g, "baseName", "base-icon");
|
|
41
42
|
export {
|
|
42
|
-
|
|
43
|
+
g as default
|
|
43
44
|
};
|