litos-ui 0.16.1 → 0.17.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 +11 -2
- package/lib/base.js +59 -27
- package/lib/button/index.d.ts +18 -3
- package/lib/button/index.js +65 -68
- package/lib/check/check.d.ts +14 -5
- package/lib/check/check.js +67 -29
- package/lib/check/checkbox.js +5 -12
- package/lib/check/checkbox_group.d.ts +0 -5
- package/lib/check/checkbox_group.js +3 -29
- package/lib/check/index.d.ts +14 -4
- package/lib/check/index.js +48 -28
- package/lib/check/radio.js +6 -14
- package/lib/check/radio_group.d.ts +1 -2
- package/lib/check/radio_group.js +5 -19
- package/lib/check-CksURvTv.js +4 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/form/form_inner.d.ts +17 -10
- package/lib/form/form_inner.js +83 -80
- package/lib/form/form_item.d.ts +23 -23
- package/lib/form/form_item.js +107 -90
- package/lib/form/index.d.ts +21 -14
- package/lib/form/index.js +92 -70
- package/lib/form/types.d.ts +7 -0
- package/lib/form/types.js +1 -0
- package/lib/index-Blf4-a2-.js +4 -0
- package/lib/index-CrMiSe0x.js +249 -0
- package/lib/index.js +162 -160
- package/lib/input/index.d.ts +24 -25
- package/lib/input/index.js +99 -89
- package/lib/loading/index.d.ts +2 -0
- package/lib/loading/index.js +50 -64
- package/lib/message/index.js +9 -9
- package/lib/modal/index.d.ts +1 -6
- package/lib/modal/index.js +40 -46
- package/lib/select_ori/index.js +1 -1
- package/lib/utils/context_provide.d.ts +9 -0
- package/lib/utils/context_provide.js +22 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +41 -33
- package/package.json +8 -8
- package/styles/loading.css +5 -3
- package/lib/check-C7YSuH60.js +0 -4
- package/lib/index-DvcllHRh.js +0 -4
- package/lib/utils/event.d.ts +0 -30
package/lib/input/index.js
CHANGED
|
@@ -1,77 +1,78 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
class I extends m {
|
|
1
|
+
import { $one as c, on as h, formatStyle as f, off as p, addClass as o, removeClass as u, $ as d, $$ as n } from "ph-utils/dom";
|
|
2
|
+
import { unitNumberStr as b, parseAttrValue as m } from "../utils/index.js";
|
|
3
|
+
import g from "../form/form_inner.js";
|
|
4
|
+
import { i as _ } from "../index-Blf4-a2-.js";
|
|
5
|
+
class I extends g {
|
|
7
6
|
static baseName = "input";
|
|
8
|
-
/** 原生 input 的 type */
|
|
9
|
-
type = "text";
|
|
10
|
-
placeholder = void 0;
|
|
11
|
-
autosize = !1;
|
|
12
|
-
/** 限制输入类型, number, integer */
|
|
13
|
-
allowInput = void 0;
|
|
14
7
|
/** 自定义输入解析器 */
|
|
15
8
|
parser;
|
|
16
|
-
/** 宽度 */
|
|
17
|
-
width;
|
|
18
|
-
/** 宽度铺满 */
|
|
19
|
-
block = !1;
|
|
20
|
-
error = !1;
|
|
21
|
-
maxlength;
|
|
22
|
-
minlength;
|
|
23
|
-
inputmode = "text";
|
|
24
9
|
$inner;
|
|
25
|
-
|
|
10
|
+
constructor() {
|
|
11
|
+
super(), this._state = {
|
|
12
|
+
type: "text",
|
|
13
|
+
placeholder: "",
|
|
14
|
+
autosize: !1,
|
|
15
|
+
allowInput: void 0,
|
|
16
|
+
block: !1,
|
|
17
|
+
clearable: !1
|
|
18
|
+
};
|
|
19
|
+
}
|
|
26
20
|
set value(t) {
|
|
27
21
|
this.setValue(t), this.$inner && (this.$inner.value = t);
|
|
28
22
|
}
|
|
29
23
|
get value() {
|
|
30
24
|
return this.getValue();
|
|
31
25
|
}
|
|
32
|
-
get clearable() {
|
|
33
|
-
return this.#t;
|
|
34
|
-
}
|
|
35
|
-
set clearable(t) {
|
|
36
|
-
this.#t = t, t ? h(this, "l-input--clearable") : u(this, "l-input--clearable");
|
|
37
|
-
}
|
|
38
26
|
static get observedAttributes() {
|
|
39
27
|
return [
|
|
40
28
|
"disabled",
|
|
41
29
|
"value",
|
|
42
30
|
"name",
|
|
31
|
+
"inner-block",
|
|
43
32
|
"error",
|
|
44
33
|
"clearable",
|
|
45
34
|
"maxlength",
|
|
46
|
-
"
|
|
35
|
+
"minlength",
|
|
36
|
+
"inputmode",
|
|
37
|
+
"type",
|
|
38
|
+
"width",
|
|
39
|
+
"block"
|
|
47
40
|
];
|
|
48
41
|
}
|
|
49
42
|
connectedCallback() {
|
|
50
|
-
|
|
43
|
+
this.loadStyleText([_]), super.connectedCallback(), this.$inner = c(".l-input__inner", this.root), h(this.$inner, "input", this._input), h(this.$inner, "change", this.#s), this.style.cssText = f(this._getStyleObj()) + this.getAttr("style", ""), this._updateError(this._state.error != null);
|
|
51
44
|
}
|
|
52
45
|
disconnectedCallback() {
|
|
53
|
-
super.disconnectedCallback(),
|
|
46
|
+
super.disconnectedCallback(), p(this.$inner, "input", this._input);
|
|
54
47
|
}
|
|
55
48
|
attributeChange(t, s, e) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
switch (t) {
|
|
50
|
+
case "error":
|
|
51
|
+
case "maxlength":
|
|
52
|
+
case "minlength":
|
|
53
|
+
case "inputmode":
|
|
54
|
+
case "type":
|
|
55
|
+
this._state[t] = e;
|
|
56
|
+
break;
|
|
57
|
+
case "clearable":
|
|
58
|
+
case "block":
|
|
59
|
+
const a = m(e, !1, t);
|
|
60
|
+
this._state[t] = a;
|
|
61
|
+
break;
|
|
62
|
+
case "width":
|
|
63
|
+
this._state.width = b(e);
|
|
64
|
+
break;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
67
|
+
updateDOM(t) {
|
|
68
|
+
t.has("clearable") && (this._state.clearable ? o(this, "l-input--clearable") : u(this, "l-input--clearable")), t.has("error") && this._updateError(this._state.error != null), t.has("maxlength") && this._updateAttr("maxlength", this._state.maxlength), t.has("minlength") && this._updateAttr("minlength", this._state.minlength), t.has("inputmode") && this._updateAttr("inputmode", this._state.inputmode), t.has("block") && this.innerBlockChange(this._state.block);
|
|
69
|
+
}
|
|
70
|
+
_updateAttr(t, s) {
|
|
71
|
+
this.$inner && (s ? this.$inner.setAttribute(t, s) : this.$inner.removeAttribute(t));
|
|
72
|
+
}
|
|
72
73
|
render() {
|
|
73
74
|
const t = document.createDocumentFragment();
|
|
74
|
-
if (
|
|
75
|
+
if (d('[slot="prefix"]', this).length > 0) {
|
|
75
76
|
const i = n("slot", {
|
|
76
77
|
name: "prefix"
|
|
77
78
|
}), l = n("span", {
|
|
@@ -83,13 +84,16 @@ class I extends m {
|
|
|
83
84
|
const e = n("input", {
|
|
84
85
|
class: "l-input__inner",
|
|
85
86
|
value: this.value,
|
|
86
|
-
name: this.getName()
|
|
87
|
-
placeholder: this.placeholder
|
|
87
|
+
name: this.getName(),
|
|
88
|
+
placeholder: this._state.placeholder,
|
|
88
89
|
part: "default",
|
|
89
|
-
type: this.type,
|
|
90
|
-
inputmode: this.inputmode
|
|
90
|
+
type: this._state.type,
|
|
91
|
+
inputmode: this._state.inputmode,
|
|
92
|
+
maxlength: this._state.maxlength,
|
|
93
|
+
minlength: this._state.minlength,
|
|
94
|
+
disabled: this.isDisabled() ? !0 : void 0
|
|
91
95
|
});
|
|
92
|
-
if (
|
|
96
|
+
if (t.appendChild(e), d('[slot="suffix"]', this).length > 0) {
|
|
93
97
|
const i = n("slot", {
|
|
94
98
|
name: "suffix"
|
|
95
99
|
}), l = n("span", {
|
|
@@ -107,82 +111,88 @@ class I extends m {
|
|
|
107
111
|
setParser(t) {
|
|
108
112
|
this.parser = t;
|
|
109
113
|
}
|
|
114
|
+
_calcCurosorPosition(t, s) {
|
|
115
|
+
const e = t.selectionStart || 0, a = t.selectionEnd || 0, i = t.value;
|
|
116
|
+
let l = e, r = a;
|
|
117
|
+
s.length < i.length ? (l = Math.max(0, e - (i.length - s.length)), r = l) : s.length > i.length ? (l = Math.min(s.length, e + (s.length - i.length)), r = l) : (l = Math.min(s.length, e), r = l), t.value = s, t.setSelectionRange(l, r);
|
|
118
|
+
}
|
|
110
119
|
_input = (t) => {
|
|
111
120
|
const s = t.target;
|
|
112
|
-
let e = s.value;
|
|
113
|
-
if (this.allowInput != null) {
|
|
114
|
-
let
|
|
115
|
-
|
|
116
|
-
integer: this.allowInput.includes("integer"),
|
|
117
|
-
negative: this.allowInput.startsWith("-"),
|
|
118
|
-
|
|
119
|
-
}),
|
|
121
|
+
let e = s.value, a = e;
|
|
122
|
+
if (this._state.allowInput != null) {
|
|
123
|
+
let i = this._state.allowInput.indexOf("."), l = i === -1 ? i : parseInt(this._state.allowInput.substring(i + 1));
|
|
124
|
+
a = this._numberInputParse(e, {
|
|
125
|
+
integer: this._state.allowInput.includes("integer"),
|
|
126
|
+
negative: this._state.allowInput.startsWith("-"),
|
|
127
|
+
precision: l
|
|
128
|
+
}), a = String(a);
|
|
120
129
|
}
|
|
121
|
-
this.parser != null && (
|
|
130
|
+
this.parser != null && (a = this.parser(a)), this._calcCurosorPosition(s, a), this.setValue(a), this.#t();
|
|
122
131
|
};
|
|
123
|
-
#
|
|
124
|
-
if (this.clearable) {
|
|
125
|
-
let t =
|
|
132
|
+
#t() {
|
|
133
|
+
if (this._state.clearable) {
|
|
134
|
+
let t = c(".l-clearable", this.root);
|
|
126
135
|
if (this.value.length > 0) {
|
|
127
136
|
if (t == null) {
|
|
128
137
|
t = n("span", {
|
|
129
138
|
class: "l-input__suffix l-clearable"
|
|
130
139
|
});
|
|
131
140
|
const s = n("l-close-filled-icon");
|
|
132
|
-
t.appendChild(s), this.root.appendChild(t),
|
|
141
|
+
t.appendChild(s), this.root.appendChild(t), h(t, "click", this.#e);
|
|
133
142
|
}
|
|
134
143
|
} else
|
|
135
|
-
t && (p(t, "click", this.#
|
|
144
|
+
t && (p(t, "click", this.#e), t.remove());
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
|
-
#
|
|
147
|
+
#e = () => {
|
|
139
148
|
this.value = "", this.dispatchEvent(
|
|
140
149
|
new CustomEvent("input", {
|
|
141
150
|
bubbles: !0,
|
|
142
151
|
detail: { value: this.value }
|
|
143
152
|
})
|
|
144
|
-
), this.#
|
|
153
|
+
), this.#t();
|
|
145
154
|
};
|
|
146
155
|
disabledChange() {
|
|
147
156
|
this.isDisabled() ? this.classList.add("is-disabled") : this.classList.remove("is-disabled"), this.$inner && (this.$inner.disabled = this.isDisabled());
|
|
148
157
|
}
|
|
149
158
|
_numberInputParse(t, s) {
|
|
150
|
-
let e = t
|
|
151
|
-
if (
|
|
152
|
-
|
|
153
|
-
|
|
159
|
+
let e = t.trim();
|
|
160
|
+
if (e === "") return "";
|
|
161
|
+
let a = e.startsWith("-");
|
|
162
|
+
if (a && (s.negative || (e = e.slice(1), a = !1)), s.integer)
|
|
163
|
+
e = e.replace(/[^\d]/g, "");
|
|
164
|
+
else {
|
|
165
|
+
const i = e.split(".");
|
|
166
|
+
if (i.length > 2)
|
|
167
|
+
e = i[0] + "." + i.slice(1).join("").substring(0, s.precision);
|
|
168
|
+
else if (i.length === 2) {
|
|
169
|
+
const l = i[0].replace(/[^\d]/g, ""), r = i[1].replace(/[^\d]/g, "").substring(0, s.precision);
|
|
170
|
+
e = `${l}.${r}`;
|
|
171
|
+
} else
|
|
172
|
+
e = e.replace(/[^\d]/g, "");
|
|
154
173
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
);
|
|
160
|
-
return i != null ? e = i[1] || i[2] : e = "", i != null ? i[1] || i[2] : "";
|
|
174
|
+
return e.length > 1 && (e = e.replace(/^0+(\d)/, "$1")), a ? "-" + e : e;
|
|
175
|
+
}
|
|
176
|
+
innerBlockChange(t) {
|
|
177
|
+
t ? o(this, "is-block") : u(this, "is-block");
|
|
161
178
|
}
|
|
162
179
|
_getStyleObj() {
|
|
163
180
|
const t = {};
|
|
164
|
-
return this.
|
|
181
|
+
return this._state.width && (t["--l-input-width"] = this._state.width), t;
|
|
165
182
|
}
|
|
166
|
-
|
|
167
|
-
|
|
183
|
+
_updateError(t = !1) {
|
|
184
|
+
t ? o(this, "is-error") : u(this, "is-error");
|
|
168
185
|
}
|
|
169
|
-
|
|
170
|
-
this.
|
|
186
|
+
validResult(t) {
|
|
187
|
+
this._updateError(t != null);
|
|
171
188
|
}
|
|
172
|
-
_validateChange = (t, s) => {
|
|
173
|
-
const e = this.getName();
|
|
174
|
-
if (e) {
|
|
175
|
-
const r = t === !0 ? !1 : t[e] != null;
|
|
176
|
-
(s == null || s === e && this.error != r) && (this.error = r, this._updateError()), Object.keys(t)[0] === e && this.focus();
|
|
177
|
-
}
|
|
178
|
-
};
|
|
179
189
|
#s = (t) => {
|
|
180
190
|
const s = t.target;
|
|
181
191
|
this.dispatchEvent(
|
|
182
192
|
new CustomEvent("change", {
|
|
183
193
|
bubbles: !0,
|
|
184
194
|
composed: !0,
|
|
185
|
-
detail: { value: s.value }
|
|
195
|
+
detail: { value: s.value, name: this.getName() }
|
|
186
196
|
})
|
|
187
197
|
);
|
|
188
198
|
};
|
package/lib/loading/index.d.ts
CHANGED
|
@@ -21,11 +21,13 @@ declare class LoadingInstance {
|
|
|
21
21
|
/** 加载容器 */
|
|
22
22
|
el: HTMLElement;
|
|
23
23
|
option: Required<Omit<LoadingInstanceParams, "to" | "zindex">>;
|
|
24
|
+
isLoading: boolean;
|
|
24
25
|
constructor(option?: LoadingInstanceParams);
|
|
25
26
|
/** 显示进度条 */
|
|
26
27
|
show(): void;
|
|
27
28
|
/** 隐藏进度条 */
|
|
28
29
|
hide(): void;
|
|
30
|
+
destroy(): void;
|
|
29
31
|
}
|
|
30
32
|
declare const _default: {
|
|
31
33
|
/** 创建并显示进度条 */
|
package/lib/loading/index.js
CHANGED
|
@@ -1,70 +1,59 @@
|
|
|
1
|
-
import { $ as
|
|
1
|
+
import { $ as c, iterate as d, $one as r, addClass as g, hasClass as m, $$ as o } from "ph-utils/dom";
|
|
2
2
|
function f(t, e) {
|
|
3
3
|
if (m(t, "l-loading")) return;
|
|
4
|
-
let
|
|
5
|
-
if (e.fullscreen &&
|
|
4
|
+
let l;
|
|
5
|
+
if (e.fullscreen && r("#l-loading") != null)
|
|
6
6
|
return;
|
|
7
|
-
|
|
7
|
+
const s = ["l-loading"];
|
|
8
|
+
(e.mask === 1 || e.mask === 2 && e.shape === "circle") && (l = o("div", {
|
|
8
9
|
class: "l-loading-mask",
|
|
9
10
|
style: {
|
|
10
11
|
"background-color": e.background,
|
|
11
12
|
"--l-loading-zindex": e.zindex
|
|
12
13
|
}
|
|
13
|
-
}), t.appendChild(
|
|
14
|
-
const
|
|
14
|
+
}), t.appendChild(l));
|
|
15
|
+
const n = o("div", {
|
|
15
16
|
class: `l-loading-spinner l-loading--${e.shape}`,
|
|
16
17
|
style: {
|
|
17
18
|
"--l-loading-color": e.color
|
|
18
19
|
}
|
|
19
20
|
});
|
|
20
21
|
if (e.shape === "bar") {
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
"top",
|
|
24
|
-
`-${getComputedStyle(t).borderTopWidth}`
|
|
25
|
-
), l.appendChild(s);
|
|
22
|
+
const i = o("div", { class: "l-loading-progress" });
|
|
23
|
+
n.appendChild(i);
|
|
26
24
|
} else if (e.shape === "circle") {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
const a = document.createElementNS(
|
|
33
|
-
"http://www.w3.org/2000/svg",
|
|
34
|
-
"circle"
|
|
35
|
-
);
|
|
36
|
-
if (a.classList.add("path"), a.setAttribute("cx", "25"), a.setAttribute("cy", "25"), a.setAttribute("r", "23"), a.setAttribute("fill", "none"), s.appendChild(a), l.appendChild(s), e.text) {
|
|
37
|
-
const i = o("p", {
|
|
25
|
+
const i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
26
|
+
i.setAttribute("viewBox", "0 0 50 50"), i.classList.add("circle");
|
|
27
|
+
const a = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
28
|
+
if (a.classList.add("path"), a.setAttribute("cx", "25"), a.setAttribute("cy", "25"), a.setAttribute("r", "23"), a.setAttribute("fill", "none"), i.appendChild(a), n.appendChild(i), e.text) {
|
|
29
|
+
const p = o("p", {
|
|
38
30
|
class: "l-loading-text",
|
|
39
31
|
textContent: e.text
|
|
40
32
|
});
|
|
41
|
-
|
|
33
|
+
n.appendChild(p);
|
|
42
34
|
}
|
|
43
35
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
e.lock && s.push("l-loading-lock"), t.classList.add(...s), l.id = "l-loading";
|
|
47
|
-
}
|
|
48
|
-
requestAnimationFrame(() => {
|
|
49
|
-
n && (n.style.opacity = "1"), l.style.opacity = "1", d(l, "l-loading-bar--start");
|
|
36
|
+
t.appendChild(n), e.lock && s.push("l-loading-lock"), e.fullscreen && (s.push("l-loading-fullscreen"), n.id = "l-loading"), t.classList.add(...s), requestAnimationFrame(() => {
|
|
37
|
+
l && (l.style.opacity = "1"), n.style.opacity = "1", g(n, "l-loading-bar--start");
|
|
50
38
|
});
|
|
51
39
|
}
|
|
52
|
-
function
|
|
53
|
-
const
|
|
54
|
-
if (!
|
|
55
|
-
function
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
-
t.tagName === "BODY" &&
|
|
40
|
+
function h(t, e) {
|
|
41
|
+
const l = t.tagName === "BODY" ? "body" : ".l-loading", s = r(`${l} > .l-loading-mask`, t), n = r(`${l} > .l-loading-spinner`, t);
|
|
42
|
+
if (!n) return;
|
|
43
|
+
function i() {
|
|
44
|
+
s && s.remove(), n.remove();
|
|
45
|
+
const a = ["l-loading"];
|
|
46
|
+
t.tagName === "BODY" && a.push("l-loading-fullscreen", "l-loading-lock"), t.classList.remove(...a);
|
|
59
47
|
}
|
|
60
|
-
|
|
61
|
-
|
|
48
|
+
n.addEventListener("transitionend", i, { once: !0 }), requestAnimationFrame(() => {
|
|
49
|
+
s && (s.style.opacity = "0"), g(n, "l-loading-bar--finish"), n.style.opacity = "0";
|
|
62
50
|
});
|
|
63
51
|
}
|
|
64
|
-
class
|
|
52
|
+
class b {
|
|
65
53
|
/** 加载容器 */
|
|
66
54
|
el;
|
|
67
55
|
option;
|
|
56
|
+
isLoading = !1;
|
|
68
57
|
constructor(e) {
|
|
69
58
|
this.option = {
|
|
70
59
|
fullscreen: !0,
|
|
@@ -76,45 +65,45 @@ class h {
|
|
|
76
65
|
mask: 2,
|
|
77
66
|
...e
|
|
78
67
|
};
|
|
79
|
-
const
|
|
80
|
-
let
|
|
81
|
-
|
|
68
|
+
const l = (e || {}).to;
|
|
69
|
+
let s = null;
|
|
70
|
+
l != null && (typeof l == "string" ? s = document.querySelector(l) : s = l), (s == null || this.option.fullscreen) && (s = document.body), this.el = s, this.show();
|
|
82
71
|
}
|
|
83
72
|
/** 显示进度条 */
|
|
84
73
|
show() {
|
|
85
|
-
f(this.el, this.option);
|
|
74
|
+
this.isLoading = !0, f(this.el, this.option);
|
|
86
75
|
}
|
|
87
76
|
/** 隐藏进度条 */
|
|
88
77
|
hide() {
|
|
89
|
-
|
|
78
|
+
this.isLoading = !1, h(this.el, this.option);
|
|
79
|
+
}
|
|
80
|
+
destroy() {
|
|
81
|
+
this.hide(), this.el = void 0;
|
|
90
82
|
}
|
|
91
83
|
}
|
|
92
|
-
function
|
|
93
|
-
const e = t.getAttribute("l-loading-text"),
|
|
84
|
+
function u(t) {
|
|
85
|
+
const e = t.getAttribute("l-loading-text"), l = t.getAttribute("l-loading-lock");
|
|
94
86
|
return {
|
|
95
87
|
background: t.getAttribute("l-loading-background"),
|
|
96
88
|
text: e ? e === "0" || e === "false" ? void 0 : e : "加载中……",
|
|
97
89
|
fullscreen: t.hasAttribute("l-loading-fullscreen"),
|
|
98
|
-
lock: !(
|
|
90
|
+
lock: !(l === "0" || l === "false"),
|
|
99
91
|
mask: Number(t.hasAttribute("l-loading-mask") || 2),
|
|
100
92
|
shape: t.getAttribute("l-loading-shape") || "circle",
|
|
101
93
|
color: t.getAttribute("l-loading-color")
|
|
102
94
|
};
|
|
103
95
|
}
|
|
104
|
-
const
|
|
96
|
+
const k = {
|
|
105
97
|
/** 创建并显示进度条 */
|
|
106
98
|
create(t) {
|
|
107
|
-
return new
|
|
99
|
+
return new b(t);
|
|
108
100
|
},
|
|
109
101
|
/** 根据指令参数初始化进度条 */
|
|
110
102
|
init(t) {
|
|
111
|
-
const e = t ? `[l-loading="${t}"]` : "[l-loading]",
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
f(
|
|
115
|
-
s.fullscreen ? document.body : l,
|
|
116
|
-
r(l)
|
|
117
|
-
);
|
|
103
|
+
const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = c(e);
|
|
104
|
+
d(l, (s) => {
|
|
105
|
+
const n = u(s);
|
|
106
|
+
f(n.fullscreen ? document.body : s, n);
|
|
118
107
|
});
|
|
119
108
|
},
|
|
120
109
|
/**
|
|
@@ -126,16 +115,13 @@ const $ = {
|
|
|
126
115
|
* @param id 可选参数,指定特定的加载元素 l-loading 对应的值,如果提供,则只关闭匹配该 id 的元素
|
|
127
116
|
*/
|
|
128
117
|
close(t) {
|
|
129
|
-
const e = t ? `[l-loading="${t}"]` : "[l-loading]",
|
|
130
|
-
|
|
131
|
-
const
|
|
132
|
-
|
|
133
|
-
s.fullscreen ? document.body : l,
|
|
134
|
-
r(l)
|
|
135
|
-
);
|
|
118
|
+
const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = c(e);
|
|
119
|
+
d(l, (s) => {
|
|
120
|
+
const n = u(s);
|
|
121
|
+
h(n.fullscreen ? document.body : s);
|
|
136
122
|
});
|
|
137
123
|
}
|
|
138
124
|
};
|
|
139
125
|
export {
|
|
140
|
-
|
|
126
|
+
k as default
|
|
141
127
|
};
|
package/lib/message/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { regist as g, useId as y } from "../utils/index.js";
|
|
2
2
|
import { transition as m } from "ph-utils/dom";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import h from "../icon/close_filled.js";
|
|
4
|
+
import p from "../icon/success.js";
|
|
5
|
+
import x from "../icon/warn.js";
|
|
6
|
+
import $ from "../icon/info.js";
|
|
7
7
|
const r = [], d = [
|
|
8
8
|
["opacity", "0", "0.3s"],
|
|
9
9
|
["transform", "translate3d(-50%, -100%, 0)", "0.3s"]
|
|
@@ -20,8 +20,8 @@ function u(e) {
|
|
|
20
20
|
const i = 15 + s.offsetHeight, n = r.length;
|
|
21
21
|
if (n !== 0)
|
|
22
22
|
for (let o = t; o < n; o++) {
|
|
23
|
-
const
|
|
24
|
-
|
|
23
|
+
const f = r[o], a = parseInt(f.style.top, 10) - i;
|
|
24
|
+
f.style.setProperty("top", `${a}px`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
function v(e) {
|
|
@@ -29,7 +29,7 @@ function v(e) {
|
|
|
29
29
|
t.id = e.id;
|
|
30
30
|
const s = e.type || "info";
|
|
31
31
|
let i = `l-message l-message-${s}`;
|
|
32
|
-
e.customClass && (i += " " + e.customClass), t.className = i, t.style.setProperty("top", `${e.offset}px`), t.style.setProperty("z-index", `${e.zindex
|
|
32
|
+
e.customClass && (i += " " + e.customClass), t.className = i, t.style.setProperty("top", `${e.offset}px`), e.zindex && t.style.setProperty("z-index", `${e.zindex}`), e.width && t.style.setProperty("width", e.width);
|
|
33
33
|
let n = s;
|
|
34
34
|
return n === "error" && (n = "close-filled"), t.innerHTML = [
|
|
35
35
|
'<div class="l-message-container">',
|
|
@@ -39,8 +39,8 @@ function v(e) {
|
|
|
39
39
|
].join(""), t;
|
|
40
40
|
}
|
|
41
41
|
const w = ((e) => {
|
|
42
|
-
l && (g([p,
|
|
43
|
-
const t = r.reduce((
|
|
42
|
+
l && (g([h, p, x, $]), l = !1);
|
|
43
|
+
const t = r.reduce((f, a) => f + a.offsetHeight + 15, 15), s = y(), i = typeof e == "string" ? { message: e } : e;
|
|
44
44
|
i.id = s, i.offset = t;
|
|
45
45
|
const n = v(i);
|
|
46
46
|
r.push(n), document.body.appendChild(n), m(n, d, "enter");
|
package/lib/modal/index.d.ts
CHANGED
|
@@ -2,18 +2,12 @@ import BaseComponent from "../base";
|
|
|
2
2
|
export default class Modal extends BaseComponent {
|
|
3
3
|
#private;
|
|
4
4
|
static baseName: string;
|
|
5
|
-
/** 是否显示对话框 */
|
|
6
|
-
show: boolean;
|
|
7
5
|
/** 关闭时销毁 Modal 里的子元素 */
|
|
8
6
|
destroyOnClose: boolean;
|
|
9
7
|
/** 点击蒙层是否允许关闭 */
|
|
10
8
|
maskClosable: boolean;
|
|
11
9
|
/** 是否展示遮罩 */
|
|
12
10
|
mask: boolean;
|
|
13
|
-
/** 标题 */
|
|
14
|
-
title: string;
|
|
15
|
-
/** 是否展示底部 */
|
|
16
|
-
footer: boolean;
|
|
17
11
|
/** 是否显示取消按钮 */
|
|
18
12
|
cancel: boolean;
|
|
19
13
|
/** 取消按钮文本 */
|
|
@@ -32,6 +26,7 @@ export default class Modal extends BaseComponent {
|
|
|
32
26
|
mobile: boolean;
|
|
33
27
|
/** 设置 Modal 的 z-index */
|
|
34
28
|
zIndex?: string;
|
|
29
|
+
_bodyOverflow: string;
|
|
35
30
|
static get observedAttributes(): string[];
|
|
36
31
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
37
32
|
connectedCallback(): void;
|