litos-ui 0.17.4 → 0.18.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/README.md +49 -49
- package/lib/animation-CTt9qgA7.js +4 -0
- package/lib/base-Dm0WS1pK.js +62 -0
- package/lib/base.js +111 -147
- package/lib/button/index.d.ts +8 -3
- package/lib/button/index.js +2 -137
- package/lib/button-CC5PmAb1.js +146 -0
- package/lib/calendar/index.d.ts +15 -4
- package/lib/calendar/index.js +2 -95
- package/lib/calendar-DeP6yZB0.js +149 -0
- package/lib/carousel/index.js +2 -280
- package/lib/carousel/item.js +2 -15
- package/lib/carousel-D4Fe3LEx.js +272 -0
- package/lib/check/checkbox.js +2 -18
- package/lib/check/checkbox_group.js +6 -6
- package/lib/check/radio.js +2 -15
- package/lib/check/radio_group.js +9 -9
- package/lib/check-B0XraJvb.js +73 -0
- package/lib/check-CvGaONEx.js +117 -0
- package/lib/checkbox-DbWsmAaL.js +16 -0
- package/lib/collapse/index.d.ts +18 -11
- package/lib/collapse/index.js +2 -88
- package/lib/collapse/item.d.ts +28 -9
- package/lib/collapse/item.js +2 -115
- package/lib/collapse/types.d.ts +7 -0
- package/lib/collapse-CeKRZ-43.js +104 -0
- package/lib/color_picker/index.js +2 -42
- package/lib/color_picker-D0brKFm-.js +41 -0
- package/lib/date_picker/index.d.ts +23 -0
- package/lib/date_picker/index.js +3 -0
- package/lib/date_picker-DQGoiN8v.js +103 -0
- package/lib/date_picker_ori/index.js +2 -129
- package/lib/date_picker_ori-aRuSSi9D.js +122 -0
- package/lib/description_panel/index.js +2 -66
- package/lib/description_panel-Df_8rVbX.js +57 -0
- package/lib/dialog/dialog_container.js +2 -131
- package/lib/dialog/index.js +67 -85
- package/lib/dialog_container-DcN87wj0.js +126 -0
- package/lib/esm-sVEoAVPu.js +244 -0
- package/lib/form/form_item.d.ts +1 -0
- package/lib/form/form_item.js +2 -136
- package/lib/form/index.js +2 -147
- package/lib/form-DdU0yK0k.js +154 -0
- package/lib/form_inner-DR9tyB_r.js +117 -0
- package/lib/form_item-Bv-YafZK.js +137 -0
- package/lib/icon/arrow_down.js +12 -12
- package/lib/icon/arrow_left.js +9 -9
- package/lib/icon/arrow_right.js +9 -9
- package/lib/icon/arrow_up.js +12 -12
- package/lib/icon/base.d.ts +16 -2
- package/lib/icon/base.js +2 -38
- package/lib/icon/calendar.d.ts +5 -0
- package/lib/icon/calendar.js +10 -0
- package/lib/icon/caret_bottom.js +9 -9
- package/lib/icon/caret_top.js +9 -9
- package/lib/icon/close.js +9 -9
- package/lib/icon/close_filled.js +12 -12
- package/lib/icon/d_arrow_left.js +12 -12
- package/lib/icon/d_arrow_right.js +12 -12
- package/lib/icon/font_icon.d.ts +2 -3
- package/lib/icon/font_icon.js +35 -39
- package/lib/icon/info.js +12 -12
- package/lib/icon/loading.js +9 -9
- package/lib/icon/moon.js +12 -12
- package/lib/icon/more.js +12 -12
- package/lib/icon/reduction.js +12 -12
- package/lib/icon/refresh.d.ts +5 -0
- package/lib/icon/refresh.js +10 -0
- package/lib/icon/refresh_left.js +12 -12
- package/lib/icon/refresh_right.js +9 -9
- package/lib/icon/search.js +9 -9
- package/lib/icon/select.js +12 -12
- package/lib/icon/sort.js +9 -9
- package/lib/icon/success.js +12 -12
- package/lib/icon/sun.js +12 -12
- package/lib/icon/theme_default.js +12 -12
- package/lib/icon/warn.js +12 -12
- package/lib/icon/zoom_in.js +12 -12
- package/lib/icon/zoom_out.js +12 -12
- package/lib/image/image_preview.js +2 -104
- package/lib/image/index.js +2 -176
- package/lib/image-CeQVfS-v.js +162 -0
- package/lib/image_preview-PzZzwo6m.js +92 -0
- package/lib/index.d.ts +10 -4
- package/lib/index.js +80 -169
- package/lib/input/index.d.ts +6 -2
- package/lib/input/index.js +188 -203
- package/lib/input-DjKxcxry.js +4 -0
- package/lib/input_inner-BKJg9n9A.js +4 -0
- package/lib/item-Cuw_ZPyn.js +14 -0
- package/lib/item-DV842Aux.js +57 -0
- package/lib/item-ZXLWFzSm.js +119 -0
- package/lib/list/index.js +2 -58
- package/lib/list-CU7vHS6s.js +51 -0
- package/lib/loading/index.d.ts +4 -2
- package/lib/loading/index.js +109 -123
- package/lib/mask/index.js +2 -105
- package/lib/mask-BlV5QfTj.js +112 -0
- package/lib/md_input/index.js +2 -60
- package/lib/md_input-DSQx5TMW.js +58 -0
- package/lib/menu/index.js +2 -105
- package/lib/menu/menu_item.js +2 -21
- package/lib/menu/sub_menu.js +2 -83
- package/lib/menu-DAtplYAH.js +91 -0
- package/lib/menu_item-BW1Tu11Q.js +20 -0
- package/lib/message/index.js +67 -60
- package/lib/modal/index.js +2 -196
- package/lib/modal/modal_box.js +87 -86
- package/lib/modal-DWyWrN-D.js +192 -0
- package/lib/page_header/index.js +2 -109
- package/lib/page_header-DdeRDN4U.js +101 -0
- package/lib/pagination/index.js +2 -248
- package/lib/pagination-BoPzSPjT.js +210 -0
- package/lib/polygon/index.js +2 -27
- package/lib/polygon-C4Ow2lxi.js +20 -0
- package/lib/qrcode/index.d.ts +13 -4
- package/lib/qrcode/index.js +2 -57
- package/lib/qrcode-BFxsD_OP.js +64 -0
- package/lib/radio-2mNSYujz.js +13 -0
- package/lib/select/index.js +3 -401
- package/lib/select-CAgggYh7.js +326 -0
- package/lib/select_ori/index.js +47 -50
- package/lib/space/index.js +2 -35
- package/lib/space-CpTmBfHP.js +38 -0
- package/lib/sub_menu-D1s8ABNu.js +75 -0
- package/lib/switch/index.js +2 -50
- package/lib/switch-BaVBi5Ip.js +48 -0
- package/lib/tabbar/index.js +2 -109
- package/lib/tabbar/item.js +2 -58
- package/lib/tabbar-4_d2Fj1n.js +91 -0
- package/lib/table/index.js +2 -269
- package/lib/table-Hifj8jAX.js +234 -0
- package/lib/tabs/index.js +38 -42
- package/lib/tag/index.js +2 -72
- package/lib/tag-DPENZf_V.js +76 -0
- package/lib/theme/index.js +2 -89
- package/lib/theme/theme_color.js +22 -26
- package/lib/theme-BRTI2-Yk.js +83 -0
- package/lib/utils/clickoutside.js +18 -18
- package/lib/utils/context_provide.js +21 -21
- package/lib/utils/event.js +13 -18
- package/lib/utils/index.js +55 -58
- package/lib/utils/popover.d.ts +4 -1
- package/lib/utils/popover.js +276 -352
- package/lib/utils/transition.js +33 -31
- package/package.json +10 -11
- package/styles/container.css +4 -0
- package/styles/datepicker.css +55 -0
- package/styles/popover.css +14 -1
- package/lib/animation-DttknHkX.js +0 -4
- package/lib/calendar/langs.js +0 -8
- package/lib/carousel/timer.js +0 -19
- package/lib/check/check.js +0 -118
- package/lib/check/index.js +0 -68
- package/lib/check-CksURvTv.js +0 -4
- package/lib/form/form_inner.js +0 -125
- package/lib/form/types.js +0 -1
- package/lib/index-CrMiSe0x.js +0 -249
- package/lib/index-DY6m9Wbe.js +0 -4
- package/lib/litos-ui.css +0 -1
- package/lib/table/types.js +0 -1
package/lib/modal/index.js
CHANGED
|
@@ -1,196 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import { parseAttrValue as n, unitNumberStr as g, kebabToCamel as u } from "../utils/index.js";
|
|
4
|
-
const y = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex, 100)}.l-modal-wrapper{position:fixed;top:0;left:0;width:100%;height:100%;z-index:calc(var(--l-modal-zindex, 100) + 1)}.l-modal{--l-modal-translate: translate3d(0, 80px, 0);background-color:#fff;border-radius:5px;width:var(--l-modal-width, 27%);margin:auto;box-shadow:0 0 8px #0000001a;position:relative;opacity:1;transform:var(--l-modal-translate) scaleZ(1);transition:opacity .3s,transform .3s}.l-modal-header{display:block;padding:10px;font-size:16px;border-bottom:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));font-weight:600;display:flex;align-items:center;gap:5px}.l-modal-footer{padding:10px;border-top:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06));display:flex;justify-content:flex-end;gap:10px}.l-modal-container{padding:var(--l-modal-container-padding, 15px 10px);font-size:14px}.l-btn-modal-close{--l-form-control-height: auto;position:absolute}.l-modal-close1{right:5px;top:8px}.l-modal-close1::part(default){width:auto;height:auto;padding:5px;border:none;font-size:16px}.l-modal-close2{right:-10px;top:-10px}.l-modal-close2::part(default){width:20px;height:20px;padding:0;background-color:#fff}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translateZ(0) scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:transparent;padding:20px 10px 5px;display:flex;justify-content:center}.l-modal--mobile .l-modal-container{--l-modal-container-padding: 5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{display:flex;justify-content:stretch;align-items:stretch;padding:0;text-align:center;height:50px;gap:0}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color, rgba(0, 0, 0, .06))}.l-modal--middle{--l-modal-translate: translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate: translate3d(0, -100%, 0);top:100%;width:100%;border-bottom-left-radius:0;border-bottom-right-radius:0}@media screen and (max-width:768px){:host{--l-modal-width: 80%}}", v = ".l-mask{position:fixed;z-index:var(--l-mask-zindex, 100);inset:0;background-color:#0009;transition:opacity .3s;opacity:1}";
|
|
5
|
-
class z extends f {
|
|
6
|
-
static baseName = "modal";
|
|
7
|
-
_bodyOverflow = "";
|
|
8
|
-
constructor() {
|
|
9
|
-
super(), this.version = 2, this._state = {
|
|
10
|
-
destroyOnClose: !1,
|
|
11
|
-
maskClosable: !0,
|
|
12
|
-
mask: !0,
|
|
13
|
-
cancel: !0,
|
|
14
|
-
cancelText: "取消",
|
|
15
|
-
okText: "确定",
|
|
16
|
-
confirmLoading: !1,
|
|
17
|
-
close: 1,
|
|
18
|
-
verticalAlign: "top",
|
|
19
|
-
mobile: !1,
|
|
20
|
-
show: !1,
|
|
21
|
-
header: !0,
|
|
22
|
-
footer: !0
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
static get observedAttributes() {
|
|
26
|
-
return [
|
|
27
|
-
"show",
|
|
28
|
-
"width",
|
|
29
|
-
"confirm-loading",
|
|
30
|
-
"destroy-on-close",
|
|
31
|
-
"mask-closable",
|
|
32
|
-
"mask",
|
|
33
|
-
"cancel",
|
|
34
|
-
"cancel-text",
|
|
35
|
-
"ok-text",
|
|
36
|
-
"close",
|
|
37
|
-
"vertical-align",
|
|
38
|
-
"mobile",
|
|
39
|
-
"z-index",
|
|
40
|
-
"header",
|
|
41
|
-
"footer",
|
|
42
|
-
"header-title"
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
attributeChanged(t, o, e) {
|
|
46
|
-
switch (t) {
|
|
47
|
-
case "show":
|
|
48
|
-
case "confirm-loading":
|
|
49
|
-
case "destroy-on-close":
|
|
50
|
-
case "mask-closable":
|
|
51
|
-
case "mask":
|
|
52
|
-
case "cancel":
|
|
53
|
-
case "mobile":
|
|
54
|
-
case "header":
|
|
55
|
-
case "footer":
|
|
56
|
-
this._state[u(t)] = n(e, !1, t);
|
|
57
|
-
break;
|
|
58
|
-
case "cancel-text":
|
|
59
|
-
this._state.cancelText = n(e, "取消");
|
|
60
|
-
break;
|
|
61
|
-
case "ok-text":
|
|
62
|
-
this._state.okText = n(e, "确定");
|
|
63
|
-
break;
|
|
64
|
-
case "close":
|
|
65
|
-
this._state.close = n(e, 1);
|
|
66
|
-
break;
|
|
67
|
-
case "width":
|
|
68
|
-
this._state[t] = g(e);
|
|
69
|
-
break;
|
|
70
|
-
case "vertical-align":
|
|
71
|
-
this._state.verticalAlign = n(e, "top");
|
|
72
|
-
break;
|
|
73
|
-
case "z-index":
|
|
74
|
-
this._state.zIndex = e;
|
|
75
|
-
break;
|
|
76
|
-
case "header-title":
|
|
77
|
-
this._state.headerTitle = e;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
updateDOM(t) {
|
|
82
|
-
if (t.has("show") && (this._state.show ? this.#t() : this.#a()), t.has("width") && this._setWidth(), t.has("confirm-loading")) {
|
|
83
|
-
const o = d('l-button[modal-action="ok"]', this.root);
|
|
84
|
-
o && o.setAttribute("loading", this._state.confirmLoading.toString());
|
|
85
|
-
}
|
|
86
|
-
t.has("z-index") && this._setZIndex();
|
|
87
|
-
}
|
|
88
|
-
afterInit() {
|
|
89
|
-
this._setWidth(), this._setZIndex(), this._state.show && this.#t();
|
|
90
|
-
}
|
|
91
|
-
render_v2() {
|
|
92
|
-
return {
|
|
93
|
-
style: [v, y]
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
_setZIndex() {
|
|
97
|
-
this._state.zIndex ? this.style.setProperty("--l-modal-zindex", this._state.zIndex) : this.style.removeProperty("--l-modal-zindex");
|
|
98
|
-
}
|
|
99
|
-
_setWidth() {
|
|
100
|
-
this._state.width ? this.style.setProperty("--l-modal-width", this._state.width) : this.style.removeProperty("--l-modal-width");
|
|
101
|
-
}
|
|
102
|
-
#t() {
|
|
103
|
-
this._bodyOverflow = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
|
|
104
|
-
let t = d(".l-modal-wrapper", this.root);
|
|
105
|
-
if (t) {
|
|
106
|
-
const o = d(".l-mask", this.root);
|
|
107
|
-
o && r(o, "mask-transition");
|
|
108
|
-
const e = d(".l-modal", this.root);
|
|
109
|
-
r(e, "modal-transition");
|
|
110
|
-
} else {
|
|
111
|
-
const o = document.createDocumentFragment();
|
|
112
|
-
let e = null;
|
|
113
|
-
this._state.mask && (e = a("div", { class: "l-mask l-modal-mask", part: "mask" }), o.appendChild(e)), t = a("div", { class: "l-modal-wrapper", part: "wrapper" });
|
|
114
|
-
const l = a("div", {
|
|
115
|
-
class: [
|
|
116
|
-
"l-modal",
|
|
117
|
-
`l-modal--${this._state.mobile ? "mobile" : "pc"}`,
|
|
118
|
-
`l-modal--${this._state.verticalAlign}`
|
|
119
|
-
],
|
|
120
|
-
part: "default"
|
|
121
|
-
});
|
|
122
|
-
if (l.setAttribute("modal-action", "modal"), this._state.close !== 0) {
|
|
123
|
-
const s = a("l-button", {
|
|
124
|
-
shape: "circle",
|
|
125
|
-
type: "normal",
|
|
126
|
-
class: `l-btn-modal-close l-modal-close${this._state.close}`,
|
|
127
|
-
"modal-action": "close"
|
|
128
|
-
}), i = a("l-close-icon");
|
|
129
|
-
s.appendChild(i), l.appendChild(s);
|
|
130
|
-
}
|
|
131
|
-
if (this._state.header) {
|
|
132
|
-
const s = a("header", { class: "l-modal-header", part: "header" }), i = a("slot", {
|
|
133
|
-
name: "header"
|
|
134
|
-
});
|
|
135
|
-
i.textContent = this._state.headerTitle || "", s.appendChild(i), l.appendChild(s);
|
|
136
|
-
}
|
|
137
|
-
const h = a("div", {
|
|
138
|
-
class: "l-modal-container",
|
|
139
|
-
part: "container"
|
|
140
|
-
}), p = a("slot");
|
|
141
|
-
if (h.appendChild(p), l.appendChild(h), this._state.footer) {
|
|
142
|
-
const s = a("footer", {
|
|
143
|
-
class: "l-modal-footer",
|
|
144
|
-
part: "footer"
|
|
145
|
-
}), i = a("slot", { name: "footer" });
|
|
146
|
-
if (this._state.cancel) {
|
|
147
|
-
const m = a("l-button", {
|
|
148
|
-
class: "l-modal-footer-btn",
|
|
149
|
-
text: this._state.mobile
|
|
150
|
-
});
|
|
151
|
-
m.textContent = this._state.cancelText, m.setAttribute("modal-action", "cancel"), i.appendChild(m);
|
|
152
|
-
}
|
|
153
|
-
const c = a("l-button", {
|
|
154
|
-
type: "primary",
|
|
155
|
-
class: "l-modal-footer-btn",
|
|
156
|
-
loading: this._state.confirmLoading,
|
|
157
|
-
text: this._state.mobile
|
|
158
|
-
});
|
|
159
|
-
c.textContent = this._state.okText, c.setAttribute("modal-action", "ok"), i.appendChild(c), s.appendChild(i), l.appendChild(s);
|
|
160
|
-
}
|
|
161
|
-
t.appendChild(l), t.setAttribute("role", "dialog"), t.setAttribute("modal-action", "mask"), b(t, "click", this.#o), o.appendChild(t), this.appendToRoot(o), r(l, "modal-transition"), e && r(e, "mask-transition");
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
#a() {
|
|
165
|
-
document.body.style.setProperty("overflow", this._bodyOverflow);
|
|
166
|
-
const t = d(".l-modal", this.root);
|
|
167
|
-
r(t, "modal-transition", "leave", () => {
|
|
168
|
-
this._state.destroyOnClose && this.#e(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
|
|
169
|
-
});
|
|
170
|
-
const o = d(".l-mask", this.root);
|
|
171
|
-
o && r(o, "mask-transition", "leave");
|
|
172
|
-
}
|
|
173
|
-
disconnectedCallback() {
|
|
174
|
-
this.#e(), super.disconnectedCallback();
|
|
175
|
-
}
|
|
176
|
-
#e() {
|
|
177
|
-
const t = d(".l-modal-wrapper", this.root);
|
|
178
|
-
t && (x(t, "click", this.#o), this.root.removeChild(t));
|
|
179
|
-
const o = d(".l-mask", this.root);
|
|
180
|
-
o && this.root.removeChild(o);
|
|
181
|
-
}
|
|
182
|
-
#o = (t) => {
|
|
183
|
-
const [o, e] = k(t, "modal-action", this.root);
|
|
184
|
-
if (o) {
|
|
185
|
-
let l = "";
|
|
186
|
-
this._state.maskClosable && e === "mask" || e === "cancel" || e === "close" ? l = "cancel" : e === "ok" && (l = "ok"), l && this.dispatchEvent(
|
|
187
|
-
new CustomEvent(l, {
|
|
188
|
-
detail: { action: e }
|
|
189
|
-
})
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
}
|
|
194
|
-
export {
|
|
195
|
-
z as default
|
|
196
|
-
};
|
|
1
|
+
import { t as e } from "../modal-DWyWrN-D.js";
|
|
2
|
+
export { e as default };
|
package/lib/modal/modal_box.js
CHANGED
|
@@ -1,91 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
() => {
|
|
36
|
-
let s = !0;
|
|
37
|
-
l === "prompt" && (s = b(".l-modal-box l-input").value), r.removeAttribute("show"), a(s);
|
|
38
|
-
},
|
|
39
|
-
{ once: !0 }
|
|
40
|
-
), m(
|
|
41
|
-
r,
|
|
42
|
-
"cancel",
|
|
43
|
-
() => {
|
|
44
|
-
r.removeAttribute("show"), a(!1);
|
|
45
|
-
},
|
|
46
|
-
{ once: !0 }
|
|
47
|
-
), document.body.appendChild(r);
|
|
48
|
-
});
|
|
1
|
+
import { regist as e } from "../utils/index.js";
|
|
2
|
+
import t from "../icon/info.js";
|
|
3
|
+
import { t as n } from "../modal-DWyWrN-D.js";
|
|
4
|
+
import r from "../icon/close.js";
|
|
5
|
+
import { t as i } from "../form_item-Bv-YafZK.js";
|
|
6
|
+
import { t as a } from "../button-CC5PmAb1.js";
|
|
7
|
+
import o from "../input/index.js";
|
|
8
|
+
import { $$ as s, $one as c, on as l } from "ph-utils/dom";
|
|
9
|
+
//#region src/components/modal/modal_box.ts
|
|
10
|
+
function u(e, t, n, r = "alert") {
|
|
11
|
+
return new Promise((i) => {
|
|
12
|
+
let a = [];
|
|
13
|
+
if (n.icon) {
|
|
14
|
+
let e = n.icon();
|
|
15
|
+
e.setAttribute("slot", "header"), a.push(e.outerHTML);
|
|
16
|
+
}
|
|
17
|
+
a.push(`<span slot="header">${e}</span>`), r === "prompt" ? (a.push(`<l-form-item label="${t}" label-position="top" inner-block>`), a.push(`<l-input placeholder="${n.placeholder || ""}"></l-input>`), a.push("</l-form-item>")) : a.push(`<span>${t}</span>`);
|
|
18
|
+
let o = s("l-modal", {
|
|
19
|
+
cancel: `${n.showCancel}`,
|
|
20
|
+
innerHTML: a.join(""),
|
|
21
|
+
show: !0,
|
|
22
|
+
class: `l-modal-box l-modal-box--${r}`,
|
|
23
|
+
close: `${n.close}`,
|
|
24
|
+
"mask-closable": `${n.maskClosable}`
|
|
25
|
+
});
|
|
26
|
+
l(o, "close", () => {
|
|
27
|
+
o.remove(), o = void 0;
|
|
28
|
+
}, { once: !0 }), l(o, "ok", () => {
|
|
29
|
+
let e = !0;
|
|
30
|
+
r === "prompt" && (e = c(".l-modal-box l-input").value), o.removeAttribute("show"), i(e);
|
|
31
|
+
}, { once: !0 }), l(o, "cancel", () => {
|
|
32
|
+
o.removeAttribute("show"), i(!1);
|
|
33
|
+
}, { once: !0 }), document.body.appendChild(o);
|
|
34
|
+
});
|
|
49
35
|
}
|
|
50
|
-
function
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
function d(t, i, o) {
|
|
37
|
+
return e([
|
|
38
|
+
a,
|
|
39
|
+
n,
|
|
40
|
+
r
|
|
41
|
+
]), new Promise((e) => {
|
|
42
|
+
let n = {
|
|
43
|
+
showCancel: !1,
|
|
44
|
+
close: 0,
|
|
45
|
+
maskClosable: !1,
|
|
46
|
+
icon: void 0,
|
|
47
|
+
...o
|
|
48
|
+
};
|
|
49
|
+
return u(i || "提示", t, n, "alert");
|
|
50
|
+
});
|
|
61
51
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
52
|
+
function f(i, o, c) {
|
|
53
|
+
e([
|
|
54
|
+
a,
|
|
55
|
+
n,
|
|
56
|
+
r,
|
|
57
|
+
t
|
|
58
|
+
]);
|
|
59
|
+
let l = {
|
|
60
|
+
showCancel: !0,
|
|
61
|
+
close: 0,
|
|
62
|
+
maskClosable: !0,
|
|
63
|
+
icon: () => s("l-info-icon", { style: "color:#1890ff;" }),
|
|
64
|
+
...c
|
|
65
|
+
};
|
|
66
|
+
return u(o || "提示", i, l, "confirm");
|
|
72
67
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
68
|
+
function p(s, c, l) {
|
|
69
|
+
e([
|
|
70
|
+
a,
|
|
71
|
+
n,
|
|
72
|
+
r,
|
|
73
|
+
t,
|
|
74
|
+
i,
|
|
75
|
+
o
|
|
76
|
+
]);
|
|
77
|
+
let d = {
|
|
78
|
+
showCancel: !0,
|
|
79
|
+
close: 0,
|
|
80
|
+
maskClosable: !0,
|
|
81
|
+
placeholder: "",
|
|
82
|
+
...l
|
|
83
|
+
};
|
|
84
|
+
return u(c || "提示", s, d, "prompt");
|
|
83
85
|
}
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
};
|
|
89
|
-
export {
|
|
90
|
-
j as default
|
|
86
|
+
var m = {
|
|
87
|
+
alert: d,
|
|
88
|
+
confirm: f,
|
|
89
|
+
prompt: p
|
|
91
90
|
};
|
|
91
|
+
//#endregion
|
|
92
|
+
export { m as default };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { kebabToCamel as t, parseAttrValue as n, unitNumberStr as r } from "./utils/index.js";
|
|
3
|
+
import { $$ as i, $one as a, off as o, on as s, shouldEventNext as c, transition as l } from "ph-utils/dom";
|
|
4
|
+
//#region src/components/modal/index.less?inline
|
|
5
|
+
var u = ":host{display:none}:host(.open){display:block}.l-modal-mask{z-index:var(--l-modal-zindex,100)}.l-modal-wrapper{width:100%;height:100%;z-index:calc(var(--l-modal-zindex,100) + 1);position:fixed;top:0;left:0}.l-modal{--l-modal-translate:translate3d(0, 80px, 0);border-radius:var(--l-modal-border-radius,5px);width:var(--l-modal-width,27%);opacity:1;transform:var(--l-modal-translate) scale3d(1, 1, 1);background-color:#fff;margin:auto;transition:opacity .3s,transform .3s;position:relative;box-shadow:0 0 8px #0000001a}.l-modal-header{padding:var(--l-modal-header-padding,10px);border-bottom:1px solid var(--l-modal-line-color,#0000000f);align-items:center;gap:5px;font-size:16px;font-weight:600;display:flex}.l-modal-footer{padding:var(--l-modal-footer-padding,10px);border-top:1px solid var(--l-modal-line-color,#0000000f);justify-content:flex-end;gap:10px;display:flex}.l-modal-container{padding:var(--l-modal-container-padding,15px 10px);font-size:14px}.l-btn-modal-close{--l-form-control-height:auto;position:absolute}.l-modal-close1{top:8px;right:5px}.l-modal-close1::part(default){border:none;width:auto;height:auto;padding:5px;font-size:16px}.l-modal-close2{top:-10px;right:-10px}.l-modal-close2::part(default){background-color:#fff;width:20px;height:20px;padding:0}.mask-transition-enter-from,.mask-transition-leave-to{opacity:0}.modal-transition-enter-from,.modal-transition-leave-to{transform:translate(0,0)scale3d(0,0,0)}.l-modal--mobile{border-radius:10px}.l-modal--mobile .l-modal-header{text-align:center;border-bottom-color:#0000;justify-content:center;padding:20px 10px 5px;display:flex}.l-modal--mobile .l-modal-container{--l-modal-container-padding:5px 15px 20px;text-align:center}.l-modal--mobile .l-modal-footer{text-align:center;justify-content:stretch;align-items:stretch;gap:0;height:50px;padding:0;display:flex}.l-modal--mobile .l-modal-footer-btn{flex-grow:1;height:100%}.l-modal--mobile .l-modal-footer-btn+.l-modal-footer-btn{border-left:1px solid var(--l-modal-line-color,#0000000f)}.l-modal--middle{--l-modal-translate:translate3d(0, -50%, 0);top:50%}.l-modal--bottom{--l-modal-translate:translate3d(0, -100%, 0);border-bottom-right-radius:0;border-bottom-left-radius:0;width:100%;top:100%}@media screen and (width<=768px){:host{--l-modal-width:80%}}", d = ".l-mask{z-index:var(--l-mask-zindex,100);opacity:1;background-color:#0009;transition:opacity .3s;position:fixed;inset:0}", f = class extends e {
|
|
6
|
+
static baseName = "modal";
|
|
7
|
+
_bodyOverflow = "";
|
|
8
|
+
constructor() {
|
|
9
|
+
super(), this.version = 2, this._state = {
|
|
10
|
+
destroyOnClose: !1,
|
|
11
|
+
maskClosable: !0,
|
|
12
|
+
mask: !0,
|
|
13
|
+
cancel: !0,
|
|
14
|
+
cancelText: "取消",
|
|
15
|
+
okText: "确定",
|
|
16
|
+
confirmLoading: !1,
|
|
17
|
+
close: 1,
|
|
18
|
+
verticalAlign: "top",
|
|
19
|
+
mobile: !1,
|
|
20
|
+
show: !1,
|
|
21
|
+
header: !0,
|
|
22
|
+
footer: !0
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
static get observedAttributes() {
|
|
26
|
+
return [
|
|
27
|
+
"show",
|
|
28
|
+
"width",
|
|
29
|
+
"confirm-loading",
|
|
30
|
+
"destroy-on-close",
|
|
31
|
+
"mask-closable",
|
|
32
|
+
"mask",
|
|
33
|
+
"cancel",
|
|
34
|
+
"cancel-text",
|
|
35
|
+
"ok-text",
|
|
36
|
+
"close",
|
|
37
|
+
"vertical-align",
|
|
38
|
+
"mobile",
|
|
39
|
+
"z-index",
|
|
40
|
+
"header",
|
|
41
|
+
"footer",
|
|
42
|
+
"header-title"
|
|
43
|
+
];
|
|
44
|
+
}
|
|
45
|
+
attributeChanged(e, i, a) {
|
|
46
|
+
switch (e) {
|
|
47
|
+
case "show":
|
|
48
|
+
case "confirm-loading":
|
|
49
|
+
case "destroy-on-close":
|
|
50
|
+
case "mask-closable":
|
|
51
|
+
case "mask":
|
|
52
|
+
case "cancel":
|
|
53
|
+
case "mobile":
|
|
54
|
+
case "header":
|
|
55
|
+
case "footer":
|
|
56
|
+
this._state[t(e)] = n(a, !1, e);
|
|
57
|
+
break;
|
|
58
|
+
case "cancel-text":
|
|
59
|
+
this._state.cancelText = n(a, "取消");
|
|
60
|
+
break;
|
|
61
|
+
case "ok-text":
|
|
62
|
+
this._state.okText = n(a, "确定");
|
|
63
|
+
break;
|
|
64
|
+
case "close":
|
|
65
|
+
this._state.close = n(a, 1);
|
|
66
|
+
break;
|
|
67
|
+
case "width":
|
|
68
|
+
this._state[e] = r(a);
|
|
69
|
+
break;
|
|
70
|
+
case "vertical-align":
|
|
71
|
+
this._state.verticalAlign = n(a, "top");
|
|
72
|
+
break;
|
|
73
|
+
case "z-index":
|
|
74
|
+
this._state.zIndex = a;
|
|
75
|
+
break;
|
|
76
|
+
case "header-title":
|
|
77
|
+
this._state.headerTitle = a;
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
updateDOM(e) {
|
|
82
|
+
if (e.has("show") && (this._state.show ? this.#e() : this.#t()), e.has("width") && this._setWidth(), e.has("confirm-loading")) {
|
|
83
|
+
let e = a("l-button[modal-action=\"ok\"]", this.root);
|
|
84
|
+
e && e.setAttribute("loading", this._state.confirmLoading.toString());
|
|
85
|
+
}
|
|
86
|
+
e.has("z-index") && this._setZIndex();
|
|
87
|
+
}
|
|
88
|
+
afterInit() {
|
|
89
|
+
this._setWidth(), this._setZIndex(), this._state.show && this.#e();
|
|
90
|
+
}
|
|
91
|
+
render_v2() {
|
|
92
|
+
return { style: [d, u] };
|
|
93
|
+
}
|
|
94
|
+
_setZIndex() {
|
|
95
|
+
this._state.zIndex ? this.style.setProperty("--l-modal-zindex", this._state.zIndex) : this.style.removeProperty("--l-modal-zindex");
|
|
96
|
+
}
|
|
97
|
+
_setWidth() {
|
|
98
|
+
this._state.width ? this.style.setProperty("--l-modal-width", this._state.width) : this.style.removeProperty("--l-modal-width");
|
|
99
|
+
}
|
|
100
|
+
#e() {
|
|
101
|
+
this._bodyOverflow = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
|
|
102
|
+
let e = a(".l-modal-wrapper", this.root);
|
|
103
|
+
if (e) {
|
|
104
|
+
let e = a(".l-mask", this.root);
|
|
105
|
+
e && l(e, "mask-transition"), l(a(".l-modal", this.root), "modal-transition");
|
|
106
|
+
} else {
|
|
107
|
+
let t = document.createDocumentFragment(), n = null;
|
|
108
|
+
this._state.mask && (n = i("div", {
|
|
109
|
+
class: "l-mask l-modal-mask",
|
|
110
|
+
part: "mask"
|
|
111
|
+
}), t.appendChild(n)), e = i("div", {
|
|
112
|
+
class: "l-modal-wrapper",
|
|
113
|
+
part: "wrapper"
|
|
114
|
+
});
|
|
115
|
+
let r = i("div", {
|
|
116
|
+
class: [
|
|
117
|
+
"l-modal",
|
|
118
|
+
`l-modal--${this._state.mobile ? "mobile" : "pc"}`,
|
|
119
|
+
`l-modal--${this._state.verticalAlign}`
|
|
120
|
+
],
|
|
121
|
+
part: "default"
|
|
122
|
+
});
|
|
123
|
+
if (r.setAttribute("modal-action", "modal"), this._state.close !== 0) {
|
|
124
|
+
let e = i("l-button", {
|
|
125
|
+
shape: "circle",
|
|
126
|
+
type: "normal",
|
|
127
|
+
class: `l-btn-modal-close l-modal-close${this._state.close}`,
|
|
128
|
+
"modal-action": "close",
|
|
129
|
+
part: "close-btn"
|
|
130
|
+
}), t = i("l-close-icon");
|
|
131
|
+
e.appendChild(t), r.appendChild(e);
|
|
132
|
+
}
|
|
133
|
+
if (this._state.header) {
|
|
134
|
+
let e = i("header", {
|
|
135
|
+
class: "l-modal-header",
|
|
136
|
+
part: "header"
|
|
137
|
+
}), t = i("slot", { name: "header" });
|
|
138
|
+
t.textContent = this._state.headerTitle || "", e.appendChild(t), r.appendChild(e);
|
|
139
|
+
}
|
|
140
|
+
let a = i("div", {
|
|
141
|
+
class: "l-modal-container",
|
|
142
|
+
part: "container"
|
|
143
|
+
}), o = i("slot");
|
|
144
|
+
if (a.appendChild(o), r.appendChild(a), this._state.footer) {
|
|
145
|
+
let e = i("footer", {
|
|
146
|
+
class: "l-modal-footer",
|
|
147
|
+
part: "footer"
|
|
148
|
+
}), t = i("slot", { name: "footer" });
|
|
149
|
+
if (this._state.cancel) {
|
|
150
|
+
let e = i("l-button", {
|
|
151
|
+
class: "l-modal-footer-btn",
|
|
152
|
+
text: this._state.mobile
|
|
153
|
+
});
|
|
154
|
+
e.textContent = this._state.cancelText, e.setAttribute("modal-action", "cancel"), t.appendChild(e);
|
|
155
|
+
}
|
|
156
|
+
let n = i("l-button", {
|
|
157
|
+
type: "primary",
|
|
158
|
+
class: "l-modal-footer-btn",
|
|
159
|
+
loading: this._state.confirmLoading,
|
|
160
|
+
text: this._state.mobile
|
|
161
|
+
});
|
|
162
|
+
n.textContent = this._state.okText, n.setAttribute("modal-action", "ok"), t.appendChild(n), e.appendChild(t), r.appendChild(e);
|
|
163
|
+
}
|
|
164
|
+
e.appendChild(r), e.setAttribute("role", "dialog"), e.setAttribute("modal-action", "mask"), s(e, "click", this.#r), t.appendChild(e), this.appendToRoot(t), l(r, "modal-transition"), n && l(n, "mask-transition");
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
#t() {
|
|
168
|
+
document.body.style.setProperty("overflow", this._bodyOverflow), l(a(".l-modal", this.root), "modal-transition", "leave", () => {
|
|
169
|
+
this._state.destroyOnClose && this.#n(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
|
|
170
|
+
});
|
|
171
|
+
let e = a(".l-mask", this.root);
|
|
172
|
+
e && l(e, "mask-transition", "leave");
|
|
173
|
+
}
|
|
174
|
+
disconnectedCallback() {
|
|
175
|
+
this.#n(), super.disconnectedCallback();
|
|
176
|
+
}
|
|
177
|
+
#n() {
|
|
178
|
+
let e = a(".l-modal-wrapper", this.root);
|
|
179
|
+
e && (o(e, "click", this.#r), this.root.removeChild(e));
|
|
180
|
+
let t = a(".l-mask", this.root);
|
|
181
|
+
t && this.root.removeChild(t);
|
|
182
|
+
}
|
|
183
|
+
#r = (e) => {
|
|
184
|
+
let [t, n] = c(e, "modal-action", this.root);
|
|
185
|
+
if (t) {
|
|
186
|
+
let e = "";
|
|
187
|
+
this._state.maskClosable && n === "mask" || n === "cancel" || n === "close" ? e = "cancel" : n === "ok" && (e = "ok"), e && this.dispatchEvent(new CustomEvent(e, { detail: { action: n } }));
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
//#endregion
|
|
192
|
+
export { f as t };
|