litos-ui 0.9.0 → 0.11.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.d.ts +4 -0
- package/lib/base.js +13 -7
- package/lib/button/index.js +3 -3
- package/lib/checkbox/index.d.ts +17 -0
- package/lib/checkbox/index.js +135 -0
- package/lib/dialog/dialog_container.d.ts +28 -0
- package/lib/dialog/dialog_container.js +100 -0
- package/lib/dialog/index.d.ts +30 -0
- package/lib/dialog/index.js +86 -0
- package/lib/form/form_inner.js +21 -20
- package/lib/form/form_item.js +1 -1
- package/lib/form/index.js +1 -1
- package/lib/icon/close.d.ts +5 -0
- package/lib/icon/close.js +10 -0
- package/lib/index.d.ts +18 -0
- package/lib/index.js +89 -71
- package/lib/input/index.js +2 -2
- package/lib/list/index.d.ts +1 -1
- package/lib/litos-ui.css +1 -1
- package/lib/loading/index.d.ts +40 -0
- package/lib/loading/index.js +135 -0
- package/lib/md_input/index.d.ts +15 -0
- package/lib/md_input/index.js +60 -0
- package/lib/radio/index.js +2 -2
- package/lib/switch/index.js +1 -1
- package/lib/theme/index.js +1 -1
- package/lib/{form/form_events.d.ts → utils/event.d.ts} +5 -7
- package/lib/utils/index.js +24 -24
- package/package.json +71 -72
- package/styles/dialog.css +56 -0
- package/styles/loading.css +100 -0
- package/styles/reset.css +10 -0
- package/lib/form/form_events.js +0 -22
- package/lib/litos-ui.min.js +0 -1
package/lib/base.d.ts
CHANGED
|
@@ -31,4 +31,8 @@ export default class BaseComponent extends HTMLElement {
|
|
|
31
31
|
connectedCallback(): void;
|
|
32
32
|
disconnectedCallback(): void;
|
|
33
33
|
render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
|
|
34
|
+
/** 初始化事件 */
|
|
35
|
+
initEvents(): void;
|
|
36
|
+
/** 移除事件 */
|
|
37
|
+
removeEvents(): void;
|
|
34
38
|
}
|
package/lib/base.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getAttr as
|
|
2
|
-
class
|
|
1
|
+
import { getAttr as n } from "ph-utils/dom";
|
|
2
|
+
class i extends HTMLElement {
|
|
3
3
|
static baseName = "base-component";
|
|
4
4
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
5
5
|
rendered = !1;
|
|
@@ -13,7 +13,7 @@ class a extends HTMLElement {
|
|
|
13
13
|
return [];
|
|
14
14
|
}
|
|
15
15
|
// 当属性发生变化时调用的回调函数
|
|
16
|
-
attributeChangedCallback(t, e,
|
|
16
|
+
attributeChangedCallback(t, e, o) {
|
|
17
17
|
}
|
|
18
18
|
get shadow() {
|
|
19
19
|
return this.shadowRoot;
|
|
@@ -34,7 +34,7 @@ class a extends HTMLElement {
|
|
|
34
34
|
Array.isArray(e) && (e = e.join("")), this.createStyle(e);
|
|
35
35
|
}
|
|
36
36
|
getAttr(t, e) {
|
|
37
|
-
return
|
|
37
|
+
return n(this, t, e);
|
|
38
38
|
}
|
|
39
39
|
appendToRoot(t) {
|
|
40
40
|
if (t)
|
|
@@ -44,14 +44,20 @@ class a extends HTMLElement {
|
|
|
44
44
|
} else t.length ? this.root.append(...t) : this.root.append(t);
|
|
45
45
|
}
|
|
46
46
|
connectedCallback() {
|
|
47
|
-
this.appendToRoot(this.render()), this.rendered = !0;
|
|
47
|
+
this.appendToRoot(this.render()), this.initEvents(), this.rendered = !0;
|
|
48
48
|
}
|
|
49
49
|
disconnectedCallback() {
|
|
50
|
-
this.root.innerHTML = "", this.rendered = !1;
|
|
50
|
+
this.removeEvents(), this.root.innerHTML = "", this.rendered = !1;
|
|
51
51
|
}
|
|
52
52
|
render() {
|
|
53
53
|
}
|
|
54
|
+
/** 初始化事件 */
|
|
55
|
+
initEvents() {
|
|
56
|
+
}
|
|
57
|
+
/** 移除事件 */
|
|
58
|
+
removeEvents() {
|
|
59
|
+
}
|
|
54
60
|
}
|
|
55
61
|
export {
|
|
56
|
-
|
|
62
|
+
i as default
|
|
57
63
|
};
|
package/lib/button/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import d from "../base.js";
|
|
|
3
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
4
|
import { adjust as b } from "ph-utils/color";
|
|
5
5
|
import { a as x } from "../animation-DttknHkX.js";
|
|
6
|
-
const y = ":host{
|
|
7
|
-
class
|
|
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;font-size:0}.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
8
|
static baseName = "button";
|
|
9
9
|
htmlType = "button";
|
|
10
10
|
constructor() {
|
|
@@ -87,5 +87,5 @@ class M extends d {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
export {
|
|
90
|
-
|
|
90
|
+
w as default
|
|
91
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
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class DialogContainer extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 是否显示标题栏 */
|
|
6
|
+
showHeader: boolean;
|
|
7
|
+
/** 头部内容 */
|
|
8
|
+
header?: string;
|
|
9
|
+
/** 是否显示底部 */
|
|
10
|
+
showFooter: boolean;
|
|
11
|
+
/** 是否显示取消按钮 */
|
|
12
|
+
showCancel: boolean;
|
|
13
|
+
/** 取消按钮文本 */
|
|
14
|
+
cancelText: string;
|
|
15
|
+
/** 是否显示确定按钮 */
|
|
16
|
+
showOk: boolean;
|
|
17
|
+
/** 确定按钮文本 */
|
|
18
|
+
okText: string;
|
|
19
|
+
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
20
|
+
showClose: number;
|
|
21
|
+
containerClass?: string;
|
|
22
|
+
connectedCallback(): void;
|
|
23
|
+
initEvents(): void;
|
|
24
|
+
removeEvents(): void;
|
|
25
|
+
static get observedAttributes(): string[] | null | undefined;
|
|
26
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
27
|
+
render(): HTMLElement[];
|
|
28
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import p from "../base.js";
|
|
2
|
+
import { $ as d, iterate as c, on as r, off as h, shouldEventNext as g, $one as f, $$ as e, formatClass as u } from "ph-utils/dom";
|
|
3
|
+
import { initAttr as x } from "../utils/index.js";
|
|
4
|
+
const C = ":host{display:block;position:relative}:host(.l-container-close-outside){padding-top:10px;padding-right:10px}.l-dialog-main{box-shadow:0 0 8px #0000001a;border-radius:5px;background-color:#fff}.l-dialog-header{padding:10px;font-size:16px;border-bottom:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-dialog-footer{padding:10px;border-top:1px solid var(--l-dialog-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-dialog-container{padding:15px 10px;font-size:14px}.l-btn-dialog-close{--nt-form-edit-height: auto;position:absolute}.l-dialog-close1{right:5px;top:6px}.l-dialog-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-dialog-close2{right:0;top:0}.l-dialog-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}";
|
|
5
|
+
class k extends p {
|
|
6
|
+
static baseName = "dialog-container";
|
|
7
|
+
/** 是否显示标题栏 */
|
|
8
|
+
showHeader = !0;
|
|
9
|
+
/** 头部内容 */
|
|
10
|
+
header;
|
|
11
|
+
/** 是否显示底部 */
|
|
12
|
+
showFooter = !0;
|
|
13
|
+
/** 是否显示取消按钮 */
|
|
14
|
+
showCancel = !0;
|
|
15
|
+
/** 取消按钮文本 */
|
|
16
|
+
cancelText = "取消";
|
|
17
|
+
/** 是否显示确定按钮 */
|
|
18
|
+
showOk = !0;
|
|
19
|
+
/** 确定按钮文本 */
|
|
20
|
+
okText = "确定";
|
|
21
|
+
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
22
|
+
showClose = 1;
|
|
23
|
+
containerClass;
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
this.loadStyleText(C), x(this), this.showClose === 2 && this.classList.add("l-container-close-outside"), super.connectedCallback();
|
|
26
|
+
}
|
|
27
|
+
initEvents() {
|
|
28
|
+
const t = d("[data-action]", this.root);
|
|
29
|
+
c(t, (o) => {
|
|
30
|
+
r(o, "click", this.#t);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
removeEvents() {
|
|
34
|
+
const t = d("[data-action]", this.root);
|
|
35
|
+
c(t, (o) => {
|
|
36
|
+
h(o, "click", this.#t);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
#t(t) {
|
|
40
|
+
const [o, i] = g(t, "data-action");
|
|
41
|
+
o && this.dispatchEvent(
|
|
42
|
+
new CustomEvent("dialogAction", {
|
|
43
|
+
detail: { action: i },
|
|
44
|
+
composed: !0
|
|
45
|
+
})
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
static get observedAttributes() {
|
|
49
|
+
return ["show-close"];
|
|
50
|
+
}
|
|
51
|
+
attributeChangedCallback(t, o, i) {
|
|
52
|
+
switch (t) {
|
|
53
|
+
case "show-close":
|
|
54
|
+
this.showClose = Number(i), this.showClose === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
|
|
55
|
+
let s = f(".l-btn-dialog-close", this.root);
|
|
56
|
+
this.showClose === 0 && s ? (h(s, "click", this.#t), s.remove()) : s ? s.className = this.#o() : (s = this.#e(), r(s, "click", this.#t), this.root.appendChild(s));
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
#o() {
|
|
61
|
+
return `l-btn-dialog-close l-dialog-close${this.showClose}`;
|
|
62
|
+
}
|
|
63
|
+
#e() {
|
|
64
|
+
const t = e("l-button", {
|
|
65
|
+
shape: "circle",
|
|
66
|
+
type: "normal",
|
|
67
|
+
class: this.#o(),
|
|
68
|
+
"data-action": "close"
|
|
69
|
+
}), o = e("l-close-icon");
|
|
70
|
+
return t.appendChild(o), t;
|
|
71
|
+
}
|
|
72
|
+
render() {
|
|
73
|
+
const t = [];
|
|
74
|
+
this.showClose !== 0 && t.push(this.#e());
|
|
75
|
+
const o = e("div", { class: "l-dialog-main" });
|
|
76
|
+
if (this.showHeader) {
|
|
77
|
+
const l = e("header", { class: "l-dialog-header" }), a = e("slot", { name: "header" });
|
|
78
|
+
a.textContent = this.header || "", l.appendChild(a), o.appendChild(l);
|
|
79
|
+
}
|
|
80
|
+
const i = e("div", {
|
|
81
|
+
class: u(["l-dialog-container", this.containerClass])
|
|
82
|
+
}), s = e("slot");
|
|
83
|
+
if (i.appendChild(s), o.appendChild(i), this.showFooter) {
|
|
84
|
+
const l = e("div", { class: "l-dialog-footer" }), a = e("slot", { name: "footer" });
|
|
85
|
+
if (this.showCancel) {
|
|
86
|
+
const n = e("l-button", { "data-action": "cancel" });
|
|
87
|
+
n.textContent = this.cancelText, a.appendChild(n);
|
|
88
|
+
}
|
|
89
|
+
if (this.showOk) {
|
|
90
|
+
const n = e("l-button", { type: "primary", "data-action": "ok" });
|
|
91
|
+
n.textContent = this.okText, a.appendChild(n);
|
|
92
|
+
}
|
|
93
|
+
l.appendChild(a), o.appendChild(l);
|
|
94
|
+
}
|
|
95
|
+
return t.push(o), t;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
export {
|
|
99
|
+
k as default
|
|
100
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
type DialogProps = {
|
|
2
|
+
/** 对话框在垂直方向位置 */
|
|
3
|
+
verticalAlign?: "top" | "bottom" | "middle";
|
|
4
|
+
/** css translate, 例如: 0,0,0 -> translate3d(0,0,0) */
|
|
5
|
+
translate?: string;
|
|
6
|
+
/** 对话框宽度 */
|
|
7
|
+
width?: string;
|
|
8
|
+
/** 是否在点击 esc 时关闭弹窗 */
|
|
9
|
+
escClose?: boolean;
|
|
10
|
+
/** 是否可以通过点击 mask 关闭对话框 */
|
|
11
|
+
maskClosable?: boolean;
|
|
12
|
+
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
13
|
+
showClose?: number;
|
|
14
|
+
};
|
|
15
|
+
/** 初始化对话框配置 */
|
|
16
|
+
type DialogInitialParams = DialogProps & {
|
|
17
|
+
/** dialog 节点 */
|
|
18
|
+
el: HTMLDialogElement | string;
|
|
19
|
+
/** 返回 true 表明手动调用 done 关闭 */
|
|
20
|
+
onAction?: (action: string, done: () => void) => boolean;
|
|
21
|
+
};
|
|
22
|
+
declare const Dialog: (option?: DialogInitialParams) => {
|
|
23
|
+
init: (option: DialogInitialParams) => void;
|
|
24
|
+
open: () => void;
|
|
25
|
+
close: () => void;
|
|
26
|
+
destroy: () => void;
|
|
27
|
+
setProp: (key: keyof DialogProps, value: DialogProps[keyof DialogProps]) => void;
|
|
28
|
+
setProps: (props: DialogProps) => void;
|
|
29
|
+
};
|
|
30
|
+
export default Dialog;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { $one as C, hasClass as v, addClass as s, getAttr as a, on as c, off as f, removeClass as $ } from "ph-utils/dom";
|
|
2
|
+
const D = (g) => {
|
|
3
|
+
let t, l, i;
|
|
4
|
+
function w(e) {
|
|
5
|
+
e.code === "Escape" && (e.preventDefault(), n());
|
|
6
|
+
}
|
|
7
|
+
function h(e) {
|
|
8
|
+
t.isSameNode(e.target) && i && i.maskClosable && n();
|
|
9
|
+
}
|
|
10
|
+
function p(e) {
|
|
11
|
+
const o = e.detail.action;
|
|
12
|
+
i.onAction != null && i.onAction(o, n), n();
|
|
13
|
+
}
|
|
14
|
+
function u(e) {
|
|
15
|
+
if (!i) {
|
|
16
|
+
let o = {
|
|
17
|
+
escClose: !0,
|
|
18
|
+
verticalAlign: "top",
|
|
19
|
+
maskClosable: !0,
|
|
20
|
+
showClose: 1,
|
|
21
|
+
...e
|
|
22
|
+
};
|
|
23
|
+
if (t = C(e.el), t) {
|
|
24
|
+
v(t, "l-dialog") || s(t, "l-dialog"), l = C("l-dialog-container", t);
|
|
25
|
+
const r = a(t, "vertical-align");
|
|
26
|
+
o.verticalAlign = r || "top", s(t, `l-dialog--vertical-${o.verticalAlign}`);
|
|
27
|
+
const m = a(t, "translate") || o.translate;
|
|
28
|
+
m && t.style.setProperty(
|
|
29
|
+
"--l-dialog-translate",
|
|
30
|
+
`translate3d(${m})`
|
|
31
|
+
);
|
|
32
|
+
const A = a(t, "width") || o.width;
|
|
33
|
+
A && t.style.setProperty("--l-dialog-width", A);
|
|
34
|
+
const d = a(t, "show-close", 1);
|
|
35
|
+
d === 2 && s(t, "l-dialog-close-outside"), l && l.setAttribute("show-close", `${d}`), o.showClose = d, c(t, "keydown", w), c(t, "click", h), l && c(l, "dialogAction", p);
|
|
36
|
+
}
|
|
37
|
+
i = o;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
function b() {
|
|
41
|
+
t && (t.showModal(), s(t, "l-dialog--open"), s(document.body, "l-body--dialog-open"));
|
|
42
|
+
}
|
|
43
|
+
function n() {
|
|
44
|
+
t && v(t, "l-dialog--open") && (c(
|
|
45
|
+
t,
|
|
46
|
+
"transitionend",
|
|
47
|
+
() => {
|
|
48
|
+
t.close(), $(document.body, "l-body--dialog-open");
|
|
49
|
+
},
|
|
50
|
+
{ once: !0 }
|
|
51
|
+
), $(t, "l-dialog--open"));
|
|
52
|
+
}
|
|
53
|
+
function P() {
|
|
54
|
+
t && (n(), f(t, "keydown", w), f(t, "click", h), l && f(l, "dialogAction", p), l = void 0, t = void 0);
|
|
55
|
+
}
|
|
56
|
+
function y(e, o) {
|
|
57
|
+
if (i && (i[e] = o, t))
|
|
58
|
+
if (e === "verticalAlign") {
|
|
59
|
+
const r = t.className.replace(
|
|
60
|
+
/l-dialog--vertical-\w+/g,
|
|
61
|
+
function() {
|
|
62
|
+
return `l-dialog--vertical-${o || "top"}`;
|
|
63
|
+
}
|
|
64
|
+
);
|
|
65
|
+
t.className = r;
|
|
66
|
+
} else e === "translate" ? o ? t.style.setProperty(
|
|
67
|
+
"--l-dialog-translate",
|
|
68
|
+
`translate3d(${o})`
|
|
69
|
+
) : t.style.removeProperty("--l-dialog-translate") : e === "width" ? o ? t.style.setProperty("--l-dialog-width", o) : t.style.removeProperty("--l-dialog-width") : e === "showClose" && l && l.setAttribute("show-close", `${o}`);
|
|
70
|
+
}
|
|
71
|
+
function k(e) {
|
|
72
|
+
for (const o in e)
|
|
73
|
+
y(o, e[o]);
|
|
74
|
+
}
|
|
75
|
+
return g != null && u(g), {
|
|
76
|
+
init: u,
|
|
77
|
+
open: b,
|
|
78
|
+
close: n,
|
|
79
|
+
destroy: P,
|
|
80
|
+
setProp: y,
|
|
81
|
+
setProps: k
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
D as default
|
|
86
|
+
};
|
package/lib/form/form_inner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import d from "../base.js";
|
|
2
2
|
import { parseAttrValue as u } from "../utils/index.js";
|
|
3
|
-
import { add as l, remove as n, emit as
|
|
4
|
-
class b extends
|
|
3
|
+
import { add as l, remove as n, emit as o } from "../utils/event.js";
|
|
4
|
+
class b extends d {
|
|
5
5
|
disabled = !1;
|
|
6
6
|
name = void 0;
|
|
7
7
|
formAttrs = {};
|
|
@@ -32,14 +32,15 @@ class b extends o {
|
|
|
32
32
|
static get observedAttributes() {
|
|
33
33
|
return ["disabled"];
|
|
34
34
|
}
|
|
35
|
-
attributeChangedCallback(t, e,
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
41
42
|
}
|
|
42
|
-
attributeChange(t, e,
|
|
43
|
+
attributeChange(t, e, r) {
|
|
43
44
|
}
|
|
44
45
|
connectedCallback() {
|
|
45
46
|
const t = this._getForm();
|
|
@@ -63,13 +64,13 @@ class b extends o {
|
|
|
63
64
|
return this.name ? this.name : this.formItemAttrs.name;
|
|
64
65
|
}
|
|
65
66
|
_getForm() {
|
|
66
|
-
let t = this.parentElement, e = {},
|
|
67
|
+
let t = this.parentElement, e = {}, r = {};
|
|
67
68
|
for (; t != null; ) {
|
|
68
69
|
const i = t.tagName;
|
|
69
70
|
if (i === "L-FORM") {
|
|
70
71
|
const a = t.sharedAttrs;
|
|
71
|
-
for (let
|
|
72
|
-
const h = a[
|
|
72
|
+
for (let s = 0; s < a.length; s++) {
|
|
73
|
+
const h = a[s];
|
|
73
74
|
e[h] = t[h];
|
|
74
75
|
}
|
|
75
76
|
break;
|
|
@@ -77,27 +78,27 @@ class b extends o {
|
|
|
77
78
|
if (i === "BODY") break;
|
|
78
79
|
if (i === "L-FORM-ITEM") {
|
|
79
80
|
const a = t.sharedAttrs;
|
|
80
|
-
for (let
|
|
81
|
-
const h = a[
|
|
82
|
-
|
|
81
|
+
for (let s = 0; s < a.length; s++) {
|
|
82
|
+
const h = a[s];
|
|
83
|
+
r[h] = t[h];
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
t = t.parentElement;
|
|
86
87
|
}
|
|
87
88
|
return t = null, {
|
|
88
89
|
formAttr: e,
|
|
89
|
-
formItemAttr:
|
|
90
|
+
formItemAttr: r
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
|
-
_formAttributeChanged = (t, e,
|
|
93
|
-
|
|
93
|
+
_formAttributeChanged = (t, e, r) => {
|
|
94
|
+
r === this.formAttrs.formId ? this.formAttrs[t] = e : this.formItemAttrs[t] = e, t === "disabled" && this._changeDisabled();
|
|
94
95
|
};
|
|
95
96
|
/** disable 属性改变时回调 */
|
|
96
97
|
_changeDisabled() {
|
|
97
98
|
}
|
|
98
99
|
pushValueChange() {
|
|
99
100
|
const t = this.getName();
|
|
100
|
-
this.formAttrs.id && t &&
|
|
101
|
+
this.formAttrs.id && t && o(
|
|
101
102
|
this.formAttrs.id,
|
|
102
103
|
"valueChange",
|
|
103
104
|
t,
|
package/lib/form/form_item.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { formatClass as a, $one as i, addClass as n, removeClass as m } from "ph-utils/dom";
|
|
2
2
|
import { initAttr as d, parseAttrValue as f } from "../utils/index.js";
|
|
3
3
|
import h from "../base.js";
|
|
4
|
-
import { emit as o, add as c, clear as p, remove as b } from "
|
|
4
|
+
import { emit as o, add as c, clear as p, remove as b } from "../utils/event.js";
|
|
5
5
|
import { random as s } from "ph-utils";
|
|
6
6
|
const u = ':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}';
|
|
7
7
|
class $ extends h {
|
package/lib/form/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { $one as n, formatClass as o, formatStyle as f } from "ph-utils/dom";
|
|
|
2
2
|
import m from "../base.js";
|
|
3
3
|
import { initAttr as c, parseAttrValue as u } from "../utils/index.js";
|
|
4
4
|
import { random as d } from "ph-utils";
|
|
5
|
-
import { emit as l, add as h, clear as v } from "
|
|
5
|
+
import { emit as l, add as h, clear as v } from "../utils/event.js";
|
|
6
6
|
import p from "ph-utils/validator";
|
|
7
7
|
const b = ":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}";
|
|
8
8
|
class $ extends m {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
class l extends e {
|
|
3
|
+
static baseName = "close-icon";
|
|
4
|
+
renderChildren() {
|
|
5
|
+
return '<path fill="currentColor" d="M764.288 214.592 512 466.88 259.712 214.592a31.936 31.936 0 0 0-45.12 45.12L466.752 512 214.528 764.224a31.936 31.936 0 1 0 45.12 45.184L512 557.184l252.288 252.288a31.936 31.936 0 0 0 45.12-45.12L557.12 512.064l252.288-252.352a31.936 31.936 0 1 0-45.12-45.184z"></path>';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
l as default
|
|
10
|
+
};
|