litos-ui 0.12.2 → 0.13.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 +23 -2
- package/lib/base.js +37 -8
- package/lib/button/index.d.ts +3 -1
- package/lib/button/index.js +18 -19
- package/lib/color_picker/index.js +1 -1
- package/lib/date_picker/index.d.ts +22 -0
- package/lib/date_picker/index.js +99 -0
- package/lib/dialog/dialog_container.d.ts +28 -0
- package/lib/dialog/dialog_container.js +100 -0
- package/lib/dialog/index.d.ts +30 -0
- package/lib/dialog/index.js +86 -0
- package/lib/form/form_inner.d.ts +7 -2
- package/lib/form/form_inner.js +27 -21
- package/lib/form/form_item.d.ts +0 -2
- package/lib/form/form_item.js +5 -9
- package/lib/form/index.d.ts +0 -2
- package/lib/form/index.js +23 -25
- package/lib/icon/base.d.ts +0 -1
- package/lib/icon/base.js +15 -17
- package/lib/icon/close.d.ts +5 -0
- package/lib/icon/close.js +10 -0
- package/lib/icon/{mask_close.js → close_filled.js} +1 -1
- package/lib/index-dwS1N2uN.js +4 -0
- package/lib/index.d.ts +28 -2
- package/lib/index.js +112 -87
- package/lib/input/index.d.ts +6 -5
- package/lib/input/index.js +105 -57
- package/lib/list/index.d.ts +1 -1
- package/lib/litos-ui.css +1 -1
- package/lib/loading/index.d.ts +45 -0
- package/lib/loading/index.js +141 -0
- package/lib/menu/base.js +1 -0
- package/lib/menu/index.d.ts +29 -0
- package/lib/menu/index.js +90 -0
- package/lib/menu/menu_item.d.ts +6 -0
- package/lib/menu/menu_item.js +21 -0
- package/lib/menu/sub_menu.d.ts +13 -0
- package/lib/menu/sub_menu.js +64 -0
- package/lib/message/index.js +1 -1
- package/lib/modal/index.d.ts +40 -0
- package/lib/modal/index.js +153 -0
- package/lib/modal/modal_box.js +95 -0
- package/lib/popover/index.d.ts +1 -4
- package/lib/popover/index.js +6 -12
- package/lib/radio/index.js +3 -3
- package/lib/select_ori/index.d.ts +0 -2
- package/lib/select_ori/index.js +11 -15
- package/lib/switch/index.d.ts +0 -1
- package/lib/switch/index.js +8 -13
- package/lib/tabbar/index.d.ts +0 -1
- package/lib/tabbar/index.js +55 -63
- package/lib/theme/index.d.ts +1 -2
- package/lib/theme/index.js +9 -12
- package/lib/utils/index.d.ts +0 -5
- package/lib/utils/index.js +45 -52
- package/lib/utils/transition.js +3 -2
- package/package.json +8 -8
- package/styles/vars.css +1 -1
- package/lib/index-391POYEJ.js +0 -4
- package/lib/litos-ui.min.js +0 -1
- /package/lib/icon/{mask_close.d.ts → close_filled.d.ts} +0 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { $ as u, iterate as g, $one as c, addClass as d, hasClass as m, $$ as o } from "ph-utils/dom";
|
|
2
|
+
function f(t, e) {
|
|
3
|
+
if (m(t, "l-loading")) return;
|
|
4
|
+
let n;
|
|
5
|
+
if (e.fullscreen && c("#l-loading") != null)
|
|
6
|
+
return;
|
|
7
|
+
d(t, "l-loading"), (e.mask === 1 || e.mask === 2 && e.shape === "circle") && (n = o("div", {
|
|
8
|
+
class: "l-loading-mask",
|
|
9
|
+
style: {
|
|
10
|
+
"background-color": e.background,
|
|
11
|
+
"--l-loading-zindex": e.zindex
|
|
12
|
+
}
|
|
13
|
+
}), t.appendChild(n));
|
|
14
|
+
const l = o("div", {
|
|
15
|
+
class: `l-loading-spinner l-loading--${e.shape}`,
|
|
16
|
+
style: {
|
|
17
|
+
"--l-loading-color": e.color
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
if (e.shape === "bar") {
|
|
21
|
+
const s = o("div", { class: "l-loading-progress" });
|
|
22
|
+
l.style.setProperty(
|
|
23
|
+
"top",
|
|
24
|
+
`-${getComputedStyle(t).borderTopWidth}`
|
|
25
|
+
), l.appendChild(s);
|
|
26
|
+
} else if (e.shape === "circle") {
|
|
27
|
+
const s = document.createElementNS(
|
|
28
|
+
"http://www.w3.org/2000/svg",
|
|
29
|
+
"svg"
|
|
30
|
+
);
|
|
31
|
+
s.setAttribute("viewBox", "0 0 50 50"), s.classList.add("circle");
|
|
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", {
|
|
38
|
+
class: "l-loading-text",
|
|
39
|
+
textContent: e.text
|
|
40
|
+
});
|
|
41
|
+
l.appendChild(i);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
if (t.appendChild(l), e.fullscreen) {
|
|
45
|
+
const s = ["l-loading-fullscreen"];
|
|
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");
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function p(t, e) {
|
|
53
|
+
const n = t.tagName === "BODY" ? "body" : ".l-loading", l = c(`${n} > .l-loading-mask`, t), s = c(`${n} > .l-loading-spinner`, t);
|
|
54
|
+
if (!s) return;
|
|
55
|
+
function a() {
|
|
56
|
+
l && l.remove(), s.remove();
|
|
57
|
+
const i = ["l-loading"];
|
|
58
|
+
t.tagName === "BODY" && i.push("l-loading-fullscreen", "l-loading-lock"), t.classList.remove(...i);
|
|
59
|
+
}
|
|
60
|
+
s.addEventListener("transitionend", a, { once: !0 }), requestAnimationFrame(() => {
|
|
61
|
+
l && (l.style.opacity = "0"), d(s, "l-loading-bar--finish"), s.style.opacity = "0";
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
class h {
|
|
65
|
+
/** 加载容器 */
|
|
66
|
+
el;
|
|
67
|
+
option;
|
|
68
|
+
constructor(e) {
|
|
69
|
+
this.option = {
|
|
70
|
+
fullscreen: !0,
|
|
71
|
+
lock: !0,
|
|
72
|
+
shape: "circle",
|
|
73
|
+
text: "加载中……",
|
|
74
|
+
background: "",
|
|
75
|
+
color: "",
|
|
76
|
+
mask: 2,
|
|
77
|
+
...e
|
|
78
|
+
};
|
|
79
|
+
const n = (e || {}).to;
|
|
80
|
+
let l = null;
|
|
81
|
+
n != null && (typeof n == "string" ? l = document.querySelector(n) : l = n), (l == null || this.option.fullscreen) && (l = document.body), this.el = l, this.show();
|
|
82
|
+
}
|
|
83
|
+
/** 显示进度条 */
|
|
84
|
+
show() {
|
|
85
|
+
f(this.el, this.option);
|
|
86
|
+
}
|
|
87
|
+
/** 隐藏进度条 */
|
|
88
|
+
hide() {
|
|
89
|
+
p(this.el, this.option);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function r(t) {
|
|
93
|
+
const e = t.getAttribute("l-loading-text"), n = t.getAttribute("l-loading-lock");
|
|
94
|
+
return {
|
|
95
|
+
background: t.getAttribute("l-loading-background"),
|
|
96
|
+
text: e ? e === "0" || e === "false" ? void 0 : e : "加载中……",
|
|
97
|
+
fullscreen: t.hasAttribute("l-loading-fullscreen"),
|
|
98
|
+
lock: !(n === "0" || n === "false"),
|
|
99
|
+
mask: Number(t.hasAttribute("l-loading-mask") || 2),
|
|
100
|
+
shape: t.getAttribute("l-loading-shape") || "circle",
|
|
101
|
+
color: t.getAttribute("l-loading-color")
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
const $ = {
|
|
105
|
+
/** 创建并显示进度条 */
|
|
106
|
+
create(t) {
|
|
107
|
+
return new h(t);
|
|
108
|
+
},
|
|
109
|
+
/** 根据指令参数初始化进度条 */
|
|
110
|
+
init(t) {
|
|
111
|
+
const e = t ? `[l-loading="${t}"]` : "[l-loading]", n = u(e);
|
|
112
|
+
g(n, (l) => {
|
|
113
|
+
const s = r(l);
|
|
114
|
+
f(
|
|
115
|
+
s.fullscreen ? document.body : l,
|
|
116
|
+
r(l)
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
/**
|
|
121
|
+
* 关闭加载中的元素
|
|
122
|
+
*
|
|
123
|
+
* 此函数用于关闭页面上带有特定 l-loading 属性的元素,只关闭与该 id 匹配的元素
|
|
124
|
+
* 否则,将关闭所有带有 l-loading 属性的元素
|
|
125
|
+
*
|
|
126
|
+
* @param id 可选参数,指定特定的加载元素 l-loading 对应的值,如果提供,则只关闭匹配该 id 的元素
|
|
127
|
+
*/
|
|
128
|
+
close(t) {
|
|
129
|
+
const e = t ? `[l-loading="${t}"]` : "[l-loading]", n = u(e);
|
|
130
|
+
g(n, (l) => {
|
|
131
|
+
const s = r(l);
|
|
132
|
+
p(
|
|
133
|
+
s.fullscreen ? document.body : l,
|
|
134
|
+
r(l)
|
|
135
|
+
);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
export {
|
|
140
|
+
$ as default
|
|
141
|
+
};
|
package/lib/menu/base.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Menu extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 当前选中的菜单项 key 数组, 用 , 分割 */
|
|
6
|
+
selectedKey: string;
|
|
7
|
+
/** 水平/垂直菜单 */
|
|
8
|
+
orientation: "horizontal" | "vertical";
|
|
9
|
+
/** 主题 */
|
|
10
|
+
theme: "light" | "dark";
|
|
11
|
+
connectedCallback(): void;
|
|
12
|
+
static get observedAttributes(): string[];
|
|
13
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
14
|
+
afterInit(): void;
|
|
15
|
+
beforeDestroy(): void;
|
|
16
|
+
render(): HTMLElement;
|
|
17
|
+
/**
|
|
18
|
+
* 展开与提供的 keys 对应的子菜单。
|
|
19
|
+
*
|
|
20
|
+
* 此方法会在当前上下文中选择所有带有 `l-sub-menu` 标签和 `key` 属性的元素,
|
|
21
|
+
* 并对其进行迭代。如果子菜单的 `key` 属性与提供的 keys 中的任意一个匹配,
|
|
22
|
+
* 则通过将其 `collapse` 属性设置为 "off" 来展开子菜单,并将该 key 添加到 `#selectedKeys` 集合中。
|
|
23
|
+
*
|
|
24
|
+
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
25
|
+
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
26
|
+
*/
|
|
27
|
+
expandSubmenus(keys: string[], collapseOther?: boolean): void;
|
|
28
|
+
updateSelectedKeys(key: string): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { on as r, off as a, $$ as c, $ as d, iterate as h, $one as u } from "ph-utils/dom";
|
|
2
|
+
import f from "../base.js";
|
|
3
|
+
import { initAttr as m } from "../utils/index.js";
|
|
4
|
+
const b = ":host{--l-menu-width: 240px;--l-menu-height: auto;--l-menu-color: #333333;--l-menu-background: #ffffff;--l-menu-level: 0;--l-menu-item-height: 40px;--l-menu-active-color: var(--l-primary-color, #722ed1);--l-menu-active-background: var(--l-primary-color-light5, #f9f0ff);display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}";
|
|
5
|
+
class v extends f {
|
|
6
|
+
static baseName = "menu";
|
|
7
|
+
/** 当前选中的菜单项 key 数组, 用 , 分割 */
|
|
8
|
+
selectedKey = "";
|
|
9
|
+
/** 水平/垂直菜单 */
|
|
10
|
+
orientation = "vertical";
|
|
11
|
+
/** 主题 */
|
|
12
|
+
theme = "light";
|
|
13
|
+
/** 展开的菜单项数组 */
|
|
14
|
+
#e = /* @__PURE__ */ new Set();
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
m(this), this.classList.add(
|
|
17
|
+
"l-menu",
|
|
18
|
+
`l-menu--${this.orientation}`,
|
|
19
|
+
`l-menu-${this.theme}`
|
|
20
|
+
), this.loadStyleText(b), super.connectedCallback();
|
|
21
|
+
}
|
|
22
|
+
static get observedAttributes() {
|
|
23
|
+
return ["selectedKeys", "orientation"];
|
|
24
|
+
}
|
|
25
|
+
attributeChangedCallback(e, t, i) {
|
|
26
|
+
if (this.rendered) {
|
|
27
|
+
if (e === "selectedKeys")
|
|
28
|
+
this.selectedKey = i;
|
|
29
|
+
else if (e === "orientation") {
|
|
30
|
+
const s = this.classList;
|
|
31
|
+
s.remove(`l-menu--${t}`), s.add(`l-menu--${i}`);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
afterInit() {
|
|
36
|
+
r(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
|
|
37
|
+
}
|
|
38
|
+
beforeDestroy() {
|
|
39
|
+
a(this, "click", this.#t);
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
return c("slot");
|
|
43
|
+
}
|
|
44
|
+
#t = (e) => {
|
|
45
|
+
const { type: t, key: i, keyPaths: s, target: l } = this.#i(
|
|
46
|
+
e.target
|
|
47
|
+
);
|
|
48
|
+
l && t === 2 && (this.#e.has(i) ? (l.setAttribute("collapse", "on"), this.#e.delete(i)) : (l.setAttribute("collapse", "off"), this.#e.add(i)));
|
|
49
|
+
};
|
|
50
|
+
#i(e) {
|
|
51
|
+
let t = 0, i = "", s;
|
|
52
|
+
const l = [];
|
|
53
|
+
do {
|
|
54
|
+
const o = e.tagName;
|
|
55
|
+
if (["L-MENU", "BODY"].includes(o))
|
|
56
|
+
break;
|
|
57
|
+
const n = e.getAttribute("key");
|
|
58
|
+
n && (i || (i = n), l.unshift(n)), t === 0 && (o === "L-MENU-ITEM" ? (t = 1, s = e) : o === "L-SUB-MENU" && (s = e, t = 2)), e = e.parentElement;
|
|
59
|
+
} while (t >= 0);
|
|
60
|
+
return { type: t, key: i, keyPaths: l, target: s };
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* 展开与提供的 keys 对应的子菜单。
|
|
64
|
+
*
|
|
65
|
+
* 此方法会在当前上下文中选择所有带有 `l-sub-menu` 标签和 `key` 属性的元素,
|
|
66
|
+
* 并对其进行迭代。如果子菜单的 `key` 属性与提供的 keys 中的任意一个匹配,
|
|
67
|
+
* 则通过将其 `collapse` 属性设置为 "off" 来展开子菜单,并将该 key 添加到 `#selectedKeys` 集合中。
|
|
68
|
+
*
|
|
69
|
+
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
70
|
+
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
71
|
+
*/
|
|
72
|
+
expandSubmenus(e, t = !1) {
|
|
73
|
+
const i = d("l-sub-menu[key]", this);
|
|
74
|
+
h(i, (s) => {
|
|
75
|
+
const l = s.getAttribute("key") || "";
|
|
76
|
+
e.includes(l) ? s.setAttribute("collapse", "off") : t && s.setAttribute("collapse", "on");
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
updateSelectedKeys(e) {
|
|
80
|
+
this.selectedKey = e;
|
|
81
|
+
const t = u(`l-menu-item[key="${e}"]`, this);
|
|
82
|
+
if (t) {
|
|
83
|
+
t.setAttribute("active", "on");
|
|
84
|
+
const { keyPaths: i } = this.#i(t);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
export {
|
|
89
|
+
v as default
|
|
90
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { $one as n, $$ as e } from "ph-utils/dom";
|
|
2
|
+
import t from "../base.js";
|
|
3
|
+
import { initAttr as i } from "../utils/index.js";
|
|
4
|
+
const a = ":host{display:flex;align-items:center;padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;border-right:2px solid transparent;transition:color .3s,background-color .3s,border-color .3s}:host(:hover){background-color:var(--l-primary-color-light5)}:host([active]){background-color:var(--l-menu-active-background);color:var(--l-menu-active-color)}.l-menu-icon-wrap{display:inline-flex;font-size:14px;margin-right:5px}";
|
|
5
|
+
class m extends t {
|
|
6
|
+
static baseName = "menu-item";
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
this.loadStyleText(a), i(this), super.connectedCallback();
|
|
9
|
+
}
|
|
10
|
+
render() {
|
|
11
|
+
const o = document.createDocumentFragment();
|
|
12
|
+
if (n('[slot="icon"]', this)) {
|
|
13
|
+
const r = e("span", { class: "l-menu-icon-wrap" });
|
|
14
|
+
r.appendChild(e("slot", { name: "icon" })), o.appendChild(r);
|
|
15
|
+
}
|
|
16
|
+
return o.appendChild(e("slot")), o;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
m as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Menu extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 默认折叠子菜单 */
|
|
6
|
+
collapse: boolean;
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
afterInit(): void;
|
|
9
|
+
beforeDestroy(): void;
|
|
10
|
+
static get observedAttributes(): string[];
|
|
11
|
+
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
12
|
+
render(): DocumentFragment;
|
|
13
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { addClass as r, removeClass as a, $one as i, on as p, off as d, queryHideNodeSize as h, $$ as l } from "ph-utils/dom";
|
|
2
|
+
import u from "../base.js";
|
|
3
|
+
import { initAttr as m, parseAttrValue as b } from "../utils/index.js";
|
|
4
|
+
const g = ":host{display:block;width:100%;overflow:hidden}.l-submenu-title{display:flex;align-items:center;padding:0 10px 0 calc(10px + var(--l-menu-level) * 15px);height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;position:relative;overflow:hidden;text-overflow:ellipsis;border-right:2px solid transparent;transition:color .3s,background-color .3s,border-color .3s}.l-submenu-title:hover{background-color:var(--l-primary-color-light5)}.l-menu{--l-menu-level: 1;display:block;width:var(--l-menu-width);height:var(--l-menu-height);font-size:14px;position:relative;color:var(--l-menu-color);background:var(--l-menu-background);box-sizing:border-box;transition:height .3s,width .3s;overflow:hidden;border-right:1px solid var(--l-border-color, #dedede)}.l-menu-icon-wrap{display:inline-flex;font-size:14px;margin-right:5px}.l-submenu-arrow-icon{position:absolute;top:50%;right:10px;transition:transform .3s;transform:translate3d(0,-50%,0) rotate(90deg);color:var(--l-info-color)}:host(.collapse) .l-submenu-arrow-icon{transform:translate3d(0,-50%,0) rotate(0)}.l-menu--collapse{display:none}";
|
|
5
|
+
class y extends u {
|
|
6
|
+
static baseName = "sub-menu";
|
|
7
|
+
/** 默认折叠子菜单 */
|
|
8
|
+
collapse = !0;
|
|
9
|
+
connectedCallback() {
|
|
10
|
+
this.loadStyleText(g), m(this), this.collapse ? r(this, "collapse") : a(this, "collapse"), super.connectedCallback();
|
|
11
|
+
}
|
|
12
|
+
afterInit() {
|
|
13
|
+
const e = i(".l-menu", this.root);
|
|
14
|
+
p(e, "transitionend", this.#e);
|
|
15
|
+
}
|
|
16
|
+
beforeDestroy() {
|
|
17
|
+
const e = i(".l-menu", this.root);
|
|
18
|
+
d(e, "transitionend", this.#e);
|
|
19
|
+
}
|
|
20
|
+
static get observedAttributes() {
|
|
21
|
+
return ["collapse"];
|
|
22
|
+
}
|
|
23
|
+
attributeChangedCallback(e, t, c) {
|
|
24
|
+
if (this.rendered && e === "collapse") {
|
|
25
|
+
const s = b(c, !0, "collapse");
|
|
26
|
+
if (this.collapse !== s) {
|
|
27
|
+
this.collapse = s;
|
|
28
|
+
const o = i(".l-menu", this.root);
|
|
29
|
+
if (this.collapse)
|
|
30
|
+
r(this, "collapse"), o.style.height = "0";
|
|
31
|
+
else {
|
|
32
|
+
a(this, "collapse");
|
|
33
|
+
const n = h(o, null);
|
|
34
|
+
o.style.height = "0", a(o, "l-menu--collapse"), requestAnimationFrame(() => {
|
|
35
|
+
o.style.height = `${n.height}px`;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
render() {
|
|
42
|
+
const e = document.createDocumentFragment(), t = l("div", { class: "l-submenu-title" });
|
|
43
|
+
if (i('[slot="icon"]', this)) {
|
|
44
|
+
const n = l("span", { class: "l-menu-icon-wrap" });
|
|
45
|
+
n.appendChild(l("slot", { name: "icon" })), t.appendChild(n);
|
|
46
|
+
}
|
|
47
|
+
t.appendChild(l("slot", { name: "title" }));
|
|
48
|
+
const s = l("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
|
|
49
|
+
t.appendChild(s), e.appendChild(t);
|
|
50
|
+
const o = l("div", {
|
|
51
|
+
class: ["l-menu", this.collapse ? "l-menu--collapse" : void 0]
|
|
52
|
+
});
|
|
53
|
+
return o.appendChild(l("slot")), e.appendChild(o), e;
|
|
54
|
+
}
|
|
55
|
+
#e = (e) => {
|
|
56
|
+
if (this.collapse) {
|
|
57
|
+
const t = e.target;
|
|
58
|
+
t.style.removeProperty("height"), r(t, "l-menu--collapse");
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
y as default
|
|
64
|
+
};
|
package/lib/message/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { regist as y, useId as p } from "../utils/index.js";
|
|
2
2
|
import { transition as d } from "ph-utils/dom";
|
|
3
|
-
import h from "../icon/
|
|
3
|
+
import h from "../icon/close_filled.js";
|
|
4
4
|
import $ from "../icon/success.js";
|
|
5
5
|
import v from "../icon/warn.js";
|
|
6
6
|
import w from "../icon/info.js";
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Modal extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 是否显示对话框 */
|
|
6
|
+
open: boolean;
|
|
7
|
+
/** 关闭时销毁 Modal 里的子元素 */
|
|
8
|
+
destroyOnClose: boolean;
|
|
9
|
+
/** 点击蒙层是否允许关闭 */
|
|
10
|
+
maskClosable: boolean;
|
|
11
|
+
/** 是否展示遮罩 */
|
|
12
|
+
mask: boolean;
|
|
13
|
+
/** 标题 */
|
|
14
|
+
title: string;
|
|
15
|
+
/** 是否展示底部 */
|
|
16
|
+
footer: boolean;
|
|
17
|
+
/** 是否显示取消按钮 */
|
|
18
|
+
cancel: boolean;
|
|
19
|
+
/** 取消按钮文本 */
|
|
20
|
+
cancelText: string;
|
|
21
|
+
/** 确定按钮文本 */
|
|
22
|
+
okText: string;
|
|
23
|
+
/** 对话框宽度 */
|
|
24
|
+
width?: string;
|
|
25
|
+
/** 确认按钮加载中 */
|
|
26
|
+
confirmLoading: boolean;
|
|
27
|
+
/** 右上角关闭按钮, 1-显示在框内,2-显示在框角, 0-不显示 */
|
|
28
|
+
close: number;
|
|
29
|
+
/** 对话框垂直方向位置 */
|
|
30
|
+
verticalAlign: "top" | "bottom" | "middle";
|
|
31
|
+
/** 是否是移动风格弹出框 */
|
|
32
|
+
mobile: boolean;
|
|
33
|
+
/** 设置 Modal 的 z-index */
|
|
34
|
+
zIndex?: string;
|
|
35
|
+
static get observedAttributes(): string[];
|
|
36
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
37
|
+
connectedCallback(): void;
|
|
38
|
+
render(): void;
|
|
39
|
+
disconnectedCallback(): void;
|
|
40
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import x from "../base.js";
|
|
2
|
+
import { parseAttrValue as c, initAttr as g } from "../utils/index.js";
|
|
3
|
+
import { $one as i, transition as s, $$ as a, on as u, off as k, shouldEventNext as y } from "ph-utils/dom";
|
|
4
|
+
const v = ":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-edit-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%}}", C = ".l-mask{position:fixed;z-index:var(--l-mask-zindex, 100);inset:0;background-color:#0009;transition:opacity .3s;opacity:1}";
|
|
5
|
+
class L extends x {
|
|
6
|
+
static baseName = "modal";
|
|
7
|
+
/** 是否显示对话框 */
|
|
8
|
+
open = !1;
|
|
9
|
+
/** 关闭时销毁 Modal 里的子元素 */
|
|
10
|
+
destroyOnClose = !1;
|
|
11
|
+
/** 点击蒙层是否允许关闭 */
|
|
12
|
+
maskClosable = !0;
|
|
13
|
+
/** 是否展示遮罩 */
|
|
14
|
+
mask = !0;
|
|
15
|
+
/** 标题 */
|
|
16
|
+
title = "";
|
|
17
|
+
/** 是否展示底部 */
|
|
18
|
+
footer = !0;
|
|
19
|
+
/** 是否显示取消按钮 */
|
|
20
|
+
cancel = !0;
|
|
21
|
+
/** 取消按钮文本 */
|
|
22
|
+
cancelText = "取消";
|
|
23
|
+
/** 确定按钮文本 */
|
|
24
|
+
okText = "确定";
|
|
25
|
+
/** 对话框宽度 */
|
|
26
|
+
width;
|
|
27
|
+
/** 确认按钮加载中 */
|
|
28
|
+
confirmLoading = !1;
|
|
29
|
+
/** 右上角关闭按钮, 1-显示在框内,2-显示在框角, 0-不显示 */
|
|
30
|
+
close = 1;
|
|
31
|
+
/** 对话框垂直方向位置 */
|
|
32
|
+
verticalAlign = "top";
|
|
33
|
+
/** 是否是移动风格弹出框 */
|
|
34
|
+
mobile = !1;
|
|
35
|
+
/** 设置 Modal 的 z-index */
|
|
36
|
+
zIndex;
|
|
37
|
+
#t = "";
|
|
38
|
+
static get observedAttributes() {
|
|
39
|
+
return ["open", "width", "confirm-loading"];
|
|
40
|
+
}
|
|
41
|
+
attributeChangedCallback(t, e, o) {
|
|
42
|
+
if (this.rendered) {
|
|
43
|
+
if (t === "open")
|
|
44
|
+
this.open = c(o, !1), this.open ? this.#e() : this.#i();
|
|
45
|
+
else if (t === "width")
|
|
46
|
+
this.width = c(o, void 0), this.#o();
|
|
47
|
+
else if (t === "confirm-loading") {
|
|
48
|
+
this.confirmLoading = c(o, !1, "confirm-loading");
|
|
49
|
+
const l = i('l-button[modal-action="ok"]', this.root);
|
|
50
|
+
l && l.setAttribute("loading", this.confirmLoading.toString());
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
connectedCallback() {
|
|
55
|
+
g(this), this.loadStyleText([C, v]), super.connectedCallback(), this.#o(), this.zIndex && this.style.setProperty("--l-modal-zindex", this.zIndex);
|
|
56
|
+
}
|
|
57
|
+
render() {
|
|
58
|
+
this.open && this.#e();
|
|
59
|
+
}
|
|
60
|
+
#o() {
|
|
61
|
+
this.width ? this.style.setProperty("--l-modal-width", this.width) : this.style.removeProperty("--l-modal-width");
|
|
62
|
+
}
|
|
63
|
+
#e() {
|
|
64
|
+
this.#t = getComputedStyle(document.body).overflow, this.classList.add("open"), document.body.style.overflow = "hidden";
|
|
65
|
+
let t = i(".l-modal-wrapper", this.root);
|
|
66
|
+
if (t) {
|
|
67
|
+
const e = i(".l-mask", this.root);
|
|
68
|
+
e && s(e, "mask-transition");
|
|
69
|
+
const o = i(".l-modal", this.root);
|
|
70
|
+
s(o, "modal-transition");
|
|
71
|
+
} else {
|
|
72
|
+
const e = document.createDocumentFragment();
|
|
73
|
+
let o = null;
|
|
74
|
+
this.mask && (o = a("div", { class: "l-mask l-modal-mask", part: "mask" }), e.appendChild(o)), t = a("div", { class: "l-modal-wrapper", part: "wrapper" });
|
|
75
|
+
const l = a("div", {
|
|
76
|
+
class: [
|
|
77
|
+
"l-modal",
|
|
78
|
+
`l-modal--${this.mobile ? "mobile" : "pc"}`,
|
|
79
|
+
`l-modal--${this.verticalAlign}`
|
|
80
|
+
],
|
|
81
|
+
part: "default"
|
|
82
|
+
});
|
|
83
|
+
if (l.setAttribute("modal-action", "modal"), this.close !== 0) {
|
|
84
|
+
const d = a("l-button", {
|
|
85
|
+
shape: "circle",
|
|
86
|
+
type: "normal",
|
|
87
|
+
class: `l-btn-modal-close l-modal-close${this.close}`,
|
|
88
|
+
"modal-action": "close"
|
|
89
|
+
}), n = a("l-close-icon");
|
|
90
|
+
d.appendChild(n), l.appendChild(d);
|
|
91
|
+
}
|
|
92
|
+
const p = a("header", { class: "l-modal-header", part: "header" }), h = a("slot", { name: "header" });
|
|
93
|
+
h.textContent = this.title || "", p.appendChild(h), l.appendChild(p);
|
|
94
|
+
const f = a("div", {
|
|
95
|
+
class: "l-modal-container",
|
|
96
|
+
part: "container"
|
|
97
|
+
}), b = a("slot");
|
|
98
|
+
if (f.appendChild(b), l.appendChild(f), this.footer) {
|
|
99
|
+
const d = a("footer", {
|
|
100
|
+
class: "l-modal-footer",
|
|
101
|
+
part: "footer"
|
|
102
|
+
}), n = a("slot", { name: "footer" });
|
|
103
|
+
if (this.cancel) {
|
|
104
|
+
const m = a("l-button", {
|
|
105
|
+
class: "l-modal-footer-btn",
|
|
106
|
+
text: this.mobile
|
|
107
|
+
});
|
|
108
|
+
m.textContent = this.cancelText, m.setAttribute("modal-action", "cancel"), n.appendChild(m);
|
|
109
|
+
}
|
|
110
|
+
const r = a("l-button", {
|
|
111
|
+
type: "primary",
|
|
112
|
+
class: "l-modal-footer-btn",
|
|
113
|
+
loading: this.confirmLoading,
|
|
114
|
+
text: this.mobile
|
|
115
|
+
});
|
|
116
|
+
r.textContent = this.okText, r.setAttribute("modal-action", "ok"), n.appendChild(r), d.appendChild(n), l.appendChild(d);
|
|
117
|
+
}
|
|
118
|
+
t.appendChild(l), t.setAttribute("role", "dialog"), t.setAttribute("modal-action", "mask"), u(t, "click", this.#a), e.appendChild(t), this.appendToRoot(e), s(l, "modal-transition"), o && s(o, "mask-transition");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
#i() {
|
|
122
|
+
document.body.style.setProperty("overflow", this.#t);
|
|
123
|
+
const t = i(".l-modal", this.root);
|
|
124
|
+
s(t, "modal-transition", "leave", () => {
|
|
125
|
+
this.destroyOnClose && this.#l(), this.classList.remove("open"), this.dispatchEvent(new CustomEvent("close"));
|
|
126
|
+
});
|
|
127
|
+
const e = i(".l-mask", this.root);
|
|
128
|
+
e && s(e, "mask-transition", "leave");
|
|
129
|
+
}
|
|
130
|
+
disconnectedCallback() {
|
|
131
|
+
this.#l(), super.disconnectedCallback();
|
|
132
|
+
}
|
|
133
|
+
#l() {
|
|
134
|
+
const t = i(".l-modal-wrapper", this.root);
|
|
135
|
+
t && (k(t, "click", this.#a), this.root.removeChild(t));
|
|
136
|
+
const e = i(".l-mask", this.root);
|
|
137
|
+
e && this.root.removeChild(e);
|
|
138
|
+
}
|
|
139
|
+
#a = (t) => {
|
|
140
|
+
const [e, o] = y(t, "modal-action", this.root);
|
|
141
|
+
if (e) {
|
|
142
|
+
let l = "";
|
|
143
|
+
this.maskClosable && o === "mask" || o === "cancel" || o === "close" ? l = "cancel" : o === "ok" && (l = "ok"), l && this.dispatchEvent(
|
|
144
|
+
new CustomEvent(l, {
|
|
145
|
+
detail: { action: o }
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
export {
|
|
152
|
+
L as default
|
|
153
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import c from "./index.js";
|
|
2
|
+
import i from "../button/index.js";
|
|
3
|
+
import p from "../icon/close.js";
|
|
4
|
+
import d from "../icon/info.js";
|
|
5
|
+
import { regist as u } from "../utils/index.js";
|
|
6
|
+
import { $$ as b, on as m, $one as h } from "ph-utils/dom";
|
|
7
|
+
import $ from "../form/form_item.js";
|
|
8
|
+
import C from "../input/index.js";
|
|
9
|
+
function f(t, e, o, l = "alert") {
|
|
10
|
+
return new Promise((a) => {
|
|
11
|
+
const n = [];
|
|
12
|
+
if (o.icon) {
|
|
13
|
+
let s = o.icon();
|
|
14
|
+
s.setAttribute("slot", "header"), n.push(s.outerHTML);
|
|
15
|
+
}
|
|
16
|
+
n.push(`<span slot="header">${t}</span>`), l === "prompt" ? (n.push(
|
|
17
|
+
`<l-form-item label="${e}" label-position="top" inner-block>`
|
|
18
|
+
), n.push(
|
|
19
|
+
`<l-input placeholder="${o.placeholder || ""}"></l-input>`
|
|
20
|
+
), n.push("</l-form-item>")) : n.push(`<span>${e}</span>`);
|
|
21
|
+
let r = b("l-modal", {
|
|
22
|
+
cancel: `${o.showCancel}`,
|
|
23
|
+
innerHTML: n.join(""),
|
|
24
|
+
open: !0,
|
|
25
|
+
class: `l-modal-box l-modal-box--${l}`,
|
|
26
|
+
close: `${o.close}`,
|
|
27
|
+
"mask-closable": `${o.maskClosable}`
|
|
28
|
+
});
|
|
29
|
+
m(
|
|
30
|
+
r,
|
|
31
|
+
"close",
|
|
32
|
+
() => {
|
|
33
|
+
r.remove(), r = void 0;
|
|
34
|
+
},
|
|
35
|
+
{ once: !0 }
|
|
36
|
+
), m(
|
|
37
|
+
r,
|
|
38
|
+
"ok",
|
|
39
|
+
() => {
|
|
40
|
+
let s = !0;
|
|
41
|
+
l === "prompt" && (s = h(".l-modal-box l-input").value), r.removeAttribute("open"), a(s);
|
|
42
|
+
},
|
|
43
|
+
{ once: !0 }
|
|
44
|
+
), m(
|
|
45
|
+
r,
|
|
46
|
+
"cancel",
|
|
47
|
+
() => {
|
|
48
|
+
r.removeAttribute("open"), a(!1);
|
|
49
|
+
},
|
|
50
|
+
{ once: !0 }
|
|
51
|
+
), document.body.appendChild(r);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function k(t, e, o) {
|
|
55
|
+
return u([i, c, p]), new Promise((l) => {
|
|
56
|
+
const a = {
|
|
57
|
+
showCancel: !1,
|
|
58
|
+
close: 0,
|
|
59
|
+
maskClosable: !1,
|
|
60
|
+
icon: void 0,
|
|
61
|
+
...o
|
|
62
|
+
};
|
|
63
|
+
return f(e || "提示", t, a, "alert");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function v(t, e, o) {
|
|
67
|
+
u([i, c, p, d]);
|
|
68
|
+
const l = {
|
|
69
|
+
showCancel: !0,
|
|
70
|
+
close: 0,
|
|
71
|
+
maskClosable: !0,
|
|
72
|
+
icon: () => b("l-info-icon", { style: "color:#1890ff;" }),
|
|
73
|
+
...o
|
|
74
|
+
};
|
|
75
|
+
return f(e || "提示", t, l, "confirm");
|
|
76
|
+
}
|
|
77
|
+
function w(t, e, o) {
|
|
78
|
+
u([i, c, p, d, $, C]);
|
|
79
|
+
const l = {
|
|
80
|
+
showCancel: !0,
|
|
81
|
+
close: 0,
|
|
82
|
+
maskClosable: !0,
|
|
83
|
+
placeholder: "",
|
|
84
|
+
...o
|
|
85
|
+
};
|
|
86
|
+
return f(e || "提示", t, l, "prompt");
|
|
87
|
+
}
|
|
88
|
+
const j = {
|
|
89
|
+
alert: k,
|
|
90
|
+
confirm: v,
|
|
91
|
+
prompt: w
|
|
92
|
+
};
|
|
93
|
+
export {
|
|
94
|
+
j as default
|
|
95
|
+
};
|