litos-ui 0.12.0 → 0.12.1
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 +48 -0
- package/lib/base.d.ts +14 -1
- package/lib/base.js +22 -5
- package/lib/button/index.d.ts +3 -1
- package/lib/button/index.js +18 -19
- 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 +26 -20
- 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/index.d.ts +26 -2
- package/lib/index.js +106 -83
- package/lib/input/index.d.ts +1 -2
- package/lib/input/index.js +5 -8
- 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/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 +11 -10
- package/styles/vars.css +1 -0
- package/lib/litos-ui.min.js +0 -1
package/lib/tabbar/index.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { isBlank as p, isNumeric as
|
|
2
|
-
import
|
|
3
|
-
import { initAttr as
|
|
4
|
-
import { addClass as h, removeClass as f, $one as l, create as b, $ as
|
|
1
|
+
import { isBlank as p, isNumeric as g } from "ph-utils";
|
|
2
|
+
import v from "../base.js";
|
|
3
|
+
import { initAttr as y, parseAttrValue as m } from "../utils/index.js";
|
|
4
|
+
import { addClass as h, removeClass as f, $one as l, create as b, $ as u, iterate as x, on as $, off as C, shouldEventNext as k, isVisible as w, formatStyle as _, formatClass as A } from "ph-utils/dom";
|
|
5
5
|
const L = ":host{--l-tabbar-hover-color: var(--l-primary-color-light1, #9254de);--l-tabbar-active-color: var(--l-primary-color, #722ed1);--l-tabbar-item-gap: 0;--l-tabbar-height: 38px;position:relative;overflow:hidden;height:var(--l-tabbar-height);background-color:#fff;display:block}.l-tabbar-wrapper{display:flex;flex-wrap:nowrap;height:100%;align-items:stretch;gap:var(--l-tabbar-item-gap)}.l-tabbar-item{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center}.l-tabbar-item:hover{color:var(--l-tabbar-hover-color)}.l-tabbar-item.active{color:var(--l-tabbar-active-color)}.l-tabbar-item-icon{font-size:18px;margin-bottom:5px;display:flex;justify-content:center;align-items:center}.l-tabbar-item-icon.only{font-size:24px;margin-bottom:0}:host(.l-tabbar--nav){--l-tabbar-height: 50px;width:100%}:host(.l-tabbar--nav) .l-tabbar-item{flex-grow:1;display:inline-flex;flex-direction:column;justify-content:center;align-items:center;font-size:12px;line-height:1}:host(.l-tabbar--bar){--l-tabbar-bar-vertical-padding: 10px;--l-tabbar-item-gap: 30px;--l-tabbar-line-color: var(--l-primary-color, #722ed1);overflow:auto;white-space:nowrap}.l-tabbar--bar-line{position:absolute;width:32px;left:0;bottom:0;border-radius:1px;height:2px;background-color:var(--l-tabbar-line-color);transition:all .3s ease-in-out}:host(.l-tabbar--card){--l-tabbar-card-border-color: #f5f7fa;--l-tabbar-line-color: #fff;--l-tabbar-item-gap: 0;--l-tabbar-card-border-radius: 5px}.l-tabbar-card-border{position:absolute;left:0;right:0;bottom:0;height:1px;background-color:var(--l-tabbar-card-border-color)}:host(.l-tabbar--card) .l-tabbar-item{padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-tabbar--card) .l-tabbar-item:first-child{border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item:last-child{border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar-gap) .l-tabbar-item{border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-tabbar--card) .l-tabbar-item.active{background:#fff}";
|
|
6
|
-
|
|
7
|
-
let e = u.target, a = "";
|
|
8
|
-
do
|
|
9
|
-
if (t && t.isSameNode(e) || e.tagName === "BODY" || (e.getAttribute && (a = e.getAttribute(r) || ""), a === "" && (e = e.parentNode), !e)) break;
|
|
10
|
-
while (a === "");
|
|
11
|
-
return [a !== "__stop__" && a !== "", a, e];
|
|
12
|
-
}
|
|
13
|
-
class S extends y {
|
|
6
|
+
class R extends v {
|
|
14
7
|
static baseName = "tabbar";
|
|
15
8
|
/**
|
|
16
9
|
* 标签类型:
|
|
@@ -23,7 +16,7 @@ class S extends y {
|
|
|
23
16
|
gap;
|
|
24
17
|
$line;
|
|
25
18
|
constructor() {
|
|
26
|
-
super(),
|
|
19
|
+
super(), y(this);
|
|
27
20
|
}
|
|
28
21
|
connectedCallback() {
|
|
29
22
|
this.loadStyleText(L), h(this, `l-tabbar--${this.type}`), !p(this.gap) && !this.gap.startsWith("0") && h(this, "l-tabbar-gap"), super.connectedCallback(), this._init();
|
|
@@ -31,39 +24,39 @@ class S extends y {
|
|
|
31
24
|
static get observedAttributes() {
|
|
32
25
|
return ["name", "type", "justify-content", "gap"];
|
|
33
26
|
}
|
|
34
|
-
attributeChangedCallback(
|
|
35
|
-
if (
|
|
36
|
-
const
|
|
37
|
-
this.name =
|
|
38
|
-
} else if (
|
|
39
|
-
const
|
|
40
|
-
if (
|
|
27
|
+
attributeChangedCallback(e, t, a) {
|
|
28
|
+
if (e === "name") {
|
|
29
|
+
const r = m(a, void 0);
|
|
30
|
+
this.name = r, this._updateActive(), this._updateLine();
|
|
31
|
+
} else if (e === "type") {
|
|
32
|
+
const r = m(a, "nav");
|
|
33
|
+
if (r !== this.type && (f(this, `l-tabbar--${this.type}`), this.type = r, f(this, `l-tabbar--${r}`), r === "card")) {
|
|
41
34
|
let i = l(".l-tabbar-card-border", this.root);
|
|
42
35
|
i || (i = b("div", { class: "l-tabbar-card-border" }), this.root.appendChild(i));
|
|
43
36
|
}
|
|
44
37
|
} else {
|
|
45
|
-
const
|
|
46
|
-
this[
|
|
38
|
+
const r = m(a, void 0);
|
|
39
|
+
this[e] = r;
|
|
47
40
|
const i = l(".l-tabbar-wrapper", this.root);
|
|
48
|
-
i && (i.style.cssText = this.#t()),
|
|
41
|
+
i && (i.style.cssText = this.#t()), e === "gap" && (!p(this.gap) && !this.gap.startsWith("0") ? h(this, "l-tabbar-gap") : f(this, "l-tabbar-gap"));
|
|
49
42
|
}
|
|
50
43
|
}
|
|
51
44
|
disconnectedCallback() {
|
|
52
45
|
super.disconnectedCallback(), this._destroy();
|
|
53
46
|
}
|
|
54
47
|
render() {
|
|
55
|
-
const
|
|
48
|
+
const e = document.createDocumentFragment(), t = document.createElement("div");
|
|
56
49
|
if (t.className = "l-tabbar-wrapper", t.style.cssText = this.#t(), t.setAttribute("part", "default"), this.getAttr("custom-content", !1)) {
|
|
57
|
-
const
|
|
58
|
-
t.appendChild(
|
|
50
|
+
const r = document.createElement("slot");
|
|
51
|
+
t.appendChild(r);
|
|
59
52
|
} else {
|
|
60
|
-
const
|
|
61
|
-
|
|
53
|
+
const r = u("[l-name]", this);
|
|
54
|
+
r.length > 0 && x(r, (i) => {
|
|
62
55
|
const c = i.getAttribute("l-name");
|
|
63
56
|
if (c) {
|
|
64
57
|
const o = i.cloneNode(!0);
|
|
65
58
|
o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), c === this.name && o.classList.add("active");
|
|
66
|
-
const n = l("[l-icon]", o), s =
|
|
59
|
+
const n = l("[l-icon]", o), s = u(":not([l-icon])", o);
|
|
67
60
|
if (n) {
|
|
68
61
|
const d = b("div", {
|
|
69
62
|
class: [
|
|
@@ -77,53 +70,53 @@ class S extends y {
|
|
|
77
70
|
}
|
|
78
71
|
});
|
|
79
72
|
}
|
|
80
|
-
if (
|
|
81
|
-
const
|
|
82
|
-
|
|
73
|
+
if (e.appendChild(t), this.type === "card") {
|
|
74
|
+
const r = b("div", { class: "l-tabbar-card-border" });
|
|
75
|
+
e.appendChild(r);
|
|
83
76
|
}
|
|
84
|
-
return
|
|
77
|
+
return e;
|
|
85
78
|
}
|
|
86
79
|
/**
|
|
87
80
|
* 设置选项卡栏的项目列表。
|
|
88
81
|
* @param items - 选项卡栏项目的数组。
|
|
89
82
|
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
90
83
|
*/
|
|
91
|
-
setItems(
|
|
84
|
+
setItems(e) {
|
|
92
85
|
const t = l(".l-tabbar-wrapper", this.root);
|
|
93
|
-
t && (t.innerHTML = "", t.appendChild(this.#e(
|
|
86
|
+
t && (t.innerHTML = "", t.appendChild(this.#e(e)));
|
|
94
87
|
}
|
|
95
88
|
/**
|
|
96
89
|
* 向标签栏添加项目。
|
|
97
90
|
* @param items 要添加的标签栏项目数组。
|
|
98
91
|
* @returns 无返回值。
|
|
99
92
|
*/
|
|
100
|
-
addItems(
|
|
93
|
+
addItems(e) {
|
|
101
94
|
const t = l(".l-tabbar-wrapper", this.root);
|
|
102
|
-
t && t.appendChild(this.#e(
|
|
95
|
+
t && t.appendChild(this.#e(e));
|
|
103
96
|
}
|
|
104
97
|
_init() {
|
|
105
|
-
|
|
98
|
+
$(this.root, "click", this._handleClick), setTimeout(() => {
|
|
106
99
|
this._updateLine();
|
|
107
100
|
}, 300);
|
|
108
101
|
}
|
|
109
102
|
_destroy() {
|
|
110
|
-
|
|
103
|
+
C(this.root, "click", this._handleClick), this.$line = void 0;
|
|
111
104
|
}
|
|
112
|
-
_handleClick = (
|
|
113
|
-
const [t,
|
|
114
|
-
t &&
|
|
105
|
+
_handleClick = (e) => {
|
|
106
|
+
const [t, a] = k(e, "l-name", this.root);
|
|
107
|
+
t && a !== this.name && (this.name = a, this.dispatchEvent(
|
|
115
108
|
new CustomEvent("change", {
|
|
116
109
|
detail: {
|
|
117
|
-
name:
|
|
110
|
+
name: a
|
|
118
111
|
}
|
|
119
112
|
})
|
|
120
113
|
), this._updateActive(), this._updateLine());
|
|
121
114
|
};
|
|
122
115
|
_updateActive() {
|
|
123
|
-
const t = this.getAttr("custom-content", !1) ? this : this.root,
|
|
124
|
-
|
|
125
|
-
const
|
|
126
|
-
|
|
116
|
+
const t = this.getAttr("custom-content", !1) ? this : this.root, a = l(".active", t);
|
|
117
|
+
a && f(a, "active");
|
|
118
|
+
const r = l(`[l-name="${this.name}"]`, t);
|
|
119
|
+
r && h(r, "active");
|
|
127
120
|
}
|
|
128
121
|
/**
|
|
129
122
|
* 初始化线条的方法,在微任务队列中执行。
|
|
@@ -132,31 +125,31 @@ class S extends y {
|
|
|
132
125
|
_updateLine() {
|
|
133
126
|
queueMicrotask(() => {
|
|
134
127
|
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
135
|
-
const
|
|
128
|
+
const e = this.getAttr("custom-content", !1), t = l(".active", e ? this : this.root);
|
|
136
129
|
if (!t) return;
|
|
137
|
-
const
|
|
130
|
+
const a = t.offsetLeft;
|
|
138
131
|
if (!this.$line) {
|
|
139
|
-
const
|
|
140
|
-
|
|
132
|
+
const r = b("div", { class: "l-tabbar--bar-line" });
|
|
133
|
+
r.part = "line", this.root.appendChild(r), this.$line = l(".l-tabbar--bar-line", this.root);
|
|
141
134
|
}
|
|
142
|
-
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${
|
|
143
|
-
left:
|
|
135
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${a}px`, w(t, this) || this.scrollTo({
|
|
136
|
+
left: a,
|
|
144
137
|
behavior: "smooth"
|
|
145
138
|
});
|
|
146
139
|
});
|
|
147
140
|
}
|
|
148
141
|
#t() {
|
|
149
|
-
const
|
|
150
|
-
if (p(t) || (
|
|
151
|
-
let
|
|
152
|
-
|
|
142
|
+
const e = {}, t = this.getAttr("justify-content");
|
|
143
|
+
if (p(t) || (e["justify-content"] = t), !p(this.gap)) {
|
|
144
|
+
let a = this.gap;
|
|
145
|
+
g(a, { isPositive: !0 }) && (a = `${a}px`), e["--l-tabbar-item-gap"] = a;
|
|
153
146
|
}
|
|
154
|
-
return _(
|
|
147
|
+
return _(e);
|
|
155
148
|
}
|
|
156
|
-
#e(
|
|
149
|
+
#e(e) {
|
|
157
150
|
const t = document.createDocumentFragment();
|
|
158
|
-
for (let
|
|
159
|
-
const i =
|
|
151
|
+
for (let a = 0, r = e.length; a < r; a++) {
|
|
152
|
+
const i = e[a], c = b("div", {
|
|
160
153
|
class: A([
|
|
161
154
|
"l-tabbar-item",
|
|
162
155
|
this.name === i.name ? "active" : void 0
|
|
@@ -180,6 +173,5 @@ class S extends y {
|
|
|
180
173
|
}
|
|
181
174
|
}
|
|
182
175
|
export {
|
|
183
|
-
|
|
184
|
-
N as shouldEventNext
|
|
176
|
+
R as default
|
|
185
177
|
};
|
package/lib/theme/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ export default class Theme extends BaseComponent {
|
|
|
4
4
|
static baseName: string;
|
|
5
5
|
type: "button" | "select" | "switch" | "radio";
|
|
6
6
|
label?: "text" | "icon";
|
|
7
|
-
theme
|
|
8
|
-
constructor();
|
|
7
|
+
theme?: string;
|
|
9
8
|
connectedCallback(): void;
|
|
10
9
|
disconnectedCallback(): void;
|
|
11
10
|
render(): any;
|
package/lib/theme/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import l from "../base.js";
|
|
2
|
-
import { initAttr as
|
|
3
|
-
import { create as i, $one as
|
|
4
|
-
import { getTheme as
|
|
2
|
+
import { initAttr as h } from "../utils/index.js";
|
|
3
|
+
import { create as i, $one as c, on as o, off as s } from "ph-utils/dom";
|
|
4
|
+
import { getTheme as a, applyTheme as r } from "ph-utils/theme";
|
|
5
5
|
const u = ":host{display:inline-flex;width:auto}.l-theme-btn::part(default){--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-text-color: #9ca3af;--l-btn-hover-text-color: #666666;width:var(--l-form-edit-height, 32px);padding:0;font-size:18px}.l-theme-switch.l-switch--checked{background-color:#65757129;border-color:#3c3f44}.l-theme-switch.l-switch--checked::part(action){background-color:#000;color:#fff}html.dark .l-theme-btn{--l-btn-hover-text-color: #ffffff}", d = [
|
|
6
6
|
{ value: "auto", text: "跟随系统", icon: "l-theme-default-icon" },
|
|
7
7
|
{ value: "light", text: "浅色模式", icon: "l-sun-icon" },
|
|
@@ -13,14 +13,11 @@ class k extends l {
|
|
|
13
13
|
label = "text";
|
|
14
14
|
theme;
|
|
15
15
|
#t;
|
|
16
|
-
constructor() {
|
|
17
|
-
super(), c(this), this.theme = h();
|
|
18
|
-
}
|
|
19
16
|
connectedCallback() {
|
|
20
|
-
this.loadStyleText(u), super.connectedCallback(), this.#
|
|
17
|
+
h(this), this.theme = a(), this.loadStyleText(u), super.connectedCallback(), this.#h();
|
|
21
18
|
}
|
|
22
19
|
disconnectedCallback() {
|
|
23
|
-
super.disconnectedCallback(), this.#
|
|
20
|
+
super.disconnectedCallback(), this.#c();
|
|
24
21
|
}
|
|
25
22
|
render() {
|
|
26
23
|
switch (this.type) {
|
|
@@ -78,12 +75,12 @@ class k extends l {
|
|
|
78
75
|
const n = t.target.value;
|
|
79
76
|
this.type !== "switch" ? e = n : e = n ? "dark" : "light";
|
|
80
77
|
}
|
|
81
|
-
await
|
|
78
|
+
await r(e), this.theme = e, this.type === "button" && this.#n(this.#t), this.dispatchEvent(new CustomEvent("change", { detail: e }));
|
|
82
79
|
};
|
|
83
|
-
#
|
|
84
|
-
this.#t =
|
|
80
|
+
#h() {
|
|
81
|
+
this.#t = c(".l-theme-inner", this.root), this.type === "button" ? o(this.#t, "click", this.#e) : o(this.#t, "change", this.#e);
|
|
85
82
|
}
|
|
86
|
-
#
|
|
83
|
+
#c() {
|
|
87
84
|
this.#t && (this.type === "button" ? s(this.#t, "click", this.#e) : s(this.#t, "change", this.#e), this.#t = void 0);
|
|
88
85
|
}
|
|
89
86
|
}
|
package/lib/utils/index.d.ts
CHANGED
package/lib/utils/index.js
CHANGED
|
@@ -1,122 +1,116 @@
|
|
|
1
1
|
import { isBlank as N } from "ph-utils";
|
|
2
|
-
import {
|
|
3
|
-
let E = -1
|
|
4
|
-
|
|
5
|
-
prefix: "l"
|
|
6
|
-
};
|
|
7
|
-
function H(t) {
|
|
8
|
-
y = { ...y, ...t };
|
|
9
|
-
}
|
|
10
|
-
function _(t, r) {
|
|
2
|
+
import { $ as x, iterate as $, transition as y } from "ph-utils/dom";
|
|
3
|
+
let E = -1;
|
|
4
|
+
function H(t, r) {
|
|
11
5
|
const e = Array.isArray(t) ? t : [t];
|
|
12
6
|
for (const i of e) {
|
|
13
|
-
const n = r ||
|
|
7
|
+
const n = r || `l-${i.baseName}`;
|
|
14
8
|
customElements.get(n) || customElements.define(n, i);
|
|
15
9
|
}
|
|
16
10
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
11
|
+
function _() {
|
|
12
|
+
return `l-${++E}`;
|
|
19
13
|
}
|
|
20
14
|
function I(t, r, e) {
|
|
21
15
|
if (t == null) return r;
|
|
22
16
|
switch (typeof r) {
|
|
23
17
|
case "boolean":
|
|
24
|
-
return
|
|
18
|
+
return ["", "true", "1", "on", e].includes(t);
|
|
25
19
|
case "number":
|
|
26
20
|
return Number(t);
|
|
27
21
|
default:
|
|
28
22
|
return t;
|
|
29
23
|
}
|
|
30
24
|
}
|
|
31
|
-
function
|
|
25
|
+
function k(t) {
|
|
32
26
|
const r = t.attributes;
|
|
33
27
|
for (const e of r) {
|
|
34
28
|
const { name: i, value: n } = e;
|
|
35
29
|
if (i.startsWith("data-") || i.startsWith("aria-") || i.startsWith("_") || i.startsWith("$") || ["id", "class", "style"].includes(i))
|
|
36
30
|
continue;
|
|
37
|
-
const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""),
|
|
38
|
-
(t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] =
|
|
31
|
+
const s = i.split("-").map((d, h) => h === 0 ? d : d[0].toUpperCase() + d.slice(1)).join(""), u = I(n, t[s], i), f = Object.getOwnPropertyNames(t);
|
|
32
|
+
(t._ignoreInitAttrs || []).includes(s) || (i === "value" ? (t[s] = u, t._resetValue = u) : f.includes(s) && (t[s] = u));
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
function W(t, r) {
|
|
42
36
|
let e = " ";
|
|
43
37
|
return r === !0 ? e = ` ${t}` : typeof r == "string" && !N(r) && (e = ` ${t}="${r}"`), e;
|
|
44
38
|
}
|
|
45
|
-
function
|
|
39
|
+
function C(t) {
|
|
46
40
|
return t.map((e) => W(e[0], e[1])).join("");
|
|
47
41
|
}
|
|
48
|
-
function
|
|
42
|
+
function V(t, r) {
|
|
49
43
|
for (const e of r) {
|
|
50
44
|
const i = e[1], n = e[0];
|
|
51
45
|
i === !0 ? t.setAttribute(n, "") : typeof i == "string" && !N(i) && t.setAttribute(n, i);
|
|
52
46
|
}
|
|
53
47
|
}
|
|
54
|
-
function
|
|
48
|
+
function l() {
|
|
55
49
|
let t;
|
|
56
50
|
const r = {
|
|
57
51
|
attributes: !0,
|
|
58
52
|
attributeFilter: ["l-transition-emit"]
|
|
59
53
|
}, e = (s) => {
|
|
60
|
-
for (let
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
c === "show" ? (
|
|
64
|
-
h === "remove" ?
|
|
54
|
+
for (let u of s)
|
|
55
|
+
if (u.type === "attributes" && u.attributeName) {
|
|
56
|
+
const f = u.target, c = f.getAttribute(u.attributeName) || "show", d = f.getAttribute("l-transition") || "l", h = f.getAttribute("l-transition-method") || "hide";
|
|
57
|
+
c === "show" ? (f.style.removeProperty("display"), y(f, d, "enter")) : y(f, d, "leave", () => {
|
|
58
|
+
h === "remove" ? f.remove() : f.style.display = "none";
|
|
65
59
|
});
|
|
66
60
|
}
|
|
67
61
|
};
|
|
68
62
|
function i(s) {
|
|
69
|
-
s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (
|
|
70
|
-
const
|
|
71
|
-
|
|
63
|
+
s && s.length > 0 && (t == null && (t = new MutationObserver(e)), $(s, (u) => {
|
|
64
|
+
const f = u.getAttribute("l-transition");
|
|
65
|
+
f && (y(u, f, "enter"), t.observe(u, r));
|
|
72
66
|
}));
|
|
73
67
|
}
|
|
74
68
|
function n(s) {
|
|
75
|
-
s == null && (s =
|
|
69
|
+
s == null && (s = x("[l-transition]"), i(s));
|
|
76
70
|
}
|
|
77
71
|
function o() {
|
|
78
72
|
t && (t.disconnect(), t = void 0);
|
|
79
73
|
}
|
|
80
74
|
return { destroy: o, add: i, init: n };
|
|
81
75
|
}
|
|
82
|
-
function
|
|
76
|
+
function m(t, r, e, i, n = 10) {
|
|
83
77
|
let o = 0;
|
|
84
78
|
return e === "top" ? o = r.height + n : e === "bottom" ? o = -(t.height + n) : (e === "left" || e === "right") && (i === "" ? o = r.height / 2 - t.height / 2 : i === "end" && (o = r.height - t.height)), o;
|
|
85
79
|
}
|
|
86
|
-
function
|
|
80
|
+
function w(t, r, e, i, n = 10) {
|
|
87
81
|
let o = 0;
|
|
88
82
|
return e === "left" ? o = r.width + n : e === "right" ? o = -(t.width + n) : (e === "top" || e === "bottom") && (i === "" ? o = r.width / 2 - t.width / 2 : i === "end" && (o = r.width - t.width)), o;
|
|
89
83
|
}
|
|
90
|
-
function
|
|
84
|
+
function v(t, r, e, i, n, o, s, u, f = 10, c = "absolute") {
|
|
91
85
|
const d = window.innerHeight + o - 10, h = window.innerWidth + n - 10;
|
|
92
|
-
let a = t.top + o -
|
|
93
|
-
a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top",
|
|
86
|
+
let a = t.top + o - u;
|
|
87
|
+
a + r.height > d && (e === "left" || e === "right" ? i = "end" : e = "top", u = m(
|
|
94
88
|
t,
|
|
95
89
|
r,
|
|
96
90
|
e,
|
|
97
91
|
i,
|
|
98
|
-
|
|
99
|
-
), a = t.top + o -
|
|
92
|
+
f
|
|
93
|
+
), a = t.top + o - u), a < o && (e === "left" || e === "right" ? i = "start" : e = "bottom");
|
|
100
94
|
let b = t.left + n - s;
|
|
101
|
-
return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s =
|
|
95
|
+
return b + r.width > h && (e === "top" || e === "bottom" ? i = "end" : e = "left", s = w(
|
|
102
96
|
t,
|
|
103
97
|
r,
|
|
104
98
|
e,
|
|
105
99
|
i,
|
|
106
|
-
|
|
107
|
-
), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (
|
|
100
|
+
f
|
|
101
|
+
), b = t.left + n - s), b < n && (e === "top" || e === "bottom" ? i = "start" : e = "right"), c === "fixed" && (u = m(
|
|
108
102
|
t,
|
|
109
103
|
r,
|
|
110
104
|
e,
|
|
111
105
|
i,
|
|
112
|
-
|
|
113
|
-
), s =
|
|
106
|
+
f
|
|
107
|
+
), s = w(
|
|
114
108
|
t,
|
|
115
109
|
r,
|
|
116
110
|
e,
|
|
117
111
|
i,
|
|
118
|
-
|
|
119
|
-
), b = t.left + n - s, a = t.top + o -
|
|
112
|
+
f
|
|
113
|
+
), b = t.left + n - s, a = t.top + o - u), {
|
|
120
114
|
x: b,
|
|
121
115
|
y: a,
|
|
122
116
|
mainAlign: e,
|
|
@@ -124,16 +118,15 @@ function U(t, r, e, i, n, o, s, f, u = 10, c = "absolute") {
|
|
|
124
118
|
};
|
|
125
119
|
}
|
|
126
120
|
export {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
V as initAttr,
|
|
121
|
+
l as createTransition,
|
|
122
|
+
w as getPopoverOffsetX,
|
|
123
|
+
m as getPopoverOffsetY,
|
|
124
|
+
v as impactDetect,
|
|
125
|
+
k as initAttr,
|
|
133
126
|
I as parseAttrValue,
|
|
134
|
-
|
|
135
|
-
|
|
127
|
+
H as regist,
|
|
128
|
+
V as setAttrs,
|
|
136
129
|
W as tagAttr,
|
|
137
|
-
|
|
138
|
-
|
|
130
|
+
C as tagAttrs,
|
|
131
|
+
_ as useId
|
|
139
132
|
};
|
package/lib/utils/transition.js
CHANGED
|
@@ -6,7 +6,8 @@ import "ph-utils";
|
|
|
6
6
|
import "ph-utils/validator";
|
|
7
7
|
import "ph-utils/color";
|
|
8
8
|
import "ph-utils/theme";
|
|
9
|
-
|
|
9
|
+
import "ph-utils/date";
|
|
10
|
+
class S extends a {
|
|
10
11
|
static baseName = "transition";
|
|
11
12
|
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
12
13
|
sheetRec;
|
|
@@ -49,5 +50,5 @@ class C extends a {
|
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
52
|
export {
|
|
52
|
-
|
|
53
|
+
S as Transition
|
|
53
54
|
};
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litos-ui",
|
|
3
3
|
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.12.
|
|
4
|
+
"version": "0.12.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@eslint/js": "^9.
|
|
7
|
+
"@eslint/js": "^9.24.0",
|
|
8
8
|
"@eslint/markdown": "^6.3.0",
|
|
9
|
-
"@types/node": "^22.
|
|
10
|
-
"eslint": "^9.
|
|
9
|
+
"@types/node": "^22.14.0",
|
|
10
|
+
"eslint": "^9.24.0",
|
|
11
11
|
"globals": "^16.0.0",
|
|
12
|
-
"less": "^4.
|
|
12
|
+
"less": "^4.3.0",
|
|
13
13
|
"lightningcss": "^1.29.3",
|
|
14
14
|
"prettier": "^3.5.3",
|
|
15
|
-
"typescript": "^5.8.
|
|
16
|
-
"typescript-eslint": "^8.
|
|
17
|
-
"vite": "^6.2.
|
|
15
|
+
"typescript": "^5.8.3",
|
|
16
|
+
"typescript-eslint": "^8.29.1",
|
|
17
|
+
"vite": "^6.2.5",
|
|
18
18
|
"vite-plugin-dts": "^4.5.3",
|
|
19
19
|
"vitepress": "^1.6.3"
|
|
20
20
|
},
|
|
@@ -52,13 +52,14 @@
|
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"
|
|
55
|
+
"iconify-icon": "^2.3.0",
|
|
56
|
+
"ph-utils": "^0.15.4",
|
|
56
57
|
"shiki": "^3.2.1"
|
|
57
58
|
},
|
|
58
59
|
"scripts": {
|
|
59
60
|
"dev": "vite dev",
|
|
60
61
|
"build": "vite build",
|
|
61
|
-
"docs:dev": "vitepress dev docs",
|
|
62
|
+
"docs:dev": "vitepress dev docs --force",
|
|
62
63
|
"docs:build": "vitepress build docs",
|
|
63
64
|
"docs:preview": "vitepress preview docs",
|
|
64
65
|
"inspect:eslint": "eslint --inspect-config",
|
package/styles/vars.css
CHANGED