litos-ui 0.20.0 → 0.20.1
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-DStAHzod.js → animation-Bo4jbSGK.js} +4 -3
- package/lib/base.d.ts +3 -2
- package/lib/base.js +7 -7
- package/lib/button/index.d.ts +2 -2
- package/lib/button/index.js +152 -2
- package/lib/button/style.d.ts +2 -0
- package/lib/button/style.js +2 -0
- package/lib/calendar/index.d.ts +2 -2
- package/lib/card/index.d.ts +23 -0
- package/lib/card/index.js +2 -0
- package/lib/card-3DM-lJQV.js +63 -0
- package/lib/date_picker/index.d.ts +2 -2
- package/lib/dialog/dialog_box.d.ts +22 -0
- package/lib/dialog/dialog_box.js +98 -0
- package/lib/dialog/dialog_container.d.ts +7 -3
- package/lib/dialog/dialog_container.js +1 -1
- package/lib/dialog/index.d.ts +33 -11
- package/lib/dialog/index.js +45 -47
- package/lib/{dialog_container-Bq6HsKey.js → dialog_container-BNPQ9n0V.js} +32 -14
- package/lib/form/form_item.d.ts +2 -2
- package/lib/form/form_item.js +1 -1
- package/lib/{form_item-CFIkfH29.js → form_item-BqPMRABd.js} +5 -5
- package/lib/icon/base.d.ts +2 -2
- package/lib/index.d.ts +2 -0
- package/lib/index.js +70 -68
- package/lib/input/index.d.ts +2 -2
- package/lib/list/index.js +1 -1
- package/lib/{list-Dg5u5dgr.js → list-MG8PRzos.js} +2 -2
- package/lib/mask-Ox6CoyFB.js +5 -0
- package/lib/menu/index.d.ts +2 -2
- package/lib/modal/index.d.ts +2 -2
- package/lib/modal/index.js +1 -1
- package/lib/modal/modal_box.js +12 -12
- package/lib/{modal-iwxqmAqW.js → modal-Cwi3qlEf.js} +36 -32
- package/lib/pagination/index.d.ts +2 -2
- package/lib/qrcode/index.d.ts +2 -2
- package/lib/select/index.d.ts +2 -2
- package/lib/select_ori/index.d.ts +2 -2
- package/lib/style-gKR_qwzm.js +5 -0
- package/lib/styles/animation/index.d.ts +2 -0
- package/lib/styles/animation/index.js +2 -0
- package/lib/styles/mask/index.d.ts +2 -0
- package/lib/styles/mask/index.js +2 -0
- package/lib/theme/theme_color.d.ts +1 -2
- package/package.json +1 -1
- package/lib/button-CDYYpQu6.js +0 -151
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
//#region src/components/styles/animation.css?inline
|
|
2
|
-
var e = "@keyframes l-rotate-frame{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.l-rotate-anim{animation:1.5s linear infinite l-rotate-frame}";
|
|
1
|
+
//#region src/components/styles/animation/index.css?inline
|
|
2
|
+
var e = "@keyframes l-rotate-frame{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.l-rotate-anim{animation:1.5s linear infinite l-rotate-frame}", t = new CSSStyleSheet();
|
|
3
|
+
t.replaceSync(e);
|
|
3
4
|
//#endregion
|
|
4
|
-
export {
|
|
5
|
+
export { t };
|
package/lib/base.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
20
20
|
protected updateDOM(_changedProps: Set<string>): void;
|
|
21
21
|
/** @deprecated */
|
|
22
22
|
get shadow(): ShadowRoot;
|
|
23
|
-
get root(): ShadowRoot
|
|
23
|
+
get root(): ShadowRoot;
|
|
24
24
|
createStyle(text: string): void;
|
|
25
25
|
createLink(href: string): void;
|
|
26
26
|
loadStyleText(styleText: string | string[]): void;
|
|
@@ -40,7 +40,7 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
40
40
|
getAttr(key: string, defaultValue: boolean): boolean;
|
|
41
41
|
getAttr<T extends Record<string, string | number | boolean>>(filepath: string, defaultValue: T): T;
|
|
42
42
|
appendToRoot(el?: HTMLElement | HTMLElement[] | string | DocumentFragment): void;
|
|
43
|
-
appendToRootV2(template?: HTMLElement | string | DocumentFragment, style?: string | string[]): void;
|
|
43
|
+
appendToRootV2(template?: HTMLElement | string | DocumentFragment, style?: string | string[], styleSheets?: CSSStyleSheet[]): void;
|
|
44
44
|
connectedCallback(): void;
|
|
45
45
|
disconnectedCallback(): void;
|
|
46
46
|
render(): void | string | HTMLElement | DocumentFragment;
|
|
@@ -51,6 +51,7 @@ export default class BaseComponent<T = Record<string, any>> extends HTMLElement
|
|
|
51
51
|
render_v2(): {
|
|
52
52
|
template?: string | HTMLElement | DocumentFragment;
|
|
53
53
|
style?: string | string[];
|
|
54
|
+
styleSheets?: CSSStyleSheet[];
|
|
54
55
|
};
|
|
55
56
|
/**
|
|
56
57
|
* 初始化事件
|
package/lib/base.js
CHANGED
|
@@ -64,22 +64,22 @@ var t = class extends HTMLElement {
|
|
|
64
64
|
} else e.length ? this.root.append(...e) : this.root.append(e);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
|
-
appendToRootV2(e, t) {
|
|
68
|
-
let
|
|
69
|
-
if (t &&
|
|
70
|
-
if (typeof e == "string")
|
|
67
|
+
appendToRootV2(e, t, n) {
|
|
68
|
+
let r = [];
|
|
69
|
+
if (t && r.push(this.styleHtml(t)), e) {
|
|
70
|
+
if (typeof e == "string") r.push(e);
|
|
71
71
|
else {
|
|
72
72
|
let t = document.createElement("div");
|
|
73
|
-
t.appendChild(e),
|
|
73
|
+
t.appendChild(e), r.push(t.innerHTML), t = void 0;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
this.root.
|
|
76
|
+
n && (this.root.adoptedStyleSheets = n), this.root.innerHTML = r.join("");
|
|
77
77
|
}
|
|
78
78
|
connectedCallback() {
|
|
79
79
|
if (this.version === 1) this.appendToRoot(this.render());
|
|
80
80
|
else {
|
|
81
81
|
let e = this.render_v2();
|
|
82
|
-
this.appendToRootV2(e.template, e.style);
|
|
82
|
+
this.appendToRootV2(e.template, e.style, e.styleSheets);
|
|
83
83
|
}
|
|
84
84
|
this.rendered = !0, this.initEvents(), this.afterInit(), this._changedProperties.size > 0 && this.updateDOM(this._changedProperties);
|
|
85
85
|
}
|
package/lib/button/index.d.ts
CHANGED
|
@@ -29,8 +29,8 @@ export default class Button extends BaseComponent<ButtonState> {
|
|
|
29
29
|
isFormButton(): boolean;
|
|
30
30
|
getHtmlType(): "submit" | "reset" | "button";
|
|
31
31
|
render_v2(): {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
styleSheets: CSSStyleSheet[];
|
|
33
|
+
template: HTMLButtonElement;
|
|
34
34
|
};
|
|
35
35
|
afterInit(): void;
|
|
36
36
|
render(): HTMLButtonElement;
|
package/lib/button/index.js
CHANGED
|
@@ -1,2 +1,152 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "../base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "../utils/index.js";
|
|
3
|
+
import { t as i } from "../animation-Bo4jbSGK.js";
|
|
4
|
+
import { t as a } from "../style-gKR_qwzm.js";
|
|
5
|
+
import { $one as o, addClass as s, formatClass as c, formatStyle as l, off as u, on as d, removeClass as f } from "ph-utils/browser";
|
|
6
|
+
import { adjust as p } from "ph-utils";
|
|
7
|
+
//#region src/components/button/index.ts
|
|
8
|
+
var m = class extends e {
|
|
9
|
+
static baseName = "button";
|
|
10
|
+
$btn;
|
|
11
|
+
constructor() {
|
|
12
|
+
super(), this.version = 2, this._state = {
|
|
13
|
+
loading: !1,
|
|
14
|
+
htmlType: "button",
|
|
15
|
+
text: !1,
|
|
16
|
+
ghost: !1,
|
|
17
|
+
disabled: !1,
|
|
18
|
+
type: "normal",
|
|
19
|
+
shape: "default",
|
|
20
|
+
loadingText: "加载中……",
|
|
21
|
+
size: "default",
|
|
22
|
+
boxShadow: "box-shadow-none"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
get disabled() {
|
|
26
|
+
return this._state.disabled;
|
|
27
|
+
}
|
|
28
|
+
set disabled(e) {
|
|
29
|
+
this.setDisabled(e);
|
|
30
|
+
}
|
|
31
|
+
setLoading(e) {
|
|
32
|
+
this.$btn && (e ? (s(this.$btn, "l-btn-loading"), this.$btn.disabled = !0, this.$btn.innerHTML = this.loadingBody()) : (f(this.$btn, "l-btn-loading"), this.$btn.disabled = this.disabled, this.$btn.innerHTML = "<slot></slot>"));
|
|
33
|
+
}
|
|
34
|
+
setDisabled(e) {
|
|
35
|
+
this._state.disabled = e, this.$btn && (this.$btn.disabled = e);
|
|
36
|
+
}
|
|
37
|
+
static get observedAttributes() {
|
|
38
|
+
return [
|
|
39
|
+
"loading",
|
|
40
|
+
"color",
|
|
41
|
+
"text",
|
|
42
|
+
"ghost",
|
|
43
|
+
"disabled",
|
|
44
|
+
"height",
|
|
45
|
+
"html-type",
|
|
46
|
+
"type",
|
|
47
|
+
"shape",
|
|
48
|
+
"loading-text",
|
|
49
|
+
"size",
|
|
50
|
+
"box-shadow"
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
attributeChanged(e, i, a) {
|
|
54
|
+
switch (e) {
|
|
55
|
+
case "color":
|
|
56
|
+
case "shape":
|
|
57
|
+
case "type":
|
|
58
|
+
case "size":
|
|
59
|
+
this._state[e] = a;
|
|
60
|
+
break;
|
|
61
|
+
case "height":
|
|
62
|
+
this._state[e] = r(a);
|
|
63
|
+
break;
|
|
64
|
+
case "text":
|
|
65
|
+
case "ghost":
|
|
66
|
+
case "disabled":
|
|
67
|
+
case "loading":
|
|
68
|
+
this._state[e] = n(a, !1, e);
|
|
69
|
+
break;
|
|
70
|
+
case "html-type":
|
|
71
|
+
case "loading-text":
|
|
72
|
+
this._state[t(e)] = a;
|
|
73
|
+
break;
|
|
74
|
+
case "box-shadow":
|
|
75
|
+
let i = n(a, !1, "box-shadow");
|
|
76
|
+
this._state.boxShadow = `box-shadow${i ? "" : "-none"}`;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
updateDOM(e) {
|
|
80
|
+
this.$btn && (e.has("loading") && this.setLoading(this._state.loading), e.has("disabled") && this.setDisabled(this.disabled), e.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(this._state.color, this._state.text, this._state.ghost)), (e.has("type") || e.has("shape") || e.has("box-shadow")) && (this.$btn.className = this._resetBtnClass())), e.has("height") && this._updateHeight();
|
|
81
|
+
}
|
|
82
|
+
connectedCallback() {
|
|
83
|
+
this.className = `l-btn-${this._state.size || "default"} ${this.className}`, super.connectedCallback(), this.isFormButton() && d(this, "click", this._handleClick), this._updateHeight();
|
|
84
|
+
}
|
|
85
|
+
disconnectedCallback() {
|
|
86
|
+
super.disconnectedCallback(), this.isFormButton() && u(this, "click", this._handleClick), this.$btn = void 0;
|
|
87
|
+
}
|
|
88
|
+
isFormButton() {
|
|
89
|
+
let e = this.getHtmlType();
|
|
90
|
+
return e === "submit" || e === "reset";
|
|
91
|
+
}
|
|
92
|
+
getHtmlType() {
|
|
93
|
+
return this._state.htmlType;
|
|
94
|
+
}
|
|
95
|
+
render_v2() {
|
|
96
|
+
return this._changedProperties.clear(), {
|
|
97
|
+
styleSheets: [a, i],
|
|
98
|
+
template: this.render()
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
afterInit() {
|
|
102
|
+
this.$btn ||= o(".l-btn", this.root);
|
|
103
|
+
}
|
|
104
|
+
render() {
|
|
105
|
+
let e = document.createElement("button"), t = this._state.loading, n = this._state.text, r = this._state.ghost;
|
|
106
|
+
e.className = this._resetBtnClass(), (this.disabled || t) && (e.disabled = !0), e.type = this._state.htmlType;
|
|
107
|
+
let i = this.applyColor(this._state.color || "", n, r);
|
|
108
|
+
return i && (e.style.cssText = i), e.innerHTML = t ? this.loadingBody() : "<slot></slot>", e.setAttribute("part", "default"), e;
|
|
109
|
+
}
|
|
110
|
+
loadingBody() {
|
|
111
|
+
let e = this._state.loadingText, t = ["<l-loading-icon class=\"l-rotate-anim\"></l-loading-icon>"];
|
|
112
|
+
return e ? t.push(`<span>${e}</span>`) : t.push("<slot></slot>"), t.join("");
|
|
113
|
+
}
|
|
114
|
+
applyColor(e, t = !1, n = !1) {
|
|
115
|
+
if (!e) return "";
|
|
116
|
+
let r = p(e, 1, !0), i = p(e, 3, !1);
|
|
117
|
+
return l({
|
|
118
|
+
"--l-btn-border-color": t ? "transparent" : e,
|
|
119
|
+
"--l-btn-text-color": n || t ? e : "#ffffff",
|
|
120
|
+
"--l-btn-hover-text-color": n || t ? r : "#ffffff",
|
|
121
|
+
"--l-btn-background": n || t ? "transparent" : e,
|
|
122
|
+
"--l-btn-active-text-color": n || t ? i : "#ffffff",
|
|
123
|
+
"--l-btn-hover-border-color": t ? "transparent" : r,
|
|
124
|
+
"--l-btn-hover-background": n || t ? "transparent" : r,
|
|
125
|
+
"--l-btn-active-background": n || t ? "transparent" : i,
|
|
126
|
+
"--l-btn-active-border-color": t ? "transparent" : i
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
_updateHeight() {
|
|
130
|
+
this._state.height ? this.style.setProperty("--l-btn-height", this._state.height) : this.style.removeProperty("--l-btn-height");
|
|
131
|
+
}
|
|
132
|
+
_resetBtnClass() {
|
|
133
|
+
return c([
|
|
134
|
+
"l-btn",
|
|
135
|
+
`l-btn-${this._state.type}`,
|
|
136
|
+
`l-btn-${this._state.shape}`,
|
|
137
|
+
`l-btn-${this._state.boxShadow}`,
|
|
138
|
+
this._state.ghost ? "l-btn-ghost" : "",
|
|
139
|
+
this._state.text ? "l-btn-text" : "",
|
|
140
|
+
this._state.loading ? "l-btn-loading" : ""
|
|
141
|
+
]);
|
|
142
|
+
}
|
|
143
|
+
_handleClick = () => {
|
|
144
|
+
(this._state.htmlType === "reset" || this._state.htmlType === "submit") && this.emit("form-action", {
|
|
145
|
+
bubbles: !0,
|
|
146
|
+
composed: !0,
|
|
147
|
+
detail: this._state.htmlType
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { m as default };
|
package/lib/calendar/index.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ export default class Calendar extends BaseComponent<CalendarState> {
|
|
|
34
34
|
rerenderBody(): void;
|
|
35
35
|
rerender(): string;
|
|
36
36
|
render_v2(): {
|
|
37
|
-
template
|
|
38
|
-
style
|
|
37
|
+
template: string;
|
|
38
|
+
style: string[];
|
|
39
39
|
};
|
|
40
40
|
}
|
|
41
41
|
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
type CardState = {
|
|
3
|
+
/** 标题 */
|
|
4
|
+
headerText?: string;
|
|
5
|
+
/** 是否显示标题 */
|
|
6
|
+
showHeader: boolean;
|
|
7
|
+
/** 底部区域内容 */
|
|
8
|
+
footerText: string;
|
|
9
|
+
/** 是否显示底部区域 */
|
|
10
|
+
showFooter: boolean;
|
|
11
|
+
};
|
|
12
|
+
export default class Card extends BaseComponent<CardState> {
|
|
13
|
+
static baseName: string;
|
|
14
|
+
constructor();
|
|
15
|
+
static get observedAttributes(): string[];
|
|
16
|
+
protected attributeChanged(name: string, _oldValue: string, newValue: string): void;
|
|
17
|
+
render_v2(): {
|
|
18
|
+
style: string;
|
|
19
|
+
template: DocumentFragment;
|
|
20
|
+
};
|
|
21
|
+
render(): DocumentFragment;
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n } from "./utils/index.js";
|
|
3
|
+
import { $$ as r } from "ph-utils/browser";
|
|
4
|
+
//#region src/components/card/index.less?inline
|
|
5
|
+
var i = ":host{--l-card-bg:#fff;--l-card-text-color:#333;--l-card-border-color:var(--l-border-color,#e8e8e8);border:1px solid var(--l-card-border-color);background-color:var(--l-card-bg);color:var(--l-card-text-color);border-radius:4px;display:block;box-shadow:0 1px 3px #0000001a,0 1px 2px -1px #0000001a}.l-card__header{border-bottom:1px solid var(--l-card-border-color);box-sizing:border-box;justify-content:space-between;align-items:center;padding:15px;display:flex}.l-card__footer{border-top:1px solid var(--l-card-border-color);box-sizing:border-box;padding:15px}.l-card__body{padding:15px}.l-header-extra:empty{display:none}:host-context(html.dark){--l-card-bg:#232324;--l-card-text-color:#ffffffb3;--l-card-border-color:#484849}", a = class extends e {
|
|
6
|
+
static baseName = "card";
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this.version = 2, this._state = {
|
|
9
|
+
headerText: "",
|
|
10
|
+
showHeader: !0,
|
|
11
|
+
footerText: "",
|
|
12
|
+
showFooter: !1
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return [
|
|
17
|
+
"header-text",
|
|
18
|
+
"show-header",
|
|
19
|
+
"footer-text",
|
|
20
|
+
"show-footer"
|
|
21
|
+
];
|
|
22
|
+
}
|
|
23
|
+
attributeChanged(e, r, i) {
|
|
24
|
+
switch (e) {
|
|
25
|
+
case "header-text":
|
|
26
|
+
case "footer-text":
|
|
27
|
+
this._state[t(e)] = i;
|
|
28
|
+
break;
|
|
29
|
+
case "show-header":
|
|
30
|
+
case "show-footer": this._state[t(e)] = n(i, !1, e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
render_v2() {
|
|
34
|
+
return {
|
|
35
|
+
style: i,
|
|
36
|
+
template: this.render()
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
let e = document.createDocumentFragment();
|
|
41
|
+
if (this._state.showHeader) {
|
|
42
|
+
let t = r("div", {
|
|
43
|
+
class: "l-card__header",
|
|
44
|
+
part: "header"
|
|
45
|
+
}, [this._state.headerText ? r("span", { textContent: this._state.headerText }) : r("slot", { name: "header" }), r("slot", { name: "header-extra" })]);
|
|
46
|
+
e.appendChild(t);
|
|
47
|
+
}
|
|
48
|
+
let t = r("div", {
|
|
49
|
+
class: "l-card__body",
|
|
50
|
+
part: "body"
|
|
51
|
+
}, [r("slot")]);
|
|
52
|
+
if (e.appendChild(t), this._state.showFooter) {
|
|
53
|
+
let t = r("div", {
|
|
54
|
+
class: "l-card__footer",
|
|
55
|
+
part: "footer"
|
|
56
|
+
}, [this._state.footerText ? r("span", { textContent: this._state.footerText }) : r("slot", { name: "footer" })]);
|
|
57
|
+
e.appendChild(t);
|
|
58
|
+
}
|
|
59
|
+
return e;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
//#endregion
|
|
63
|
+
export { a as t };
|
|
@@ -12,8 +12,8 @@ export default class DatePicker extends FormInner<DatePickerState> {
|
|
|
12
12
|
attributeChange(name: string, oldValue: string, newValue: string): void;
|
|
13
13
|
protected updateDOM(changedProps: Set<string>): void;
|
|
14
14
|
render_v2(): {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
style: string[];
|
|
16
|
+
template: DocumentFragment;
|
|
17
17
|
};
|
|
18
18
|
private _popoverContentRender;
|
|
19
19
|
private _updateWidth;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type AlertOptions = {
|
|
2
|
+
/** 是否显示取消按钮 */
|
|
3
|
+
showCancel?: boolean;
|
|
4
|
+
/** 右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示, 默认: 0 */
|
|
5
|
+
close?: number;
|
|
6
|
+
/** 点击蒙层是否允许关闭, 默认: false */
|
|
7
|
+
maskClosable?: boolean;
|
|
8
|
+
/** 显示图标 */
|
|
9
|
+
icon?: () => HTMLElement;
|
|
10
|
+
};
|
|
11
|
+
type PromptOptions = AlertOptions & {
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
};
|
|
14
|
+
declare function alert(content: string, title?: string, option?: AlertOptions): Promise<boolean>;
|
|
15
|
+
declare function confirm(content: string, title?: string, option?: AlertOptions): Promise<boolean>;
|
|
16
|
+
declare function prompt(label: string, title?: string, option?: PromptOptions): Promise<string | false>;
|
|
17
|
+
declare const _default: {
|
|
18
|
+
alert: typeof alert;
|
|
19
|
+
confirm: typeof confirm;
|
|
20
|
+
prompt: typeof prompt;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { regist as e } from "../utils/index.js";
|
|
2
|
+
import t from "../icon/info.js";
|
|
3
|
+
import n from "./index.js";
|
|
4
|
+
import { t as r } from "../dialog_container-BNPQ9n0V.js";
|
|
5
|
+
import i from "../button/index.js";
|
|
6
|
+
import a from "../icon/close.js";
|
|
7
|
+
import { t as o } from "../form_item-BqPMRABd.js";
|
|
8
|
+
import s from "../input/index.js";
|
|
9
|
+
import { $$ as c, $one as l } from "ph-utils/browser";
|
|
10
|
+
//#region src/components/dialog/dialog_box.ts
|
|
11
|
+
function u(e, t, r, i = "alert") {
|
|
12
|
+
return new Promise((a) => {
|
|
13
|
+
let o = [];
|
|
14
|
+
if (r.icon) {
|
|
15
|
+
let e = r.icon();
|
|
16
|
+
e.setAttribute("slot", "header"), o.push(e.outerHTML);
|
|
17
|
+
}
|
|
18
|
+
o.push(`<span slot="header">${e}</span>`), i === "prompt" ? (o.push(`<l-form-item label="${t}" label-position="top" inner-block>`), o.push(`<l-input placeholder="${r.placeholder || ""}"></l-input>`), o.push("</l-form-item>")) : o.push(`<span>${t}</span>`);
|
|
19
|
+
let s = document.createElement("dialog"), c = document.createElement("l-dialog-container");
|
|
20
|
+
c.setAttribute("header", e), c.setAttribute("close", `${r.close}`), c.setAttribute("show-cancel", `${r.showCancel}`), c.innerHTML = o.join(""), s.appendChild(c), document.body.appendChild(s);
|
|
21
|
+
let u = new n({
|
|
22
|
+
el: s,
|
|
23
|
+
maskClosable: r.maskClosable,
|
|
24
|
+
close: r.close,
|
|
25
|
+
onAction: (e, t) => {
|
|
26
|
+
if (e === "ok") {
|
|
27
|
+
let e = !0;
|
|
28
|
+
if (i === "prompt") {
|
|
29
|
+
let t = l("l-input", c);
|
|
30
|
+
e = t ? t.value : "";
|
|
31
|
+
}
|
|
32
|
+
t(), a(e);
|
|
33
|
+
} else t(), a(!1);
|
|
34
|
+
setTimeout(() => {
|
|
35
|
+
u.destroy(), s.remove();
|
|
36
|
+
}, 350);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
u.open();
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
function d(t, n, o) {
|
|
43
|
+
e([
|
|
44
|
+
i,
|
|
45
|
+
r,
|
|
46
|
+
a
|
|
47
|
+
]);
|
|
48
|
+
let s = {
|
|
49
|
+
showCancel: !1,
|
|
50
|
+
close: 0,
|
|
51
|
+
maskClosable: !1,
|
|
52
|
+
icon: void 0,
|
|
53
|
+
...o
|
|
54
|
+
};
|
|
55
|
+
return u(n || "提示", t, s, "alert");
|
|
56
|
+
}
|
|
57
|
+
function f(n, o, s) {
|
|
58
|
+
e([
|
|
59
|
+
i,
|
|
60
|
+
r,
|
|
61
|
+
a,
|
|
62
|
+
t
|
|
63
|
+
]);
|
|
64
|
+
let l = {
|
|
65
|
+
showCancel: !0,
|
|
66
|
+
close: 0,
|
|
67
|
+
maskClosable: !0,
|
|
68
|
+
icon: () => c("l-info-icon", { style: "color:#1890ff;" }),
|
|
69
|
+
...s
|
|
70
|
+
};
|
|
71
|
+
return u(o || "提示", n, l, "confirm");
|
|
72
|
+
}
|
|
73
|
+
function p(n, c, l) {
|
|
74
|
+
e([
|
|
75
|
+
i,
|
|
76
|
+
r,
|
|
77
|
+
a,
|
|
78
|
+
t,
|
|
79
|
+
o,
|
|
80
|
+
s
|
|
81
|
+
]);
|
|
82
|
+
let d = {
|
|
83
|
+
showCancel: !0,
|
|
84
|
+
close: 0,
|
|
85
|
+
maskClosable: !0,
|
|
86
|
+
placeholder: "",
|
|
87
|
+
icon: void 0,
|
|
88
|
+
...l
|
|
89
|
+
};
|
|
90
|
+
return u(c || "提示", n, d, "prompt");
|
|
91
|
+
}
|
|
92
|
+
var m = {
|
|
93
|
+
alert: d,
|
|
94
|
+
confirm: f,
|
|
95
|
+
prompt: p
|
|
96
|
+
};
|
|
97
|
+
//#endregion
|
|
98
|
+
export { m as default };
|
|
@@ -15,9 +15,13 @@ type DialogContainerState = {
|
|
|
15
15
|
/** 确定按钮文本 */
|
|
16
16
|
okText: string;
|
|
17
17
|
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
18
|
-
|
|
18
|
+
close: number;
|
|
19
19
|
/** 容器类名 */
|
|
20
20
|
containerClass?: string;
|
|
21
|
+
/** 是否是移动风格弹出框 */
|
|
22
|
+
mobile: boolean;
|
|
23
|
+
/** 确定按钮 loading */
|
|
24
|
+
confirmLoading: boolean;
|
|
21
25
|
};
|
|
22
26
|
export default class DialogContainer extends BaseComponent<DialogContainerState> {
|
|
23
27
|
#private;
|
|
@@ -28,8 +32,8 @@ export default class DialogContainer extends BaseComponent<DialogContainerState>
|
|
|
28
32
|
static get observedAttributes(): string[] | null | undefined;
|
|
29
33
|
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
30
34
|
render_v2(): {
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
style: string;
|
|
36
|
+
template: DocumentFragment;
|
|
33
37
|
};
|
|
34
38
|
render(): DocumentFragment;
|
|
35
39
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../dialog_container-
|
|
1
|
+
import { t as e } from "../dialog_container-BNPQ9n0V.js";
|
|
2
2
|
export { e as default };
|
package/lib/dialog/index.d.ts
CHANGED
|
@@ -10,21 +10,43 @@ type DialogProps = {
|
|
|
10
10
|
/** 是否可以通过点击 mask 关闭对话框 */
|
|
11
11
|
maskClosable?: boolean;
|
|
12
12
|
/** 是否显示右上角关闭按钮, 1 - 显示在框内, 2 - 显示在框角, 0 - 不显示 */
|
|
13
|
-
|
|
13
|
+
close?: number;
|
|
14
14
|
};
|
|
15
15
|
/** 初始化对话框配置 */
|
|
16
16
|
type DialogInitialParams = DialogProps & {
|
|
17
17
|
/** dialog 节点 */
|
|
18
18
|
el: HTMLDialogElement | string;
|
|
19
19
|
/** 返回 true 表明手动调用 done 关闭 */
|
|
20
|
-
onAction?: (action: string, done: () => void) =>
|
|
20
|
+
onAction?: (action: string, done: () => void) => void;
|
|
21
21
|
};
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
22
|
+
export default class Dialog {
|
|
23
|
+
private $dialog;
|
|
24
|
+
private $container;
|
|
25
|
+
private config;
|
|
26
|
+
constructor(option?: DialogInitialParams);
|
|
27
|
+
private handleKeydown;
|
|
28
|
+
private handleClick;
|
|
29
|
+
private handleContainerAction;
|
|
30
|
+
/**
|
|
31
|
+
* 初始化对话框
|
|
32
|
+
* @param option 配置项
|
|
33
|
+
*/
|
|
34
|
+
init(option: DialogInitialParams): void;
|
|
35
|
+
/**
|
|
36
|
+
* 打开对话框
|
|
37
|
+
*/
|
|
38
|
+
open(): void;
|
|
39
|
+
/**
|
|
40
|
+
* 关闭对话框
|
|
41
|
+
*/
|
|
42
|
+
close(): void;
|
|
43
|
+
destroy(): void;
|
|
44
|
+
setProp(key: keyof DialogProps, value: DialogProps[keyof DialogProps]): void;
|
|
45
|
+
setProps(props: DialogProps): void;
|
|
46
|
+
/**
|
|
47
|
+
* 设置确定按钮 loading 状态
|
|
48
|
+
* @param loading 是否 loading
|
|
49
|
+
*/
|
|
50
|
+
setConfirmLoading(loading: boolean): void;
|
|
51
|
+
}
|
|
52
|
+
export {};
|