litos-ui 0.20.0 → 0.21.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-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 +156 -2
- package/lib/dialog/dialog_container_style.d.ts +2 -0
- package/lib/dialog/dialog_container_style.js +2 -0
- package/lib/dialog/index.d.ts +33 -11
- package/lib/dialog/index.js +45 -47
- package/lib/dialog_container_style-C1s0aBf7.js +5 -0
- 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/arrow_down.js +1 -1
- package/lib/icon/arrow_left.js +1 -1
- package/lib/icon/arrow_right.js +1 -1
- package/lib/icon/arrow_up.js +1 -1
- package/lib/icon/base.d.ts +3 -2
- package/lib/icon/base.js +63 -2
- package/lib/icon/calendar.js +1 -1
- package/lib/icon/caret_bottom.js +1 -1
- package/lib/icon/caret_top.js +1 -1
- package/lib/icon/close.js +1 -1
- package/lib/icon/close_filled.js +1 -1
- package/lib/icon/copy.d.ts +6 -0
- package/lib/icon/copy.js +13 -0
- package/lib/icon/d_arrow_left.js +1 -1
- package/lib/icon/d_arrow_right.js +1 -1
- package/lib/icon/font_icon.js +1 -1
- package/lib/icon/icon_style.d.ts +2 -0
- package/lib/icon/icon_style.js +2 -0
- package/lib/icon/info.js +1 -1
- package/lib/icon/loading.js +1 -1
- package/lib/icon/moon.js +1 -1
- package/lib/icon/more.js +1 -1
- package/lib/icon/reduction.js +1 -1
- package/lib/icon/refresh.js +1 -1
- package/lib/icon/refresh_left.js +1 -1
- package/lib/icon/refresh_right.js +1 -1
- package/lib/icon/search.js +1 -1
- package/lib/icon/select.js +1 -1
- package/lib/icon/sort.js +1 -1
- package/lib/icon/success.js +1 -1
- package/lib/icon/sun.js +1 -1
- package/lib/icon/theme_default.js +1 -1
- package/lib/icon/warn.js +1 -1
- package/lib/icon/zoom_in.js +1 -1
- package/lib/icon/zoom_out.js +1 -1
- package/lib/icon_style-J7iiDS_a.js +5 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.js +74 -69
- package/lib/input/index.d.ts +2 -2
- package/lib/input_number/index.d.ts +59 -0
- package/lib/input_number/index.js +203 -0
- package/lib/input_number/style.d.ts +2 -0
- package/lib/input_number/style.js +2 -0
- 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.d.ts +22 -0
- 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-C5wUmE2b.js +5 -0
- 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/base-Dyj1rzaK.js +0 -61
- package/lib/button-CDYYpQu6.js +0 -151
- package/lib/dialog_container-Bq6HsKey.js +0 -127
|
@@ -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 r from "./dialog_container.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
|
-
template
|
|
32
|
-
|
|
35
|
+
template: DocumentFragment;
|
|
36
|
+
styleSheets: CSSStyleSheet[];
|
|
33
37
|
};
|
|
34
38
|
render(): DocumentFragment;
|
|
35
39
|
}
|
|
@@ -1,2 +1,156 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import e from "../base.js";
|
|
2
|
+
import { t } from "../dialog_container_style-C1s0aBf7.js";
|
|
3
|
+
import { $ as n, $$ as r, $one as i, formatClass as a, iterate as o, off as s, on as c, shouldEventNext as l } from "ph-utils/browser";
|
|
4
|
+
//#region src/components/dialog/dialog_container.ts
|
|
5
|
+
var u = class extends e {
|
|
6
|
+
static baseName = "dialog-container";
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this.version = 2, this._state = {
|
|
9
|
+
showHeader: !0,
|
|
10
|
+
showFooter: !0,
|
|
11
|
+
showCancel: !0,
|
|
12
|
+
cancelText: "取消",
|
|
13
|
+
showOk: !0,
|
|
14
|
+
okText: "确定",
|
|
15
|
+
close: 1,
|
|
16
|
+
mobile: !1,
|
|
17
|
+
confirmLoading: !1
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
afterInit() {
|
|
21
|
+
this._state.close === 2 && this.classList.add("l-container-close-outside");
|
|
22
|
+
let e = n("[data-action]", this.root);
|
|
23
|
+
o(e, (e) => {
|
|
24
|
+
c(e, "click", this.#e);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
beforeDestroy() {
|
|
28
|
+
let e = n("[data-action]", this.root);
|
|
29
|
+
o(e, (e) => {
|
|
30
|
+
s(e, "click", this.#e);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
#e(e) {
|
|
34
|
+
let [t, n] = l(e, "data-action");
|
|
35
|
+
t && this.emit("dialogAction", { detail: { action: n } });
|
|
36
|
+
}
|
|
37
|
+
static get observedAttributes() {
|
|
38
|
+
return [
|
|
39
|
+
"show-header",
|
|
40
|
+
"header",
|
|
41
|
+
"show-footer",
|
|
42
|
+
"show-cancel",
|
|
43
|
+
"cancel-text",
|
|
44
|
+
"show-ok",
|
|
45
|
+
"ok-text",
|
|
46
|
+
"close",
|
|
47
|
+
"container-class",
|
|
48
|
+
"mobile",
|
|
49
|
+
"confirm-loading"
|
|
50
|
+
];
|
|
51
|
+
}
|
|
52
|
+
attributeChanged(e, t, n) {
|
|
53
|
+
switch (e) {
|
|
54
|
+
case "show-header":
|
|
55
|
+
this._state.showHeader = n !== null, this.connectedCallback();
|
|
56
|
+
break;
|
|
57
|
+
case "header":
|
|
58
|
+
this._state.header = n || void 0, this.connectedCallback();
|
|
59
|
+
break;
|
|
60
|
+
case "show-footer":
|
|
61
|
+
this._state.showFooter = n !== null, this.connectedCallback();
|
|
62
|
+
break;
|
|
63
|
+
case "show-cancel":
|
|
64
|
+
this._state.showCancel = n !== null, this.connectedCallback();
|
|
65
|
+
break;
|
|
66
|
+
case "cancel-text":
|
|
67
|
+
this._state.cancelText = n || "取消", this.connectedCallback();
|
|
68
|
+
break;
|
|
69
|
+
case "show-ok":
|
|
70
|
+
this._state.showOk = n !== null, this.connectedCallback();
|
|
71
|
+
break;
|
|
72
|
+
case "ok-text":
|
|
73
|
+
this._state.okText = n || "确定", this.connectedCallback();
|
|
74
|
+
break;
|
|
75
|
+
case "close":
|
|
76
|
+
this._state.close = Number(n), this._state.close === 2 ? this.classList.add("l-container-close-outside") : this.classList.remove("l-container-close-outside");
|
|
77
|
+
let e = i(".l-btn-dialog-close", this.root);
|
|
78
|
+
this._state.close === 0 && e ? (s(e, "click", this.#e), e.remove()) : e ? e.className = this.#t() : (e = this.#n(), c(e, "click", this.#e), this.root.appendChild(e));
|
|
79
|
+
break;
|
|
80
|
+
case "container-class":
|
|
81
|
+
this._state.containerClass = n || void 0, this.connectedCallback();
|
|
82
|
+
break;
|
|
83
|
+
case "mobile":
|
|
84
|
+
this._state.mobile = n !== null, this.connectedCallback();
|
|
85
|
+
break;
|
|
86
|
+
case "confirm-loading":
|
|
87
|
+
this._state.confirmLoading = n !== null;
|
|
88
|
+
let t = i("[data-action=\"ok\"]", this.root);
|
|
89
|
+
t && t.setAttribute("loading", this._state.confirmLoading.toString());
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
#t() {
|
|
93
|
+
return `l-btn-dialog-close l-dialog-close${this._state.close}`;
|
|
94
|
+
}
|
|
95
|
+
#n() {
|
|
96
|
+
let e = r("l-button", {
|
|
97
|
+
shape: "circle",
|
|
98
|
+
type: "normal",
|
|
99
|
+
class: this.#t(),
|
|
100
|
+
"data-action": "close",
|
|
101
|
+
part: "close-icon"
|
|
102
|
+
}), t = r("l-close-icon");
|
|
103
|
+
return e.appendChild(t), e;
|
|
104
|
+
}
|
|
105
|
+
render_v2() {
|
|
106
|
+
return {
|
|
107
|
+
template: this.render(),
|
|
108
|
+
styleSheets: [t]
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
let e = document.createDocumentFragment();
|
|
113
|
+
this._state.close !== 0 && e.appendChild(this.#n());
|
|
114
|
+
let t = r("div", {
|
|
115
|
+
class: ["l-dialog-main", this._state.mobile ? "l-dialog-main--mobile" : ""],
|
|
116
|
+
part: "main"
|
|
117
|
+
});
|
|
118
|
+
if (this._state.showHeader) {
|
|
119
|
+
let e = r("header", {
|
|
120
|
+
class: "l-dialog-header",
|
|
121
|
+
part: "header"
|
|
122
|
+
}), n = r("slot", { name: "header" });
|
|
123
|
+
n.textContent = this._state.header || "", e.appendChild(n), t.appendChild(e);
|
|
124
|
+
}
|
|
125
|
+
let n = r("div", {
|
|
126
|
+
class: a(["l-dialog-container", this._state.containerClass]),
|
|
127
|
+
part: "container"
|
|
128
|
+
}), i = r("slot");
|
|
129
|
+
if (n.appendChild(i), t.appendChild(n), this._state.showFooter) {
|
|
130
|
+
let e = r("div", {
|
|
131
|
+
class: "l-dialog-footer",
|
|
132
|
+
part: "footer"
|
|
133
|
+
}), n = r("slot", { name: "footer" });
|
|
134
|
+
if (this._state.showCancel) {
|
|
135
|
+
let e = r("l-button", {
|
|
136
|
+
"data-action": "cancel",
|
|
137
|
+
text: this._state.mobile
|
|
138
|
+
});
|
|
139
|
+
e.textContent = this._state.cancelText, n.appendChild(e);
|
|
140
|
+
}
|
|
141
|
+
if (this._state.showOk) {
|
|
142
|
+
let e = r("l-button", {
|
|
143
|
+
type: "primary",
|
|
144
|
+
"data-action": "ok",
|
|
145
|
+
loading: this._state.confirmLoading,
|
|
146
|
+
text: this._state.mobile
|
|
147
|
+
});
|
|
148
|
+
e.textContent = this._state.okText, n.appendChild(e);
|
|
149
|
+
}
|
|
150
|
+
e.appendChild(n), t.appendChild(e);
|
|
151
|
+
}
|
|
152
|
+
return e.appendChild(t), e;
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { u as default };
|