litos-ui 0.11.0 → 0.12.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.
@@ -1,135 +0,0 @@
1
- import { $ as d, iterate as u, hasClass as h, $one as m, addClass as r, $$ as c } from "ph-utils/dom";
2
- function f(t, e) {
3
- if (h(t, "l-loading")) return;
4
- let l;
5
- if (e.fullscreen && (l = m("#l-loading-mask"), l != null))
6
- return;
7
- r(t, "l-loading"), l = c("div", { class: "l-loading-mask" }), e.background && (l.style.backgroundColor = e.background);
8
- const n = c("div", { class: "l-loading-spinner" });
9
- if (e.bar)
10
- r(l, "l-loading-bar");
11
- else {
12
- const s = document.createElementNS(
13
- "http://www.w3.org/2000/svg",
14
- "svg"
15
- );
16
- s.setAttribute("viewBox", "0 0 50 50"), s.classList.add("circle");
17
- const a = document.createElementNS(
18
- "http://www.w3.org/2000/svg",
19
- "circle"
20
- );
21
- if (a.classList.add("path"), a.setAttribute("cx", "25"), a.setAttribute("cy", "25"), a.setAttribute("r", "23"), a.setAttribute("fill", "none"), s.appendChild(a), n.appendChild(s), e.text) {
22
- const i = c("p", {
23
- class: "l-loading-text",
24
- textContent: e.text
25
- });
26
- n.appendChild(i);
27
- }
28
- }
29
- if (e.fullscreen) {
30
- const s = ["l-loading-fullscreen"];
31
- e.lock && s.push("l-loading-lock"), t.classList.add(...s), l.id = "l-loading-mask";
32
- }
33
- l.appendChild(n), t.appendChild(l), setTimeout(() => {
34
- e.bar ? r(l, "l-loading-bar--start") : l.style.opacity = "1";
35
- }, 10);
36
- }
37
- function b(t, e) {
38
- const l = e.fullscreen ? "#" : ".", n = d(`${l}l-loading-mask`, t);
39
- u(n, (s) => {
40
- function a() {
41
- const g = ["l-loading-bar--start", "l-loading-bar--finish"];
42
- t.tagName === "BODY" && g.push(
43
- "l-loading",
44
- "l-loading-fullscreen",
45
- "l-loading-lock"
46
- ), t.classList.remove(...g), s != null && t.contains(s) && (t.removeChild(s), s = void 0);
47
- }
48
- let i = -1;
49
- s.addEventListener(
50
- "transitionend",
51
- () => {
52
- cancelAnimationFrame(i), i = requestAnimationFrame(() => {
53
- a();
54
- });
55
- },
56
- { once: !0 }
57
- ), e.bar ? t.classList.add("l-loading-bar--finish") : s.style.opacity = "0", setTimeout(() => {
58
- a();
59
- }, 500);
60
- });
61
- }
62
- class p {
63
- /** 加载容器 */
64
- el;
65
- option;
66
- constructor(e) {
67
- this.option = {
68
- fullscreen: !0,
69
- lock: !0,
70
- bar: !1,
71
- text: "加载中……",
72
- background: "",
73
- ...e
74
- };
75
- const l = (e || {}).to;
76
- let n = null;
77
- l != null && (typeof l == "string" ? n = document.querySelector(l) : n = l), (n == null || this.option.fullscreen) && (n = document.body), this.el = n, this.show();
78
- }
79
- /** 显示进度条 */
80
- show() {
81
- f(this.el, this.option);
82
- }
83
- /** 隐藏进度条 */
84
- hide() {
85
- b(this.el, this.option);
86
- }
87
- }
88
- function o(t) {
89
- const e = t.getAttribute("l-loading-text"), l = t.getAttribute("l-loading-lock");
90
- return {
91
- background: t.getAttribute("l-loading-background"),
92
- text: e ? e === "0" || e === "false" ? void 0 : e : "加载中……",
93
- fullscreen: t.hasAttribute("l-loading-fullscreen"),
94
- lock: !(l === "0" || l === "false"),
95
- bar: t.hasAttribute("l-loading-bar")
96
- };
97
- }
98
- const x = {
99
- /** 创建并显示进度条 */
100
- create(t) {
101
- return new p(t);
102
- },
103
- /** 根据指令参数初始化进度条 */
104
- init(t) {
105
- const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = d(e);
106
- u(l, (n) => {
107
- const s = o(n);
108
- f(
109
- s.fullscreen ? document.body : n,
110
- o(n)
111
- );
112
- });
113
- },
114
- /**
115
- * 关闭加载中的元素
116
- *
117
- * 此函数用于关闭页面上带有特定 l-loading 属性的元素,只关闭与该 id 匹配的元素
118
- * 否则,将关闭所有带有 l-loading 属性的元素
119
- *
120
- * @param id 可选参数,指定特定的加载元素 l-loading 对应的值,如果提供,则只关闭匹配该 id 的元素
121
- */
122
- close(t) {
123
- const e = t ? `[l-loading="${t}"]` : "[l-loading]", l = d(e);
124
- u(l, (n) => {
125
- const s = o(n);
126
- b(
127
- s.fullscreen ? document.body : n,
128
- o(n)
129
- );
130
- });
131
- }
132
- };
133
- export {
134
- x as default
135
- };