litos-ui 0.0.2
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/LICENSE +21 -0
- package/README.md +1 -0
- package/lib/base.js +52 -0
- package/lib/button/index.js +28 -0
- package/lib/icon/arrow_down.js +14 -0
- package/lib/icon/base.js +38 -0
- package/lib/icon/caret_bottom.js +11 -0
- package/lib/icon/caret_top.js +11 -0
- package/lib/icon/font_icon.js +39 -0
- package/lib/icon/info.js +14 -0
- package/lib/icon/mask_close.js +14 -0
- package/lib/icon/success.js +14 -0
- package/lib/icon/warn.js +14 -0
- package/lib/index-DMj9CroY.js +4 -0
- package/lib/index-DZ2ZMrk1.js +4 -0
- package/lib/index.js +21 -0
- package/lib/message/index.js +65 -0
- package/lib/transition.js +47 -0
- package/lib/util.js +27 -0
- package/package.json +60 -0
- package/styles/message.css +53 -0
- package/styles/reset.css +49 -0
- package/styles/vars.css +36 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Tenny
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# litos-ui
|
package/lib/base.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getAttr as l } from "ph-utils/dom";
|
|
2
|
+
const d = (c, e, t) => {
|
|
3
|
+
const n = c[e];
|
|
4
|
+
return n ? typeof n == "function" ? n() : Promise.resolve(n) : new Promise((s, o) => {
|
|
5
|
+
(typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
|
|
6
|
+
o.bind(
|
|
7
|
+
null,
|
|
8
|
+
new Error(
|
|
9
|
+
"Unknown variable dynamic import: " + e + (e.split("/").length !== t ? ". Note that variables only represent file names one level deep." : "")
|
|
10
|
+
)
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
});
|
|
14
|
+
}, r = class r extends HTMLElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(), this.attachShadow({ mode: "open" });
|
|
17
|
+
}
|
|
18
|
+
get shadow() {
|
|
19
|
+
return this.shadowRoot;
|
|
20
|
+
}
|
|
21
|
+
loadStyle(e) {
|
|
22
|
+
for (let t = 0, n = e.length; t < n; t++) {
|
|
23
|
+
const s = e[t];
|
|
24
|
+
d(/* @__PURE__ */ Object.assign({ "./button/index.css": () => import("./index-DMj9CroY.js"), "./icon/index.css": () => import("./index-DZ2ZMrk1.js") }), `./${s}/index.css`, 3).then((o) => {
|
|
25
|
+
const i = document.createElement("style");
|
|
26
|
+
i.textContent = o.default.trim(), this.shadow.appendChild(i);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
setProperty(e, t) {
|
|
31
|
+
this[e] = t;
|
|
32
|
+
}
|
|
33
|
+
setProperties(e) {
|
|
34
|
+
for (const t in e)
|
|
35
|
+
this.setProperty(t, e[t]);
|
|
36
|
+
}
|
|
37
|
+
getAttr(e, t) {
|
|
38
|
+
return l(this, e, t);
|
|
39
|
+
}
|
|
40
|
+
connectedCallback() {
|
|
41
|
+
this.render();
|
|
42
|
+
}
|
|
43
|
+
disconnectedCallback() {
|
|
44
|
+
}
|
|
45
|
+
render() {
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
r.tagName = "base-component";
|
|
49
|
+
let a = r;
|
|
50
|
+
export {
|
|
51
|
+
a as default
|
|
52
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import a from "../base.js";
|
|
2
|
+
import { formatClass as o } from "ph-utils/dom";
|
|
3
|
+
const e = class e extends a {
|
|
4
|
+
constructor() {
|
|
5
|
+
super();
|
|
6
|
+
}
|
|
7
|
+
connectedCallback() {
|
|
8
|
+
this.loadStyle(["button"]), this.render();
|
|
9
|
+
}
|
|
10
|
+
render() {
|
|
11
|
+
const l = this.getAttr("type", "normal"), t = document.createElement("button"), n = [
|
|
12
|
+
"l-btn",
|
|
13
|
+
`l-btn-${l}`,
|
|
14
|
+
this.getAttr("block", !1) ? "l-btn-block" : "",
|
|
15
|
+
this.getAttr("round", !1) ? "l-btn-round" : "",
|
|
16
|
+
this.getAttr("circle", !1) ? "l-btn-circle" : "",
|
|
17
|
+
this.getAttr("ghost", !1) ? "l-btn-ghost" : "",
|
|
18
|
+
this.getAttr("text", !1) ? "l-btn-text" : "",
|
|
19
|
+
this.getAttr("loading", !1) ? "l-btn-loading" : ""
|
|
20
|
+
];
|
|
21
|
+
t.className = o(n), t.disabled = this.getAttr("disabled", !1) || this.getAttr("loading", !1), t.type = this.getAttr("html-type", "button"), t.innerHTML = "<slot></slot>", this.shadow.appendChild(t);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
e.tagName = "button";
|
|
25
|
+
let s = e;
|
|
26
|
+
export {
|
|
27
|
+
s as default
|
|
28
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import t from "./base.js";
|
|
2
|
+
const a = class a extends t {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
super.connectedCallback();
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return '<path fill="currentColor" d="M831.872 340.864 512 652.672 192.128 340.864a30.592 30.592 0 0 0-42.752 0 29.12 29.12 0 0 0 0 41.6L489.664 714.24a32 32 0 0 0 44.672 0l340.288-331.712a29.12 29.12 0 0 0 0-41.728 30.592 30.592 0 0 0-42.752 0z"></path>';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
a.tagName = "arrow-down-icon";
|
|
11
|
+
let e = a;
|
|
12
|
+
export {
|
|
13
|
+
e as default
|
|
14
|
+
};
|
package/lib/icon/base.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import a from "../base.js";
|
|
2
|
+
const s = class s extends a {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(), this.useLink = !1, this.viewBox = "0 0 1024 1024";
|
|
5
|
+
}
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
this.loadStyle(["icon"]), this.render();
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
const e = this.createEl("svg"), l = this.getAttr("useLink", this.useLink), c = this.getAttr("viewBox", this.viewBox);
|
|
11
|
+
e.classList.add("l-icon"), l || e.setAttribute("viewBox", c);
|
|
12
|
+
const t = this.renderChildren();
|
|
13
|
+
if (typeof t == "string")
|
|
14
|
+
if (t === "") {
|
|
15
|
+
const n = this.children, r = [];
|
|
16
|
+
for (let i = 0, d = n.length; i < d; i++) {
|
|
17
|
+
const o = n[i];
|
|
18
|
+
r.push(o.outerHTML), e.appendChild(o);
|
|
19
|
+
}
|
|
20
|
+
e.innerHTML = r.join("");
|
|
21
|
+
} else
|
|
22
|
+
e.innerHTML = t;
|
|
23
|
+
else
|
|
24
|
+
e.append(t);
|
|
25
|
+
this.shadow.appendChild(e);
|
|
26
|
+
}
|
|
27
|
+
renderChildren() {
|
|
28
|
+
return "";
|
|
29
|
+
}
|
|
30
|
+
createEl(e) {
|
|
31
|
+
return document.createElementNS("http://www.w3.org/2000/svg", e);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
s.tagName = "base-icon";
|
|
35
|
+
let h = s;
|
|
36
|
+
export {
|
|
37
|
+
h as default
|
|
38
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import o from "./base.js";
|
|
2
|
+
const s = class s extends o {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(), this.useLink = !0, this._t = void 0, this._start = 0;
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return "";
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
super.render();
|
|
11
|
+
}
|
|
12
|
+
disconnectedCallback() {
|
|
13
|
+
this._t != null && (cancelAnimationFrame(this._t), this._t = void 0);
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
super.connectedCallback();
|
|
17
|
+
const t = this.getAttribute("name");
|
|
18
|
+
this._start = Date.now(), t && this._loadIcon(t);
|
|
19
|
+
}
|
|
20
|
+
_loadIcon(t) {
|
|
21
|
+
Date.now() - this._start >= 1e4 || (this._t = requestAnimationFrame(() => {
|
|
22
|
+
const e = document.querySelector(`#${t}`);
|
|
23
|
+
if (e == null) {
|
|
24
|
+
this._loadIcon(t);
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
this._t = void 0;
|
|
28
|
+
let i = e.getAttribute("viewBox");
|
|
29
|
+
i || (i = "0 0 1024 1024");
|
|
30
|
+
const r = this.shadow.querySelector("svg");
|
|
31
|
+
r != null && (r.setAttribute("viewBox", i), r.innerHTML = e.innerHTML);
|
|
32
|
+
}));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
s.tagName = "font-icon";
|
|
36
|
+
let n = s;
|
|
37
|
+
export {
|
|
38
|
+
n as default
|
|
39
|
+
};
|
package/lib/icon/info.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
const c = class c extends e {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
super.connectedCallback();
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return '<path fill="currentColor" d="M512 64a448 448 0 110 896.064A448 448 0 01512 64zm67.2 275.072c33.28 0 60.288-23.104 60.288-57.344s-27.072-57.344-60.288-57.344c-33.28 0-60.16 23.104-60.16 57.344s26.88 57.344 60.16 57.344zM590.912 699.2c0-6.848 2.368-24.64 1.024-34.752l-52.608 60.544c-10.88 11.456-24.512 19.392-30.912 17.28a12.992 12.992 0 01-8.256-14.72l87.68-276.992c7.168-35.136-12.544-67.2-54.336-71.296-44.096 0-108.992 44.736-148.48 101.504 0 6.784-1.28 23.68.064 33.792l52.544-60.608c10.88-11.328 23.552-19.328 29.952-17.152a12.8 12.8 0 017.808 16.128L388.48 728.576c-10.048 32.256 8.96 63.872 55.04 71.04 67.84 0 107.904-43.648 147.456-100.416z"></path>';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
c.tagName = "info-icon";
|
|
11
|
+
let a = c;
|
|
12
|
+
export {
|
|
13
|
+
a as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
const t = class t extends e {
|
|
3
|
+
constructor() {
|
|
4
|
+
super(), this.viewBox = "0 0 24 24";
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return '<path fill="currentColor" d="M12 23a11 11 0 100-22 11 11 0 000 22zM8.82 7.4L12 10.6l3.18-3.19 1.42 1.42L13.4 12l3.19 3.18-1.42 1.42L12 13.4 8.82 16.6 7.4 15.18 10.6 12 7.4 8.82 8.82 7.4z"></path>';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
t.tagName = "mask-close-icon";
|
|
11
|
+
let r = t;
|
|
12
|
+
export {
|
|
13
|
+
r as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
const e = class e extends a {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
super.connectedCallback();
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return '<path fill="currentColor" d="M512 0C228.693333 0 0 228.693333 0 512s228.693333 512 512 512 512-228.693333 512-512S795.306667 0 512 0z m307.2 368.64L467.626667 730.453333c0 3.413333-3.413333 3.413333-3.413334 6.826667-13.653333 13.653333-37.546667 13.653333-51.2 0l-177.493333-177.493333c-13.653333-13.653333-13.653333-37.546667 0-51.2 13.653333-13.653333 37.546667-13.653333 51.2 0l150.186667 153.6 334.506666-341.333334c13.653333-13.653333 37.546667-13.653333 51.2 0 10.24 10.24 10.24 34.133333-3.413333 47.786667z m0 0"></path>';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
e.tagName = "success-icon";
|
|
11
|
+
let t = e;
|
|
12
|
+
export {
|
|
13
|
+
t as default
|
|
14
|
+
};
|
package/lib/icon/warn.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import t from "./base.js";
|
|
2
|
+
const e = class e extends t {
|
|
3
|
+
connectedCallback() {
|
|
4
|
+
super.connectedCallback();
|
|
5
|
+
}
|
|
6
|
+
renderChildren() {
|
|
7
|
+
return '<path fill="currentColor" d="M512 1024C229.234 1024 0 794.766 0 512S229.234 0 512 0s512 229.234 512 512-229.234 512-512 512z m-64.853-734.52l19.484 244.906 1.309 16.156c1.251 15.93 15.018 28.644 30.72 28.644h25.571c15.56 0 29.298-12.601 30.663-28.132l1.422-16.668 21.334-244.907c3.214-36.978-24.434-66.844-61.725-66.844h-6.627c-37.462 0-65.138 29.923-62.18 66.844zM512 801.393a66.788 66.788 0 1 0 0-133.575 66.788 66.788 0 0 0 0 133.575z"></path>';
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
e.tagName = "warn-icon";
|
|
11
|
+
let c = e;
|
|
12
|
+
export {
|
|
13
|
+
c as default
|
|
14
|
+
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
const r = ".l-btn{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #52c41a);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #31890a);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #31890a);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:var(--l-form-edit-height, 32px);border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var( --l-btn-active-border-color, var(--l-btn-active-background) );color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #31890a);--l-btn-active-text-color: var(--l-primary-color-dark1, #31890a);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color);--l-btn-hover-background: var(--l-primary-color-light1, #31890a);--l-btn-active-background: var(--l-primary-color-dark1, #31890a)}.l-btn:not(.l-btn-loading):disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;height:auto;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #52c41a);--l-btn-hover-text-color: var(--l-primary-color-light1, #31890a);--l-btn-active-text-color: var(--l-primary-color-dark1, #31890a)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height);padding:0}.l-btn-block{width:100%}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
|
|
2
|
+
export {
|
|
3
|
+
r as default
|
|
4
|
+
};
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { default as e } from "./button/index.js";
|
|
2
|
+
import { default as a } from "./icon/base.js";
|
|
3
|
+
import { default as s } from "./icon/arrow_down.js";
|
|
4
|
+
import { default as d } from "./icon/caret_top.js";
|
|
5
|
+
import { default as p } from "./icon/caret_bottom.js";
|
|
6
|
+
import { default as x } from "./icon/font_icon.js";
|
|
7
|
+
import { default as c } from "./message/index.js";
|
|
8
|
+
import { config as i, hideTransition as g, regist as B, useId as w } from "./util.js";
|
|
9
|
+
export {
|
|
10
|
+
s as ArrowDownIcon,
|
|
11
|
+
a as BaseIcon,
|
|
12
|
+
e as Button,
|
|
13
|
+
p as CaretBottomIcon,
|
|
14
|
+
d as CaretTopIcon,
|
|
15
|
+
x as FontIcon,
|
|
16
|
+
c as Message,
|
|
17
|
+
i as config,
|
|
18
|
+
g as hideTransition,
|
|
19
|
+
B as regist,
|
|
20
|
+
w as useId
|
|
21
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { regist as a, useId as u } from "../util.js";
|
|
2
|
+
import { startTransition as y, endTransition as g } from "ph-utils/dom";
|
|
3
|
+
import p from "../icon/mask_close.js";
|
|
4
|
+
import h from "../icon/success.js";
|
|
5
|
+
import $ from "../icon/warn.js";
|
|
6
|
+
import x from "../icon/info.js";
|
|
7
|
+
a(p);
|
|
8
|
+
a(h);
|
|
9
|
+
a($);
|
|
10
|
+
a(x);
|
|
11
|
+
const i = [], m = [
|
|
12
|
+
["opacity", "0"],
|
|
13
|
+
["transform", "translate3d(-50%, -100%, 0)"]
|
|
14
|
+
];
|
|
15
|
+
function d(e) {
|
|
16
|
+
const t = i.findIndex((o) => o.id === e);
|
|
17
|
+
if (t === -1) return;
|
|
18
|
+
const s = i.splice(t, 1)[0];
|
|
19
|
+
if (s == null) return;
|
|
20
|
+
g(s, m, () => {
|
|
21
|
+
s.remove();
|
|
22
|
+
});
|
|
23
|
+
const r = 15 + s.offsetHeight, n = i.length;
|
|
24
|
+
if (n !== 0)
|
|
25
|
+
for (let o = t; o < n; o++) {
|
|
26
|
+
const c = i[o], f = parseInt(c.style.top, 10) - r;
|
|
27
|
+
c.style.setProperty("top", `${f}px`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function v(e) {
|
|
31
|
+
const t = document.createElement("div");
|
|
32
|
+
t.id = e.id;
|
|
33
|
+
const s = e.type || "info";
|
|
34
|
+
let r = `l-message l-message-${s}`;
|
|
35
|
+
e.customClass && (r += " " + e.customClass), t.className = r, t.style.setProperty("top", `${e.offset}px`), t.style.setProperty("z-index", `${e.zindex || 1e3}`), e.width && t.style.setProperty("width", e.width);
|
|
36
|
+
let n = s;
|
|
37
|
+
return n === "error" && (n = "mask-close"), t.innerHTML = `
|
|
38
|
+
<div class="l-message-container">
|
|
39
|
+
<l-${n}-icon class="l-message-icon"></l-${n}-icon>
|
|
40
|
+
<span class="l-message-content">${e.message}</span>
|
|
41
|
+
</div>
|
|
42
|
+
`, t;
|
|
43
|
+
}
|
|
44
|
+
const l = (e) => {
|
|
45
|
+
const t = i.reduce(
|
|
46
|
+
(c, f) => c + f.offsetHeight + 15,
|
|
47
|
+
15
|
|
48
|
+
), s = u(), r = typeof e == "string" ? { message: e } : e;
|
|
49
|
+
r.id = s, r.offset = t;
|
|
50
|
+
const n = v(r);
|
|
51
|
+
i.push(n), document.body.appendChild(n), y(n, m);
|
|
52
|
+
let o = r.duration;
|
|
53
|
+
return o == null && (o = 3e3), o !== 0 && setTimeout(() => {
|
|
54
|
+
d(s);
|
|
55
|
+
}, o), s;
|
|
56
|
+
};
|
|
57
|
+
for (const e of ["info", "success", "error", "warn", "show"])
|
|
58
|
+
l[e] = (t) => {
|
|
59
|
+
const s = typeof t == "string" ? { message: t } : t;
|
|
60
|
+
return e !== "show" ? s.type = e : s.type == null && (s.type = "info"), l(s);
|
|
61
|
+
};
|
|
62
|
+
l.close = d;
|
|
63
|
+
export {
|
|
64
|
+
l as default
|
|
65
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import a from "./base.js";
|
|
2
|
+
import { startTransition as l, endTransition as c } from "ph-utils/dom";
|
|
3
|
+
const r = class r extends a {
|
|
4
|
+
static get observedAttributes() {
|
|
5
|
+
return ["sheets"];
|
|
6
|
+
}
|
|
7
|
+
constructor() {
|
|
8
|
+
super(), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
9
|
+
}
|
|
10
|
+
connectedCallback() {
|
|
11
|
+
super.connectedCallback(), this.show();
|
|
12
|
+
}
|
|
13
|
+
render() {
|
|
14
|
+
this.shadow.innerHTML = "<slot></slot>";
|
|
15
|
+
}
|
|
16
|
+
attributeChangedCallback(t, e, s) {
|
|
17
|
+
t === "sheets" && (this.sheetRec = this._parseSheets(s));
|
|
18
|
+
}
|
|
19
|
+
show() {
|
|
20
|
+
const t = this._getSlotFirstChild();
|
|
21
|
+
if (!t) return;
|
|
22
|
+
const e = this.getAttr("duration", "0.3s");
|
|
23
|
+
l(t, this.sheetRec, e);
|
|
24
|
+
}
|
|
25
|
+
hide(t) {
|
|
26
|
+
const e = this._getSlotFirstChild();
|
|
27
|
+
e && c(e, this.sheetRec, t);
|
|
28
|
+
}
|
|
29
|
+
_parseSheets(t) {
|
|
30
|
+
const e = t.split(";"), s = [];
|
|
31
|
+
return e.forEach((i) => {
|
|
32
|
+
if (i) {
|
|
33
|
+
const [h, n] = i.split(":");
|
|
34
|
+
s.push([h.trim(), n.trim()]);
|
|
35
|
+
}
|
|
36
|
+
}), s;
|
|
37
|
+
}
|
|
38
|
+
_getSlotFirstChild() {
|
|
39
|
+
const t = this.shadow.querySelector("slot");
|
|
40
|
+
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
r.tagName = "transition";
|
|
44
|
+
let o = r;
|
|
45
|
+
export {
|
|
46
|
+
o as Transition
|
|
47
|
+
};
|
package/lib/util.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
let f = -1, t = {
|
|
2
|
+
/** 注册应用的前缀 */
|
|
3
|
+
prefix: "l"
|
|
4
|
+
};
|
|
5
|
+
function o(e) {
|
|
6
|
+
t = { ...t, ...e };
|
|
7
|
+
}
|
|
8
|
+
function r(e, n) {
|
|
9
|
+
const i = n || `${t.prefix}-${e.tagName}`;
|
|
10
|
+
customElements.get(i) || customElements.define(i, e);
|
|
11
|
+
}
|
|
12
|
+
function s(e, n = !1) {
|
|
13
|
+
e = e || "l-transition";
|
|
14
|
+
let i = e;
|
|
15
|
+
typeof e == "string" && (i = document.querySelector(e)), i && i.hide(() => {
|
|
16
|
+
n && i.remove();
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function u() {
|
|
20
|
+
return `${t.prefix}-${++f}`;
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
o as config,
|
|
24
|
+
s as hideTransition,
|
|
25
|
+
r as regist,
|
|
26
|
+
u as useId
|
|
27
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "litos-ui",
|
|
3
|
+
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
+
"version": "0.0.2",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"devDependencies": {
|
|
7
|
+
"@eslint/js": "^9.15.0",
|
|
8
|
+
"@types/node": "^22.9.3",
|
|
9
|
+
"eslint": "^9.15.0",
|
|
10
|
+
"globals": "^15.12.0",
|
|
11
|
+
"prettier": "^3.3.3",
|
|
12
|
+
"typescript": "^5.7.2",
|
|
13
|
+
"typescript-eslint": "^8.15.0",
|
|
14
|
+
"vite": "^5.4.11",
|
|
15
|
+
"vitepress": "^1.5.0"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib",
|
|
19
|
+
"styles"
|
|
20
|
+
],
|
|
21
|
+
"main": "./lib/index.js",
|
|
22
|
+
"module": "./lib/index.js",
|
|
23
|
+
"types": "./lib/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
"./styles/*": "./styles/*",
|
|
26
|
+
"./lib/*": "./lib/*",
|
|
27
|
+
".": {
|
|
28
|
+
"import": "./lib/index.js",
|
|
29
|
+
"require": "./lib/index.js",
|
|
30
|
+
"types": "./lib/index.d.ts"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "git+https://github.com/DvShu/litos-ui.git"
|
|
36
|
+
},
|
|
37
|
+
"keywords": [
|
|
38
|
+
"litos-ui",
|
|
39
|
+
"web component",
|
|
40
|
+
"ui framework",
|
|
41
|
+
"component library"
|
|
42
|
+
],
|
|
43
|
+
"homepage": "https://dvshu.github.io/litos-ui/",
|
|
44
|
+
"bugs": {
|
|
45
|
+
"url": "https://github.com/DvShu/litos-ui/issues"
|
|
46
|
+
},
|
|
47
|
+
"license": "MIT",
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"ph-utils": "^0.10.0",
|
|
50
|
+
"shiki": "^1.23.1"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"lib:build": "vite build",
|
|
54
|
+
"docs:dev": "vitepress dev docs",
|
|
55
|
+
"docs:build": "vitepress build docs",
|
|
56
|
+
"docs:preview": "vitepress preview docs",
|
|
57
|
+
"inspect:eslint": "eslint --inspect-config",
|
|
58
|
+
"new_version": "node scripts/version.js"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.l-message {
|
|
2
|
+
position: fixed;
|
|
3
|
+
left: 50%;
|
|
4
|
+
top: 20px;
|
|
5
|
+
padding: 10px;
|
|
6
|
+
transform: translate3d(-50%, 0, 0);
|
|
7
|
+
transition:
|
|
8
|
+
opacity 0.3s,
|
|
9
|
+
transform 0.3s,
|
|
10
|
+
top 0.3s;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
border-radius: 5px;
|
|
14
|
+
font-size: 14px;
|
|
15
|
+
background: #f0faff;
|
|
16
|
+
color: var(--l-primary-color);
|
|
17
|
+
border: 1px solid #d4eeff;
|
|
18
|
+
z-index: 1000;
|
|
19
|
+
}
|
|
20
|
+
.l-message .l-message-icon {
|
|
21
|
+
margin-right: 5px;
|
|
22
|
+
}
|
|
23
|
+
.l-message.l-message-success {
|
|
24
|
+
background: #edfff3;
|
|
25
|
+
color: var(--l-success-color);
|
|
26
|
+
border-color: #bbf2cf;
|
|
27
|
+
}
|
|
28
|
+
.l-message.l-message-error {
|
|
29
|
+
background: #ffefe6;
|
|
30
|
+
color: var(--l-error-color);
|
|
31
|
+
border-color: #ffcfb8;
|
|
32
|
+
}
|
|
33
|
+
.l-message.l-message-warn {
|
|
34
|
+
background: #fff9e6;
|
|
35
|
+
color: var(--l-warn-color);
|
|
36
|
+
border-color: #ffe7a3;
|
|
37
|
+
}
|
|
38
|
+
.l-message-container {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.l-message-fade-enter-from,
|
|
44
|
+
.l-message-fade-leave-to {
|
|
45
|
+
opacity: 0;
|
|
46
|
+
transform: translate3d(-50%, -100%, 0);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media screen and (max-width: 768px) {
|
|
50
|
+
.l-message {
|
|
51
|
+
width: 90%;
|
|
52
|
+
}
|
|
53
|
+
}
|
package/styles/reset.css
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* 一般开发网页的时候,都是按照100%来开发 */
|
|
2
|
+
html,
|
|
3
|
+
body {
|
|
4
|
+
height: 100%;
|
|
5
|
+
}
|
|
6
|
+
body {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-size: 14px;
|
|
9
|
+
line-height: 1.6;
|
|
10
|
+
-webkit-text-size-adjust: 100%;
|
|
11
|
+
-webkit-tap-highlight-color: transparent;
|
|
12
|
+
}
|
|
13
|
+
/* 修复由于 inline baseline 导致的图片下方的空白间隙问题 */
|
|
14
|
+
img {
|
|
15
|
+
vertical-align: top;
|
|
16
|
+
}
|
|
17
|
+
/* 非大面积文字排版网站通常不需要列表项,如果需要可单独设置 */
|
|
18
|
+
ul,
|
|
19
|
+
ol {
|
|
20
|
+
list-style: none;
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 0;
|
|
23
|
+
}
|
|
24
|
+
/* 统一采用盒子模式 */
|
|
25
|
+
div {
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
}
|
|
28
|
+
/*
|
|
29
|
+
* 去除链接默认的下划线,提高文字可读性
|
|
30
|
+
*/
|
|
31
|
+
a {
|
|
32
|
+
text-decoration: none;
|
|
33
|
+
color: #4998f6;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
transition: color 0.3s;
|
|
36
|
+
}
|
|
37
|
+
a:hover {
|
|
38
|
+
color: #5ba2f7; /* less tint(#4998f6, 10%) */
|
|
39
|
+
}
|
|
40
|
+
a:active {
|
|
41
|
+
color: #64a7f7; /* less tint(#4998f6, 15%) */
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
p {
|
|
45
|
+
margin: 5px 0;
|
|
46
|
+
font-size: 16px;
|
|
47
|
+
line-height: 1.4;
|
|
48
|
+
color: #333;
|
|
49
|
+
}
|
package/styles/vars.css
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* button、input 元素高度 */
|
|
3
|
+
--l-form-edit-height: 32px;
|
|
4
|
+
/** 禁用状态颜色 */
|
|
5
|
+
--l-disabled-color: #f5f7fa;
|
|
6
|
+
/* 主题(primary)颜色 */
|
|
7
|
+
--l-primary-color: #722ed1;
|
|
8
|
+
--l-primary-color-light1: #9254de;
|
|
9
|
+
--l-primary-color-light2: #b37feb;
|
|
10
|
+
--l-primary-color-light3: #d3adf7;
|
|
11
|
+
--l-primary-color-light4: #efdbff;
|
|
12
|
+
--l-primary-color-light5: #f9f0ff;
|
|
13
|
+
--l-primary-color-dark1: #531dab;
|
|
14
|
+
/* 表示错误(error)的颜色 */
|
|
15
|
+
--l-error-color: #f5222d;
|
|
16
|
+
--l-error-color-light3: #ffa39e;
|
|
17
|
+
--l-error-color-light5: #fff1f0;
|
|
18
|
+
/* 表示成功(success)的颜色 */
|
|
19
|
+
--l-success-color: #52c41a;
|
|
20
|
+
--l-success-color-light1: #73d13d;
|
|
21
|
+
--l-success-color-light2: #95de64;
|
|
22
|
+
--l-success-color-light3: #b7eb8f;
|
|
23
|
+
--l-success-color-light4: #d9f7be;
|
|
24
|
+
--l-success-color-light5: #f6ffed;
|
|
25
|
+
--l-success-color-dark1: #389e0d;
|
|
26
|
+
/* 表示警告(warn)的颜色 */
|
|
27
|
+
--l-warn-color: #f90;
|
|
28
|
+
/* 表示信息(info)的颜色 */
|
|
29
|
+
--l-info-color: #999;
|
|
30
|
+
--l-info-color-light9: #f5f5f5;
|
|
31
|
+
/* 边框颜色 */
|
|
32
|
+
--l-border-color: #dedede;
|
|
33
|
+
}
|
|
34
|
+
html.dark {
|
|
35
|
+
--l-disabled-color: #262727;
|
|
36
|
+
}
|