litos-ui 0.4.0 → 0.6.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 +2 -2
- package/lib/base.js +2 -1
- package/lib/browser.d.ts +2 -0
- package/lib/button/index.js +10 -11
- package/lib/color_picker/index.d.ts +0 -1
- package/lib/color_picker/index.js +15 -15
- package/lib/form/form_inner.js +25 -25
- package/lib/form/form_item.js +1 -1
- package/lib/form/index.js +1 -1
- package/lib/icon/arrow_left.d.ts +5 -0
- package/lib/icon/arrow_left.js +13 -0
- package/lib/icon/arrow_right.d.ts +5 -0
- package/lib/icon/arrow_right.js +13 -0
- package/lib/icon/arrow_up.d.ts +6 -0
- package/lib/icon/arrow_up.js +16 -0
- package/lib/icon/base.js +13 -13
- package/lib/icon/theme_default.d.ts +6 -0
- package/lib/icon/theme_default.js +16 -0
- package/lib/index-116dRdDj.js +4 -0
- package/lib/index-BUyxD_nH.js +4 -0
- package/lib/{index-1Gw78Uze.js → index-Bl8lRTJd.js} +1 -1
- package/lib/index-DJ70Xyma.js +4 -0
- package/lib/index.d.ts +18 -1
- package/lib/index.js +82 -60
- package/lib/input/index.d.ts +1 -1
- package/lib/input/index.js +14 -14
- package/lib/list/index.js +1 -1
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/message/index.js +27 -27
- package/lib/polygon/index.js +1 -1
- package/lib/popover/index.d.ts +34 -0
- package/lib/popover/index.js +153 -0
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/index.js +61 -49
- package/lib/select_ori/index.js +1 -1
- package/lib/switch/index.d.ts +2 -5
- package/lib/switch/index.js +45 -48
- package/lib/tabbar/index.js +1 -1
- package/lib/theme/index.d.ts +12 -0
- package/lib/theme/index.js +95 -0
- package/lib/theme/theme_color.d.ts +9 -0
- package/lib/theme/theme_color.js +40 -0
- package/lib/utils/clickoutside.d.ts +5 -0
- package/lib/utils/clickoutside.js +22 -0
- package/lib/utils/index.d.ts +88 -0
- package/lib/utils/index.js +139 -0
- package/lib/utils/transition.js +58 -0
- package/package.json +69 -68
- package/styles/animation.css +13 -0
- package/styles/container.css +51 -0
- package/styles/scrollbar.css +23 -0
- package/styles/transition.css +33 -0
- package/lib/event.d.ts +0 -30
- package/lib/index-CPpMuwU3.js +0 -4
- package/lib/transition.d.ts +0 -15
- package/lib/transition.js +0 -52
- package/lib/util.d.ts +0 -42
- package/lib/util.js +0 -67
- /package/lib/{event.js → utils/event.js} +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { isBlank as $ } from "ph-utils";
|
|
2
|
+
import { iterate as N, transition as w, $ as p } from "ph-utils/dom";
|
|
3
|
+
let E = -1, y = {
|
|
4
|
+
/** 注册应用的前缀 */
|
|
5
|
+
prefix: "l"
|
|
6
|
+
};
|
|
7
|
+
function j(t) {
|
|
8
|
+
y = { ...y, ...t };
|
|
9
|
+
}
|
|
10
|
+
function k(t, r) {
|
|
11
|
+
const e = Array.isArray(t) ? t : [t];
|
|
12
|
+
for (const i of e) {
|
|
13
|
+
const n = r || `${y.prefix}-${i.baseName}`;
|
|
14
|
+
customElements.get(n) || customElements.define(n, i);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
function V() {
|
|
18
|
+
return `${y.prefix}-${++E}`;
|
|
19
|
+
}
|
|
20
|
+
function W(t, r, e) {
|
|
21
|
+
if (t == null) return r;
|
|
22
|
+
switch (typeof r) {
|
|
23
|
+
case "boolean":
|
|
24
|
+
return t === "" || t === "true" || t === "1" || t === e;
|
|
25
|
+
case "number":
|
|
26
|
+
return Number(t);
|
|
27
|
+
default:
|
|
28
|
+
return t;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
function _(t) {
|
|
32
|
+
const r = t.attributes;
|
|
33
|
+
for (const e of r) {
|
|
34
|
+
const { name: i, value: n } = e;
|
|
35
|
+
if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$"))
|
|
36
|
+
continue;
|
|
37
|
+
const f = i.split("-").map((o, h) => h === 0 ? o : o[0].toUpperCase() + o.slice(1)).join(""), u = W(n, t[f], i);
|
|
38
|
+
t[f] = u, i === "value" && (t._resetValue = u);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function C(t, r) {
|
|
42
|
+
let e = " ";
|
|
43
|
+
return r === !0 ? e = ` ${t}` : typeof r == "string" && !$(r) && (e = ` ${t}="${r}"`), e;
|
|
44
|
+
}
|
|
45
|
+
function B(t) {
|
|
46
|
+
return t.map((e) => C(e[0], e[1])).join("");
|
|
47
|
+
}
|
|
48
|
+
function F(t, r) {
|
|
49
|
+
for (const e of r) {
|
|
50
|
+
const i = e[1], n = e[0];
|
|
51
|
+
i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !$(i) && t.setAttribute(n, i);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
function M() {
|
|
55
|
+
let t;
|
|
56
|
+
const r = {
|
|
57
|
+
attributes: !0,
|
|
58
|
+
attributeFilter: ["l-transition-emit"]
|
|
59
|
+
}, e = (f) => {
|
|
60
|
+
for (let u of f)
|
|
61
|
+
if (u.type === "attributes" && u.attributeName) {
|
|
62
|
+
const o = u.target, h = o.getAttribute(u.attributeName) || "show", b = o.getAttribute("l-transition") || "l", m = o.getAttribute("l-transition-method") || "hide";
|
|
63
|
+
h === "show" ? (o.style.removeProperty("display"), w(o, b, "enter")) : w(o, b, "leave", () => {
|
|
64
|
+
m === "remove" ? o.remove() : o.style.display = "none";
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
function i(f) {
|
|
69
|
+
f && f.length > 0 && (t == null && (t = new MutationObserver(e)), N(f, (u) => {
|
|
70
|
+
const o = u.getAttribute("l-transition");
|
|
71
|
+
o && (w(u, o, "enter"), t.observe(u, r));
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
function n(f) {
|
|
75
|
+
f == null && (f = p("[l-transition]"), i(f));
|
|
76
|
+
}
|
|
77
|
+
function s() {
|
|
78
|
+
t && (t.disconnect(), t = void 0);
|
|
79
|
+
}
|
|
80
|
+
return { destroy: s, add: i, init: n };
|
|
81
|
+
}
|
|
82
|
+
function c(t, r, e, i, n = 10) {
|
|
83
|
+
let s = 0;
|
|
84
|
+
return e === "top" ? s = r.height + n : e === "bottom" ? s = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? s = r.height / 2 - t.height / 2 : i === "end" && (s = r.height - t.height)), s;
|
|
85
|
+
}
|
|
86
|
+
function x(t, r, e, i, n = 10) {
|
|
87
|
+
let s = 0;
|
|
88
|
+
return e === "left" ? s = r.width + n : e === "right" ? s = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? s = r.width / 2 - t.width / 2 : i === "end" && (s = r.width - t.width)), s;
|
|
89
|
+
}
|
|
90
|
+
function U(t, r, e, i, n, s, f, u, o = 10, h = "absolute") {
|
|
91
|
+
const b = window.innerHeight + s - 10, m = window.innerWidth + n - 10;
|
|
92
|
+
let d = t.top + s - u;
|
|
93
|
+
d + r.height > b && (e === "left" || e === "right" ? i = "end" : e = "top", u = c(
|
|
94
|
+
t,
|
|
95
|
+
r,
|
|
96
|
+
e,
|
|
97
|
+
i,
|
|
98
|
+
o
|
|
99
|
+
), d = t.top + s - u), d < s && (e === "left" || e === "right" ? i = "start" : e = "bottom");
|
|
100
|
+
let a = t.left + n - f;
|
|
101
|
+
return a + r.width > m && (e === "top" || e === "bottom" ? i = "end" : e = "left", f = x(
|
|
102
|
+
t,
|
|
103
|
+
r,
|
|
104
|
+
e,
|
|
105
|
+
i,
|
|
106
|
+
o
|
|
107
|
+
), a = t.left + n - f), a < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), h === "fixed" && (u = c(
|
|
108
|
+
t,
|
|
109
|
+
r,
|
|
110
|
+
e,
|
|
111
|
+
i,
|
|
112
|
+
o
|
|
113
|
+
), f = x(
|
|
114
|
+
t,
|
|
115
|
+
r,
|
|
116
|
+
e,
|
|
117
|
+
i,
|
|
118
|
+
o
|
|
119
|
+
), a = t.left + n - f, d = t.top + s - u), {
|
|
120
|
+
x: a,
|
|
121
|
+
y: d,
|
|
122
|
+
mainAlign: e,
|
|
123
|
+
crossAlign: i
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
export {
|
|
127
|
+
j as config,
|
|
128
|
+
M as createTransition,
|
|
129
|
+
x as getPopoverOffsetX,
|
|
130
|
+
c as getPopoverOffsetY,
|
|
131
|
+
U as impactDetect,
|
|
132
|
+
_ as initAttr,
|
|
133
|
+
W as parseAttrValue,
|
|
134
|
+
k as regist,
|
|
135
|
+
F as setAttrs,
|
|
136
|
+
C as tagAttr,
|
|
137
|
+
B as tagAttrs,
|
|
138
|
+
V as useId
|
|
139
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var c = Object.defineProperty;
|
|
2
|
+
var p = (s, e, t) => e in s ? c(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var o = (s, e, t) => p(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { initAttr as d } from "./index.js";
|
|
5
|
+
import u from "../base.js";
|
|
6
|
+
import "../message/index.js";
|
|
7
|
+
import { transition as n } from "ph-utils/dom";
|
|
8
|
+
import "ph-utils";
|
|
9
|
+
import "ph-utils/validator";
|
|
10
|
+
import "../button/index.js";
|
|
11
|
+
import "../list/index.js";
|
|
12
|
+
import "ph-utils/theme";
|
|
13
|
+
class m extends u {
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
17
|
+
o(this, "sheetRec");
|
|
18
|
+
o(this, "duration", "0.3s");
|
|
19
|
+
d(this), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
20
|
+
}
|
|
21
|
+
static get observedAttributes() {
|
|
22
|
+
return ["sheets"];
|
|
23
|
+
}
|
|
24
|
+
connectedCallback() {
|
|
25
|
+
super.connectedCallback(), this.show();
|
|
26
|
+
}
|
|
27
|
+
render() {
|
|
28
|
+
this.shadow.innerHTML = "<slot></slot>";
|
|
29
|
+
}
|
|
30
|
+
attributeChangedCallback(t, r, i) {
|
|
31
|
+
t === "sheets" && (this.sheetRec = this._parseSheets(i));
|
|
32
|
+
}
|
|
33
|
+
show() {
|
|
34
|
+
const t = this._getSlotFirstChild();
|
|
35
|
+
t && n(t, this.sheetRec, "enter");
|
|
36
|
+
}
|
|
37
|
+
hide(t) {
|
|
38
|
+
const r = this._getSlotFirstChild();
|
|
39
|
+
r && n(r, this.sheetRec, "leave", t);
|
|
40
|
+
}
|
|
41
|
+
_parseSheets(t) {
|
|
42
|
+
const r = t.split(";"), i = [];
|
|
43
|
+
return r.forEach((h) => {
|
|
44
|
+
if (h) {
|
|
45
|
+
const [a, l] = h.split(":");
|
|
46
|
+
i.push([a.trim(), l.trim(), this.duration]);
|
|
47
|
+
}
|
|
48
|
+
}), i;
|
|
49
|
+
}
|
|
50
|
+
_getSlotFirstChild() {
|
|
51
|
+
const t = this.shadow.querySelector("slot");
|
|
52
|
+
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
o(m, "baseName", "transition");
|
|
56
|
+
export {
|
|
57
|
+
m as Transition
|
|
58
|
+
};
|
package/package.json
CHANGED
|
@@ -1,68 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "litos-ui",
|
|
3
|
-
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.
|
|
5
|
-
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
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
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
|
|
68
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "litos-ui",
|
|
3
|
+
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
+
"version": "0.6.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"docs:dev": "vitepress dev docs",
|
|
8
|
+
"docs:build": "vitepress build docs",
|
|
9
|
+
"docs:preview": "vitepress preview docs",
|
|
10
|
+
"inspect:eslint": "eslint --inspect-config",
|
|
11
|
+
"new_version": "node scripts/version.js",
|
|
12
|
+
"create": "node scripts/index.js create",
|
|
13
|
+
"source:build": "vite build",
|
|
14
|
+
"iife:build": "vite build -c vite_iife.config.ts --mode browser",
|
|
15
|
+
"dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
|
|
16
|
+
"lib:build": "pnpm source:build && pnpm dts:build && pnpm iife:build",
|
|
17
|
+
"vp": "scripts/publish.sh"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"@eslint/js": "^9.17.0",
|
|
21
|
+
"@types/node": "^22.10.3",
|
|
22
|
+
"eslint": "^9.17.0",
|
|
23
|
+
"globals": "^15.14.0",
|
|
24
|
+
"less": "^4.2.1",
|
|
25
|
+
"lightningcss": "^1.28.2",
|
|
26
|
+
"prettier": "^3.4.2",
|
|
27
|
+
"typescript": "^5.7.2",
|
|
28
|
+
"typescript-eslint": "^8.19.0",
|
|
29
|
+
"vite": "^6.0.6",
|
|
30
|
+
"vitepress": "^1.5.0"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"lib",
|
|
34
|
+
"styles"
|
|
35
|
+
],
|
|
36
|
+
"main": "./lib/index.js",
|
|
37
|
+
"module": "./lib/index.js",
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"jsdelivr": "./lib/litos-ui.min.js",
|
|
40
|
+
"unpkg": "./lib/litos-ui.min.js",
|
|
41
|
+
"exports": {
|
|
42
|
+
"./styles/*": "./styles/*",
|
|
43
|
+
"./lib/*": "./lib/*",
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./lib/index.js",
|
|
46
|
+
"types": "./lib/index.d.ts",
|
|
47
|
+
"require": "./lib/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/DvShu/litos-ui.git"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"litos-ui",
|
|
56
|
+
"web component",
|
|
57
|
+
"ui framework",
|
|
58
|
+
"component library"
|
|
59
|
+
],
|
|
60
|
+
"homepage": "https://dvshu.github.io/litos-ui/",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/DvShu/litos-ui/issues"
|
|
63
|
+
},
|
|
64
|
+
"license": "MIT",
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"ph-utils": "^0.13.1",
|
|
67
|
+
"shiki": "^1.24.4"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/* 旋转动画 */
|
|
2
|
+
@keyframes l-rotate-frame {
|
|
3
|
+
from {
|
|
4
|
+
transform: rotate3d(0, 0, 1, 0);
|
|
5
|
+
}
|
|
6
|
+
to {
|
|
7
|
+
transform: rotate3d(0, 0, 1, 360deg);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** 应用旋转动画 */
|
|
11
|
+
.l-rotate-anim {
|
|
12
|
+
animation: l-rotate-frame var(--l-animation-duration, 1.5s) infinite linear;
|
|
13
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
.l-container {
|
|
2
|
+
/* header高度 */
|
|
3
|
+
--l-header-height: 50px;
|
|
4
|
+
/* footer高度 */
|
|
5
|
+
--l-footer-height: var(--l-header-height, 50px);
|
|
6
|
+
/* 侧边栏宽度 */
|
|
7
|
+
--l-aside-width: 240px;
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-flow: row nowrap;
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
flex-grow: 1;
|
|
12
|
+
height: 100%;
|
|
13
|
+
}
|
|
14
|
+
.l-container .l-container {
|
|
15
|
+
height: calc(100% - var(--l-header-height));
|
|
16
|
+
}
|
|
17
|
+
.l-container.l-layout-vertical {
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
width: 100%;
|
|
20
|
+
}
|
|
21
|
+
.l-aside {
|
|
22
|
+
overflow: auto;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
width: var(--l-aside-width);
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
border-right: 1px solid #dedede;
|
|
27
|
+
padding: 10px;
|
|
28
|
+
}
|
|
29
|
+
.l-header {
|
|
30
|
+
padding: 0 10px;
|
|
31
|
+
box-sizing: border-box;
|
|
32
|
+
border-bottom: 1px solid #dedede;
|
|
33
|
+
display: flex;
|
|
34
|
+
align-items: center;
|
|
35
|
+
justify-content: space-between;
|
|
36
|
+
height: var(--l-header-height);
|
|
37
|
+
}
|
|
38
|
+
.l-footer {
|
|
39
|
+
padding: 10px;
|
|
40
|
+
box-sizing: border-box;
|
|
41
|
+
border-top: 1px solid #dedede;
|
|
42
|
+
height: var(--l-footer-height);
|
|
43
|
+
}
|
|
44
|
+
.l-main {
|
|
45
|
+
width: 100%;
|
|
46
|
+
box-sizing: border-box;
|
|
47
|
+
overflow: auto;
|
|
48
|
+
padding: 10px;
|
|
49
|
+
flex-grow: 1;
|
|
50
|
+
--webkit-overflow-scrolling: touch;
|
|
51
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@media screen and (min-width: 768px) {
|
|
2
|
+
.l-scrollbar {
|
|
3
|
+
/* 滑块背景色 */
|
|
4
|
+
--l-scrollbar-bg: #d9d9d9;
|
|
5
|
+
/* 滑块尺寸, 水平滚动条时为高度,垂直时为宽度 */
|
|
6
|
+
--l-scrollbar-size: 10px;
|
|
7
|
+
/* 鼠标悬浮时滑块颜色 */
|
|
8
|
+
--l-scrollbar-hover: #bfbfbf;
|
|
9
|
+
overflow: auto;
|
|
10
|
+
scroll-behavior: smooth;
|
|
11
|
+
}
|
|
12
|
+
.l-scrollbar::-webkit-scrollbar-thumb {
|
|
13
|
+
background: var(--l-scrollbar-bg);
|
|
14
|
+
border-radius: calc(var(--l-scrollbar-size) / 2);
|
|
15
|
+
}
|
|
16
|
+
.l-scrollbar::-webkit-scrollbar {
|
|
17
|
+
width: var(--l-scrollbar-size);
|
|
18
|
+
height: var(--l-scrollbar-size);
|
|
19
|
+
}
|
|
20
|
+
.l-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
21
|
+
background: var(--l-scrollbar-hover);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.l-opacity-enter-active,
|
|
2
|
+
.l-opacity-leave-active {
|
|
3
|
+
transition: opacity var(--l-transition-times, 0.3s) ease;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.l-opacity-enter-from,
|
|
7
|
+
.l-opacity-leave-to {
|
|
8
|
+
opacity: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.l-fadein-enter-active,
|
|
12
|
+
.l-fadein-leave-active {
|
|
13
|
+
transition:
|
|
14
|
+
opacity var(--l-transition-times, 0.3s) ease-in-out,
|
|
15
|
+
transform var(--l-transition-times, 0.3s) ease-in-out;
|
|
16
|
+
}
|
|
17
|
+
.l-fadein-enter-from,
|
|
18
|
+
.l-fadein-leave-to {
|
|
19
|
+
opacity: 0;
|
|
20
|
+
transform: translateY(var(--l-fadein-offset, -20px));
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.l-scale-enter-from,
|
|
24
|
+
.l-scale-leave-to {
|
|
25
|
+
opacity: 0;
|
|
26
|
+
transform: scale(0);
|
|
27
|
+
}
|
|
28
|
+
.l-scale-enter-active,
|
|
29
|
+
.l-scale-leave-active {
|
|
30
|
+
transition:
|
|
31
|
+
opacity var(--l-transition-times, 0.3s) ease-in-out,
|
|
32
|
+
transform var(--l-transition-times, 0.3s) ease-in-out;
|
|
33
|
+
}
|
package/lib/event.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 添加表单事件监听器。
|
|
3
|
-
* @param formId - 表单的唯一标识符。
|
|
4
|
-
* @param event - 要监听的事件类型
|
|
5
|
-
* @param cb - 当事件触发时调用的回调函数,接收两个参数:属性名和属性值。
|
|
6
|
-
* 该函数用于将回调函数添加到指定表单ID的事件监听器集合中。
|
|
7
|
-
*/
|
|
8
|
-
export declare function add(channel: string, event: string, cb: (...param: any) => void): void;
|
|
9
|
-
/**
|
|
10
|
-
* 移除指定表单的事件监听器。
|
|
11
|
-
* @param formId - 表单的唯一标识符。
|
|
12
|
-
* @param event - 要移除的事件类型,可以是 'attributeChanged' 或 'formSubmitted'。
|
|
13
|
-
* @param cb - 要移除的事件回调函数,该函数接收两个参数:属性名和属性值。
|
|
14
|
-
* 该函数会从事件存储中移除指定的回调函数,如果某个事件类型下没有更多的回调函数,则删除该事件类型;
|
|
15
|
-
* 如果表单下没有更多的事件类型,则删除该表单;如果事件存储为空,则重置事件存储。
|
|
16
|
-
*/
|
|
17
|
-
export declare function remove(channel: string, event: string, cb: (...params: any) => void): void;
|
|
18
|
-
/**
|
|
19
|
-
* 清除事件存储。如果提供了ID,则删除特定ID的事件;如果没有提供ID,则清除所有事件。
|
|
20
|
-
* 当事件存储为空时,将其设置为undefined。
|
|
21
|
-
* @param id 可选参数,指定要删除的事件ID。
|
|
22
|
-
*/
|
|
23
|
-
export declare function clear(channel?: string): void;
|
|
24
|
-
/**
|
|
25
|
-
* 触发指定表单的事件,并执行所有注册的回调函数。
|
|
26
|
-
* @param id - 表单的唯一标识符。
|
|
27
|
-
* @param event - 要触发的事件名称。
|
|
28
|
-
* @param params - 要传递给回调函数的参数列表。
|
|
29
|
-
*/
|
|
30
|
-
export declare function emit(channel: string, event: string, ...params: any): void;
|
package/lib/index-CPpMuwU3.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const i = ":host{display:inline-flex}.l-switch{--l-switch-height: 22px;--l-switch-width: 40px;display:inline-flex;box-sizing:border-box;width:var(--l-switch-width);height:var(--l-switch-height);align-items:center;justify-content:flex-start;background-color:#dcdfe6;border-radius:calc(var(--l-switch-height) / 2);padding:2px;position:relative;cursor:pointer;transition:all .3s ease-in-out;vertical-align:middle;border:1px solid #c2c2c2}.l-switch:hover,.l-switch.l-switch--checked:hover{border-color:var(--l-primary-color, #722ed1)}.l-switch--checked{background-color:var(--l-primary-color, #722ed1);border-color:var(--l-primary-color, #722ed1)}.l-switch-action{position:absolute;width:calc(var(--l-switch-height) - 6px);top:2px;left:2px;bottom:2px;background-color:#fff;border-radius:50%;transition:all .3s ease-in-out;display:flex;justify-content:center;align-items:center;padding:2px;font-size:12px;box-sizing:border-box}.l-switch-text{color:#fff;padding-left:calc(var(--l-switch-width) - 20px);transition:padding-left .3s ease-in-out}.l-switch--checked .l-switch-action{left:calc(var(--l-switch-width) - var(--l-switch-height) + 3px)}.l-switch--checked .l-switch-text{padding-left:5px}";
|
|
2
|
-
export {
|
|
3
|
-
i as default
|
|
4
|
-
};
|
package/lib/transition.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import BaseComponent from "./base";
|
|
2
|
-
export declare class Transition extends BaseComponent {
|
|
3
|
-
static tagName: string;
|
|
4
|
-
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
5
|
-
sheetRec: [string, string][];
|
|
6
|
-
static get observedAttributes(): string[];
|
|
7
|
-
constructor();
|
|
8
|
-
connectedCallback(): void;
|
|
9
|
-
render(): void;
|
|
10
|
-
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
11
|
-
private show;
|
|
12
|
-
hide(finish?: () => void): void;
|
|
13
|
-
private _parseSheets;
|
|
14
|
-
private _getSlotFirstChild;
|
|
15
|
-
}
|
package/lib/transition.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
var l = Object.defineProperty;
|
|
2
|
-
var c = (r, e, t) => e in r ? l(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
3
|
-
var o = (r, e, t) => c(r, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import d from "./base.js";
|
|
5
|
-
import { startTransition as u, endTransition as g } from "ph-utils/dom";
|
|
6
|
-
class p extends d {
|
|
7
|
-
constructor() {
|
|
8
|
-
super();
|
|
9
|
-
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
10
|
-
o(this, "sheetRec");
|
|
11
|
-
this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
12
|
-
}
|
|
13
|
-
static get observedAttributes() {
|
|
14
|
-
return ["sheets"];
|
|
15
|
-
}
|
|
16
|
-
connectedCallback() {
|
|
17
|
-
super.connectedCallback(), this.show();
|
|
18
|
-
}
|
|
19
|
-
render() {
|
|
20
|
-
this.shadow.innerHTML = "<slot></slot>";
|
|
21
|
-
}
|
|
22
|
-
attributeChangedCallback(t, s, i) {
|
|
23
|
-
t === "sheets" && (this.sheetRec = this._parseSheets(i));
|
|
24
|
-
}
|
|
25
|
-
show() {
|
|
26
|
-
const t = this._getSlotFirstChild();
|
|
27
|
-
if (!t) return;
|
|
28
|
-
const s = this.getAttr("duration", "0.3s");
|
|
29
|
-
u(t, this.sheetRec, s);
|
|
30
|
-
}
|
|
31
|
-
hide(t) {
|
|
32
|
-
const s = this._getSlotFirstChild();
|
|
33
|
-
s && g(s, this.sheetRec, t);
|
|
34
|
-
}
|
|
35
|
-
_parseSheets(t) {
|
|
36
|
-
const s = t.split(";"), i = [];
|
|
37
|
-
return s.forEach((n) => {
|
|
38
|
-
if (n) {
|
|
39
|
-
const [h, a] = n.split(":");
|
|
40
|
-
i.push([h.trim(), a.trim()]);
|
|
41
|
-
}
|
|
42
|
-
}), i;
|
|
43
|
-
}
|
|
44
|
-
_getSlotFirstChild() {
|
|
45
|
-
const t = this.shadow.querySelector("slot");
|
|
46
|
-
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
o(p, "tagName", "transition");
|
|
50
|
-
export {
|
|
51
|
-
p as Transition
|
|
52
|
-
};
|
package/lib/util.d.ts
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
type UIConfig = {
|
|
2
|
-
/** 注册应用的前缀, 默认: lt */
|
|
3
|
-
prefix: string;
|
|
4
|
-
};
|
|
5
|
-
export declare function config(cfg: Partial<UIConfig>): void;
|
|
6
|
-
/**
|
|
7
|
-
* 注册 Web Components 组件
|
|
8
|
-
* @param component Web Components 组件
|
|
9
|
-
* @param name 组件名称, 如果不填, 则根据组件的 baseName 生成
|
|
10
|
-
*/
|
|
11
|
-
export declare function regist(component: typeof HTMLElement, name?: string): void;
|
|
12
|
-
/**
|
|
13
|
-
* 隐藏 Transition 组件
|
|
14
|
-
* @param el Transition 组件或者选择器, 不传则为: l-transition
|
|
15
|
-
* @param remove 是否在隐藏后移除元素, 对应 vue-vIf
|
|
16
|
-
*/
|
|
17
|
-
export declare function hideTransition(el?: string | HTMLElement, remove?: boolean): void;
|
|
18
|
-
/**
|
|
19
|
-
* 生成一个唯一标识符,格式为:`uiConfig.prefix-递增的seed值`。
|
|
20
|
-
* 此函数用于在组件或应用中生成唯一的ID。
|
|
21
|
-
* @returns {string} 唯一标识符字符串
|
|
22
|
-
*/
|
|
23
|
-
export declare function useId(): string;
|
|
24
|
-
export declare function parseAttrValue(value: string, defaultValue?: string): string;
|
|
25
|
-
export declare function parseAttrValue(value: string, defaultValue?: boolean, key?: string): boolean;
|
|
26
|
-
export declare function parseAttrValue(value: string, defaultValue?: number, key?: string): number;
|
|
27
|
-
/**
|
|
28
|
-
* 初始化元素的属性值。
|
|
29
|
-
* 遍历元素的所有属性,并对每个属性的值进行解析,然后将解析后的值赋给元素的相应属性。
|
|
30
|
-
* @param el - 要初始化属性的 HTML 元素。
|
|
31
|
-
*/
|
|
32
|
-
export declare function initAttr(el: HTMLElement): void;
|
|
33
|
-
/**
|
|
34
|
-
* 生成 HTML 标签属性字符串。
|
|
35
|
-
* @param attr - 属性名。
|
|
36
|
-
* @param value - 属性值,可以是字符串、undefined 或布尔值。
|
|
37
|
-
* @returns 返回拼接好的属性字符串。
|
|
38
|
-
*/
|
|
39
|
-
export declare function tagAttr(attr: string, value: string | undefined | boolean): string;
|
|
40
|
-
export declare function tagAttrs(attr: [string, string | undefined | boolean][]): string;
|
|
41
|
-
export declare function setAttrs(el: HTMLElement, attrs: [string, string | undefined | boolean][]): void;
|
|
42
|
-
export {};
|