litos-ui 0.14.1 → 0.15.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/lib/description_panel/index.d.ts +12 -0
- package/lib/description_panel/index.js +23 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +68 -62
- package/lib/menu/index.js +45 -39
- package/lib/qrcode/index.d.ts +22 -0
- package/lib/qrcode/index.js +57 -0
- package/lib/tabbar/index.d.ts +2 -22
- package/lib/tabbar/index.js +47 -121
- package/lib/tabbar/item.d.ts +12 -0
- package/lib/tabbar/item.js +58 -0
- package/lib/utils/transition.js +3 -2
- package/package.json +14 -13
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class DescriptionPanel extends BaseComponent {
|
|
3
|
+
static baseName: string;
|
|
4
|
+
/** 内容折叠后的高度, 默认: 100px */
|
|
5
|
+
collapseHeight: string;
|
|
6
|
+
/** 字体大小, 默认: 12px */
|
|
7
|
+
fontSize: string;
|
|
8
|
+
static get observedAttributes(): string[] | null | undefined;
|
|
9
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
10
|
+
connectedCallback(): void;
|
|
11
|
+
render(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import a from "../base.js";
|
|
2
|
+
const l = ":host{--l-desc-panel-min-height: 100px;--l-desc-panel-font-size: 12px;--l-desc-panel-textindent: calc(var(--l-desc-panel-font-size) * 2);display:block;max-height:var(--l-desc-panel-max-height, max-content);color:#1f2937;font-size:var(--l-desc-panel-font-size);position:relative;transition:all .15s linear}";
|
|
3
|
+
class o extends a {
|
|
4
|
+
static baseName = "description-panel";
|
|
5
|
+
/** 内容折叠后的高度, 默认: 100px */
|
|
6
|
+
collapseHeight = "100px";
|
|
7
|
+
/** 字体大小, 默认: 12px */
|
|
8
|
+
fontSize = "12px";
|
|
9
|
+
static get observedAttributes() {
|
|
10
|
+
return ["collapse-height", "font-size"];
|
|
11
|
+
}
|
|
12
|
+
attributeChangedCallback(e, s, t) {
|
|
13
|
+
this[e] = t;
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
this.loadStyleText(l), super.connectedCallback();
|
|
17
|
+
}
|
|
18
|
+
render() {
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
o as default
|
|
23
|
+
};
|
package/lib/index.d.ts
CHANGED
|
@@ -45,6 +45,7 @@ export { default as List } from "./list";
|
|
|
45
45
|
export { default as Polygon } from "./polygon";
|
|
46
46
|
export { default as ColorPicker } from "./color_picker";
|
|
47
47
|
export { default as Tabbar } from "./tabbar";
|
|
48
|
+
export { default as TabbarItem } from "./tabbar/item";
|
|
48
49
|
export { default as Theme } from "./theme";
|
|
49
50
|
export { default as ThemeColor } from "./theme/theme_color";
|
|
50
51
|
export { default as DatePicker } from "./date_picker";
|
|
@@ -53,6 +54,8 @@ export { default as MenuItem } from "./menu/menu_item";
|
|
|
53
54
|
export { default as SubMenu } from "./menu/sub_menu";
|
|
54
55
|
export { default as Carousel } from "./carousel";
|
|
55
56
|
export { default as CarouselItem } from "./carousel/item";
|
|
57
|
+
export { default as Qrcode } from "./qrcode";
|
|
58
|
+
export { default as DescriptionPanel } from "./description_panel";
|
|
56
59
|
|
|
57
60
|
declare global {
|
|
58
61
|
interface HTMLElementTagNameMap {
|
|
@@ -100,6 +103,7 @@ declare global {
|
|
|
100
103
|
"l-polygon": import("./polygon").default
|
|
101
104
|
"l-color-picker": import("./color_picker").default
|
|
102
105
|
"l-tabbar": import("./tabbar").default
|
|
106
|
+
"l-tabbar-item": import("./tabbar/item").default
|
|
103
107
|
"l-theme": import("./theme").default
|
|
104
108
|
"l-theme-color": import("./theme/theme_color").default
|
|
105
109
|
"l-date-picker": import("./date_picker").default
|
|
@@ -108,5 +112,7 @@ declare global {
|
|
|
108
112
|
"l-sub-menu": import("./menu/sub_menu").default
|
|
109
113
|
"l-carousel": import("./carousel").default
|
|
110
114
|
"l-carousel-item": import("./carousel/item").default
|
|
115
|
+
"l-qrcode": import("./qrcode").default
|
|
116
|
+
"l-description-panel": import("./description_panel").default
|
|
111
117
|
}
|
|
112
118
|
}
|
package/lib/index.js
CHANGED
|
@@ -2,21 +2,21 @@ import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a,
|
|
|
2
2
|
import { set as c, remove as I } from "./utils/clickoutside.js";
|
|
3
3
|
import { default as C } from "./base.js";
|
|
4
4
|
import { default as h } from "./message/index.js";
|
|
5
|
-
import { default as
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
5
|
+
import { default as P } from "./popover/index.js";
|
|
6
|
+
import { default as D } from "./popconfirm/index.js";
|
|
7
|
+
import { default as R } from "./dialog/index.js";
|
|
8
|
+
import { default as T } from "./dialog/dialog_container.js";
|
|
9
|
+
import { default as w } from "./loading/index.js";
|
|
10
10
|
import { default as L } from "./modal/index.js";
|
|
11
11
|
import { default as B } from "./icon/base.js";
|
|
12
12
|
import { default as G } from "./icon/arrow_down.js";
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
18
|
-
import { default as
|
|
19
|
-
import { default as
|
|
13
|
+
import { default as Q } from "./icon/arrow_left.js";
|
|
14
|
+
import { default as V } from "./icon/arrow_right.js";
|
|
15
|
+
import { default as X } from "./icon/arrow_up.js";
|
|
16
|
+
import { default as j } from "./icon/caret_top.js";
|
|
17
|
+
import { default as z } from "./icon/caret_bottom.js";
|
|
18
|
+
import { default as H } from "./icon/font_icon.js";
|
|
19
|
+
import { default as K } from "./icon/loading.js";
|
|
20
20
|
import { default as Z } from "./icon/search.js";
|
|
21
21
|
import { default as $ } from "./icon/sun.js";
|
|
22
22
|
import { default as eo } from "./icon/moon.js";
|
|
@@ -29,82 +29,88 @@ import { default as co } from "./icon/close.js";
|
|
|
29
29
|
import { default as io } from "./icon/info.js";
|
|
30
30
|
import { default as go } from "./icon/success.js";
|
|
31
31
|
import { default as Ao } from "./icon/warn.js";
|
|
32
|
-
import { default as
|
|
33
|
-
import { default as
|
|
34
|
-
import { default as
|
|
35
|
-
import { default as
|
|
32
|
+
import { default as bo } from "./icon/close_filled.js";
|
|
33
|
+
import { default as Mo } from "./form/index.js";
|
|
34
|
+
import { default as So } from "./form/form_item.js";
|
|
35
|
+
import { default as ko } from "./check/radio_group.js";
|
|
36
36
|
import { default as vo } from "./check/radio.js";
|
|
37
37
|
import { default as Oo } from "./check/checkbox.js";
|
|
38
38
|
import { default as Fo } from "./check/checkbox_group.js";
|
|
39
39
|
import { default as yo } from "./button/index.js";
|
|
40
|
-
import { default as
|
|
41
|
-
import { default as
|
|
42
|
-
import { default as
|
|
43
|
-
import { default as
|
|
44
|
-
import { default as
|
|
45
|
-
import { default as
|
|
46
|
-
import { default as
|
|
40
|
+
import { default as Uo } from "./input/index.js";
|
|
41
|
+
import { default as Wo } from "./select_ori/index.js";
|
|
42
|
+
import { default as Yo } from "./switch/index.js";
|
|
43
|
+
import { default as qo } from "./md_input/index.js";
|
|
44
|
+
import { default as Eo } from "./list/index.js";
|
|
45
|
+
import { default as Jo } from "./polygon/index.js";
|
|
46
|
+
import { default as No } from "./color_picker/index.js";
|
|
47
47
|
import { default as _o } from "./tabbar/index.js";
|
|
48
|
-
import { default as oe } from "./
|
|
49
|
-
import { default as te } from "./theme/
|
|
50
|
-
import { default as ae } from "./
|
|
51
|
-
import { default as se } from "./
|
|
52
|
-
import { default as le } from "./menu/
|
|
53
|
-
import { default as pe } from "./menu/
|
|
54
|
-
import { default as xe } from "./
|
|
55
|
-
import { default as ce } from "./carousel/
|
|
48
|
+
import { default as oe } from "./tabbar/item.js";
|
|
49
|
+
import { default as te } from "./theme/index.js";
|
|
50
|
+
import { default as ae } from "./theme/theme_color.js";
|
|
51
|
+
import { default as se } from "./date_picker/index.js";
|
|
52
|
+
import { default as le } from "./menu/index.js";
|
|
53
|
+
import { default as pe } from "./menu/menu_item.js";
|
|
54
|
+
import { default as xe } from "./menu/sub_menu.js";
|
|
55
|
+
import { default as ce } from "./carousel/index.js";
|
|
56
|
+
import { default as ie } from "./carousel/item.js";
|
|
57
|
+
import { default as ge } from "./qrcode/index.js";
|
|
58
|
+
import { default as Ae } from "./description_panel/index.js";
|
|
56
59
|
export {
|
|
57
60
|
G as ArrowDownIcon,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
+
Q as ArrowLeftIcon,
|
|
62
|
+
V as ArrowRightIcon,
|
|
63
|
+
X as ArrowUpIcon,
|
|
61
64
|
C as BaseComponent,
|
|
62
65
|
B as BaseIcon,
|
|
63
66
|
yo as Button,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
z as CaretBottomIcon,
|
|
68
|
+
j as CaretTopIcon,
|
|
69
|
+
ce as Carousel,
|
|
70
|
+
ie as CarouselItem,
|
|
68
71
|
Oo as Checkbox,
|
|
69
72
|
Fo as CheckboxGroup,
|
|
70
|
-
|
|
73
|
+
bo as CloseFilledIcon,
|
|
71
74
|
co as CloseIcon,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
No as ColorPicker,
|
|
76
|
+
se as DatePicker,
|
|
77
|
+
Ae as DescriptionPanel,
|
|
78
|
+
R as Dialog,
|
|
79
|
+
T as DialogContainer,
|
|
80
|
+
H as FontIcon,
|
|
81
|
+
Mo as Form,
|
|
82
|
+
So as FormItem,
|
|
79
83
|
io as InfoIcon,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
Uo as Input,
|
|
85
|
+
Eo as List,
|
|
86
|
+
w as Loading,
|
|
87
|
+
K as LoadingIcon,
|
|
88
|
+
qo as MdInput,
|
|
89
|
+
le as Menu,
|
|
90
|
+
pe as MenuItem,
|
|
87
91
|
h as Message,
|
|
88
92
|
L as Modal,
|
|
89
93
|
eo as MoonIcon,
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
94
|
+
Jo as Polygon,
|
|
95
|
+
D as Popconfirm,
|
|
96
|
+
P as Popover,
|
|
97
|
+
ge as Qrcode,
|
|
93
98
|
vo as Radio,
|
|
94
|
-
|
|
99
|
+
ko as RadioGroup,
|
|
95
100
|
ro as ReductionIcon,
|
|
96
101
|
fo as RefreshLeftIcon,
|
|
97
102
|
uo as RefreshRightIcon,
|
|
98
103
|
Z as SearchIcon,
|
|
99
|
-
|
|
104
|
+
Wo as SelectOri,
|
|
100
105
|
mo as SortIcon,
|
|
101
|
-
|
|
106
|
+
xe as SubMenu,
|
|
102
107
|
go as SuccessIcon,
|
|
103
108
|
$ as SunIcon,
|
|
104
|
-
|
|
109
|
+
Yo as Switch,
|
|
105
110
|
_o as Tabbar,
|
|
106
|
-
oe as
|
|
107
|
-
te as
|
|
111
|
+
oe as TabbarItem,
|
|
112
|
+
te as Theme,
|
|
113
|
+
ae as ThemeColor,
|
|
108
114
|
xo as ThemeDefaultIcon,
|
|
109
115
|
Ao as WarnIcon,
|
|
110
116
|
c as addClickOutside,
|
package/lib/menu/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { on as
|
|
1
|
+
import { on as c, off as u, $$ as h, $ as a, iterate as d, $one as f } from "ph-utils/dom";
|
|
2
2
|
import m from "../base.js";
|
|
3
3
|
import { initAttr as b } from "../utils/index.js";
|
|
4
4
|
const p = ":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)}";
|
|
@@ -20,44 +20,44 @@ class x extends m {
|
|
|
20
20
|
), this.loadStyleText(p), super.connectedCallback();
|
|
21
21
|
}
|
|
22
22
|
static get observedAttributes() {
|
|
23
|
-
return ["
|
|
23
|
+
return ["selected-key", "orientation"];
|
|
24
24
|
}
|
|
25
|
-
attributeChangedCallback(
|
|
25
|
+
attributeChangedCallback(e, s, t) {
|
|
26
26
|
if (this.rendered) {
|
|
27
|
-
if (
|
|
28
|
-
this.selectedKey !==
|
|
29
|
-
else if (
|
|
30
|
-
const
|
|
31
|
-
|
|
27
|
+
if (e === "selected-key")
|
|
28
|
+
this.selectedKey !== t && this.updateSelectedKeys(t);
|
|
29
|
+
else if (e === "orientation") {
|
|
30
|
+
const i = this.classList;
|
|
31
|
+
i.remove(`l-menu--${s}`), i.add(`l-menu--${t}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
afterInit() {
|
|
36
|
-
|
|
36
|
+
c(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
|
|
37
37
|
}
|
|
38
38
|
beforeDestroy() {
|
|
39
|
-
|
|
39
|
+
u(this, "click", this.#t);
|
|
40
40
|
}
|
|
41
41
|
render() {
|
|
42
|
-
return
|
|
42
|
+
return h("slot");
|
|
43
43
|
}
|
|
44
|
-
#t = (
|
|
45
|
-
const { type:
|
|
46
|
-
|
|
44
|
+
#t = (e) => {
|
|
45
|
+
const { type: s, key: t, keyPaths: i, target: n } = this.#e(
|
|
46
|
+
e.target
|
|
47
47
|
);
|
|
48
|
-
|
|
48
|
+
n && (s === 2 ? n.hasAttribute("expanded") ? n.removeAttribute("expanded") : (n.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(i, !0)) : s === 1 && (this.#i(i), this.updateSelectedKeys(t), this.emit("select", { detail: { key: t, keyPaths: i } })));
|
|
49
49
|
};
|
|
50
|
-
#e(
|
|
51
|
-
let
|
|
52
|
-
const
|
|
50
|
+
#e(e, s) {
|
|
51
|
+
let t = 0, i = "", n;
|
|
52
|
+
const l = [];
|
|
53
53
|
do {
|
|
54
|
-
const
|
|
55
|
-
if (["L-MENU", "BODY"].includes(
|
|
54
|
+
const o = e.tagName;
|
|
55
|
+
if (["L-MENU", "BODY"].includes(o))
|
|
56
56
|
break;
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
} while (
|
|
60
|
-
return { type:
|
|
57
|
+
const r = e.getAttribute("key");
|
|
58
|
+
r && (i || (i = r), l.unshift(r), s && s(e, r)), t === 0 && (o === "L-MENU-ITEM" ? (t = 1, n = e) : o === "L-SUB-MENU" && (n = e, t = 2)), e = e.parentElement;
|
|
59
|
+
} while (t >= 0);
|
|
60
|
+
return { type: t, key: i, keyPaths: l, target: n };
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* 展开与提供的 keys 对应的子菜单。
|
|
@@ -69,24 +69,30 @@ class x extends m {
|
|
|
69
69
|
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
70
70
|
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
71
71
|
*/
|
|
72
|
-
expandSubmenus(
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const
|
|
76
|
-
|
|
72
|
+
expandSubmenus(e, s = !1) {
|
|
73
|
+
const t = a("l-sub-menu[key]", this);
|
|
74
|
+
d(t, (i) => {
|
|
75
|
+
const n = i.getAttribute("key") || "";
|
|
76
|
+
e.includes(n) ? i.setAttribute("expanded", "") : s && i.removeAttribute("expanded");
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
updateSelectedKeys(
|
|
80
|
-
this.selectedKey =
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
e
|
|
84
|
-
|
|
79
|
+
updateSelectedKeys(e) {
|
|
80
|
+
this.selectedKey = e;
|
|
81
|
+
const s = f(`l-menu-item[key="${e}"]`, this);
|
|
82
|
+
if (s) {
|
|
83
|
+
const t = this.#e(s, (i) => {
|
|
84
|
+
i.setAttribute("active", ""), i.setAttribute("expanded", "");
|
|
85
|
+
});
|
|
86
|
+
this.#i(t.keyPaths);
|
|
87
|
+
}
|
|
85
88
|
}
|
|
86
|
-
#i(
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
t.
|
|
89
|
+
#i(e) {
|
|
90
|
+
const s = a("l-menu-item[active]", this);
|
|
91
|
+
d(s, (t) => {
|
|
92
|
+
const i = t.getAttribute("key") || "";
|
|
93
|
+
e.includes(i) || this.#e(t, (n, l) => {
|
|
94
|
+
e.includes(l) || (n.removeAttribute("expanded"), n.removeAttribute("active"));
|
|
95
|
+
});
|
|
90
96
|
});
|
|
91
97
|
}
|
|
92
98
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Qrcode extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 二维码内容 */
|
|
6
|
+
text?: string;
|
|
7
|
+
/** 二维码颜色 */
|
|
8
|
+
fill: string;
|
|
9
|
+
/** 二维码大小 */
|
|
10
|
+
size?: string | number;
|
|
11
|
+
/** 二维码等级 */
|
|
12
|
+
level?: "L" | "M" | "Q" | "H";
|
|
13
|
+
/** 插入二维码中间的图标 */
|
|
14
|
+
icon?: string;
|
|
15
|
+
private _qrcode?;
|
|
16
|
+
connectedCallback(): void;
|
|
17
|
+
static get observedAttributes(): string[] | null | undefined;
|
|
18
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
19
|
+
afterInit(): void;
|
|
20
|
+
beforeDestroy(): void;
|
|
21
|
+
render(): string;
|
|
22
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import s from "../base.js";
|
|
2
|
+
import { QRCodeRender as o, renderToCanvas as r } from "qrcode-generator-es";
|
|
3
|
+
import { $one as c } from "ph-utils/dom";
|
|
4
|
+
const n = ":host{display:inline-flex}.renderer-el{display:inline-flex}";
|
|
5
|
+
class f extends s {
|
|
6
|
+
static baseName = "qrcode";
|
|
7
|
+
/** 二维码内容 */
|
|
8
|
+
text;
|
|
9
|
+
/** 二维码颜色 */
|
|
10
|
+
fill = "#000000";
|
|
11
|
+
/** 二维码大小 */
|
|
12
|
+
size = "100";
|
|
13
|
+
/** 二维码等级 */
|
|
14
|
+
level = "M";
|
|
15
|
+
/** 插入二维码中间的图标 */
|
|
16
|
+
icon;
|
|
17
|
+
_qrcode;
|
|
18
|
+
connectedCallback() {
|
|
19
|
+
this.loadStyleText(n), super.connectedCallback();
|
|
20
|
+
}
|
|
21
|
+
static get observedAttributes() {
|
|
22
|
+
return ["text", "fill", "size", "level", "icon"];
|
|
23
|
+
}
|
|
24
|
+
attributeChangedCallback(e, t, i) {
|
|
25
|
+
t !== i && (this[e] = i, this.#t(e, i), this.#e());
|
|
26
|
+
}
|
|
27
|
+
afterInit() {
|
|
28
|
+
this.#e();
|
|
29
|
+
}
|
|
30
|
+
beforeDestroy() {
|
|
31
|
+
this._qrcode = void 0;
|
|
32
|
+
}
|
|
33
|
+
#t(e, t) {
|
|
34
|
+
this._qrcode && (e === "icon" ? this._qrcode.option.icon = t ? { src: t } : void 0 : this._qrcode.option[e] = t);
|
|
35
|
+
}
|
|
36
|
+
#e() {
|
|
37
|
+
if (!this._qrcode) {
|
|
38
|
+
const e = c("canvas", this.root);
|
|
39
|
+
e && (console.log(this.icon), this._qrcode = new o({
|
|
40
|
+
renderFn: r,
|
|
41
|
+
text: this.text,
|
|
42
|
+
size: Number(this.size),
|
|
43
|
+
level: this.level,
|
|
44
|
+
fill: this.fill,
|
|
45
|
+
icon: this.icon ? { src: this.icon } : void 0,
|
|
46
|
+
el: e
|
|
47
|
+
}));
|
|
48
|
+
}
|
|
49
|
+
this._qrcode != null && this.text && this._qrcode.render();
|
|
50
|
+
}
|
|
51
|
+
render() {
|
|
52
|
+
return "<canvas class='renderer-el' width='100' height='100'></canvas>";
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
export {
|
|
56
|
+
f as default
|
|
57
|
+
};
|
package/lib/tabbar/index.d.ts
CHANGED
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
type TabbarItem = {
|
|
3
|
-
name: string;
|
|
4
|
-
text?: string | (() => string | HTMLElement);
|
|
5
|
-
icon?: string | (() => string | HTMLElement);
|
|
6
|
-
};
|
|
7
2
|
export default class Tabbar extends BaseComponent {
|
|
8
3
|
#private;
|
|
9
4
|
static baseName: string;
|
|
@@ -17,26 +12,12 @@ export default class Tabbar extends BaseComponent {
|
|
|
17
12
|
name?: string;
|
|
18
13
|
gap?: string;
|
|
19
14
|
private $line?;
|
|
20
|
-
constructor();
|
|
21
15
|
connectedCallback(): void;
|
|
22
16
|
static get observedAttributes(): string[] | null | undefined;
|
|
23
17
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
24
|
-
disconnectedCallback(): void;
|
|
25
18
|
render(): any;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
* @param items - 选项卡栏项目的数组。
|
|
29
|
-
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
30
|
-
*/
|
|
31
|
-
setItems(items: TabbarItem[]): void;
|
|
32
|
-
/**
|
|
33
|
-
* 向标签栏添加项目。
|
|
34
|
-
* @param items 要添加的标签栏项目数组。
|
|
35
|
-
* @returns 无返回值。
|
|
36
|
-
*/
|
|
37
|
-
addItems(items: TabbarItem[]): void;
|
|
38
|
-
private _init;
|
|
39
|
-
private _destroy;
|
|
19
|
+
afterInit(): void;
|
|
20
|
+
beforeDestroy(): void;
|
|
40
21
|
private _handleClick;
|
|
41
22
|
private _updateActive;
|
|
42
23
|
/**
|
|
@@ -45,4 +26,3 @@ export default class Tabbar extends BaseComponent {
|
|
|
45
26
|
*/
|
|
46
27
|
private _updateLine;
|
|
47
28
|
}
|
|
48
|
-
export {};
|
package/lib/tabbar/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isBlank as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { addClass as
|
|
5
|
-
const
|
|
6
|
-
class
|
|
1
|
+
import { isBlank as h, isNumeric as c } from "ph-utils";
|
|
2
|
+
import d from "../base.js";
|
|
3
|
+
import { parseAttrValue as l } from "../utils/index.js";
|
|
4
|
+
import { addClass as b, removeClass as o, $one as r, create as n, $$ as p, on as f, off as m, shouldEventNext as u, isVisible as v } from "ph-utils/dom";
|
|
5
|
+
const g = ":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:flex;flex-wrap:nowrap;align-items:stretch;gap:var(--l-tabbar-item-gap);box-sizing:border-box}:host(.l-tabbar--nav){--l-tabbar-height: 50px;--l-tabbar-item-grow: 1;width:100%}: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)}";
|
|
6
|
+
class _ extends d {
|
|
7
7
|
static baseName = "tabbar";
|
|
8
8
|
/**
|
|
9
9
|
* 标签类型:
|
|
@@ -15,96 +15,46 @@ class R extends v {
|
|
|
15
15
|
name;
|
|
16
16
|
gap;
|
|
17
17
|
$line;
|
|
18
|
-
constructor() {
|
|
19
|
-
super(), y(this);
|
|
20
|
-
}
|
|
21
18
|
connectedCallback() {
|
|
22
|
-
this.loadStyleText(
|
|
19
|
+
this.loadStyleText(g), b(this, `l-tabbar--${this.type}`), this.#t(), super.connectedCallback();
|
|
23
20
|
}
|
|
24
21
|
static get observedAttributes() {
|
|
25
22
|
return ["name", "type", "justify-content", "gap"];
|
|
26
23
|
}
|
|
27
|
-
attributeChangedCallback(
|
|
28
|
-
if (
|
|
29
|
-
const
|
|
30
|
-
this.name =
|
|
31
|
-
} else if (
|
|
32
|
-
const
|
|
33
|
-
if (
|
|
34
|
-
let
|
|
35
|
-
|
|
24
|
+
attributeChangedCallback(t, e, a) {
|
|
25
|
+
if (t === "name") {
|
|
26
|
+
const i = l(a, void 0);
|
|
27
|
+
this.name = i, this._updateActive(), this._updateLine();
|
|
28
|
+
} else if (t === "type") {
|
|
29
|
+
const i = l(a, "nav");
|
|
30
|
+
if (i !== this.type && (o(this, `l-tabbar--${this.type}`), this.type = i, o(this, `l-tabbar--${i}`), i === "card")) {
|
|
31
|
+
let s = r(".l-tabbar-card-border", this.root);
|
|
32
|
+
s || (s = n("div", { class: "l-tabbar-card-border" }), this.root.appendChild(s));
|
|
36
33
|
}
|
|
37
34
|
} else {
|
|
38
|
-
const
|
|
39
|
-
this[
|
|
40
|
-
const i = l(".l-tabbar-wrapper", this.root);
|
|
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"));
|
|
35
|
+
const i = l(a, void 0);
|
|
36
|
+
this[t] = i, this.#t();
|
|
42
37
|
}
|
|
43
38
|
}
|
|
44
|
-
disconnectedCallback() {
|
|
45
|
-
super.disconnectedCallback(), this._destroy();
|
|
46
|
-
}
|
|
47
39
|
render() {
|
|
48
|
-
const
|
|
49
|
-
if (t.
|
|
50
|
-
const
|
|
51
|
-
t.appendChild(
|
|
52
|
-
} else {
|
|
53
|
-
const r = u("[l-name]", this);
|
|
54
|
-
r.length > 0 && x(r, (i) => {
|
|
55
|
-
const c = i.getAttribute("l-name");
|
|
56
|
-
if (c) {
|
|
57
|
-
const o = i.cloneNode(!0);
|
|
58
|
-
o.classList.add("l-tabbar-item"), o.setAttribute("part", "item"), c === this.name && o.classList.add("active");
|
|
59
|
-
const n = l("[l-icon]", o), s = u(":not([l-icon])", o);
|
|
60
|
-
if (n) {
|
|
61
|
-
const d = b("div", {
|
|
62
|
-
class: [
|
|
63
|
-
"l-tabbar-item-icon",
|
|
64
|
-
s.length === 0 ? "only" : void 0
|
|
65
|
-
]
|
|
66
|
-
});
|
|
67
|
-
d.appendChild(n.cloneNode(!0)), n.replaceWith(d);
|
|
68
|
-
}
|
|
69
|
-
t.appendChild(o);
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
if (e.appendChild(t), this.type === "card") {
|
|
74
|
-
const r = b("div", { class: "l-tabbar-card-border" });
|
|
75
|
-
e.appendChild(r);
|
|
40
|
+
const t = document.createDocumentFragment();
|
|
41
|
+
if (t.appendChild(p("slot")), this.type === "card") {
|
|
42
|
+
const e = n("div", { class: "l-tabbar-card-border" });
|
|
43
|
+
t.appendChild(e);
|
|
76
44
|
}
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* 设置选项卡栏的项目列表。
|
|
81
|
-
* @param items - 选项卡栏项目的数组。
|
|
82
|
-
* 该方法首先清空选项卡栏的包装器元素,然后根据传入的项目数组创建并追加新的选项卡项目。
|
|
83
|
-
*/
|
|
84
|
-
setItems(e) {
|
|
85
|
-
const t = l(".l-tabbar-wrapper", this.root);
|
|
86
|
-
t && (t.innerHTML = "", t.appendChild(this.#e(e)));
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 向标签栏添加项目。
|
|
90
|
-
* @param items 要添加的标签栏项目数组。
|
|
91
|
-
* @returns 无返回值。
|
|
92
|
-
*/
|
|
93
|
-
addItems(e) {
|
|
94
|
-
const t = l(".l-tabbar-wrapper", this.root);
|
|
95
|
-
t && t.appendChild(this.#e(e));
|
|
45
|
+
return t;
|
|
96
46
|
}
|
|
97
|
-
|
|
98
|
-
|
|
47
|
+
afterInit() {
|
|
48
|
+
f(this.root, "click", this._handleClick), setTimeout(() => {
|
|
99
49
|
this._updateLine();
|
|
100
50
|
}, 300);
|
|
101
51
|
}
|
|
102
|
-
|
|
103
|
-
|
|
52
|
+
beforeDestroy() {
|
|
53
|
+
m(this.root, "click", this._handleClick), this.$line = void 0;
|
|
104
54
|
}
|
|
105
|
-
_handleClick = (
|
|
106
|
-
const [
|
|
107
|
-
|
|
55
|
+
_handleClick = (t) => {
|
|
56
|
+
const [e, a] = u(t, "name", this);
|
|
57
|
+
e && a !== this.name && (this.name = a, console.log(a), this.dispatchEvent(
|
|
108
58
|
new CustomEvent("change", {
|
|
109
59
|
detail: {
|
|
110
60
|
name: a
|
|
@@ -113,10 +63,10 @@ class R extends v {
|
|
|
113
63
|
), this._updateActive(), this._updateLine());
|
|
114
64
|
};
|
|
115
65
|
_updateActive() {
|
|
116
|
-
const t =
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
66
|
+
const t = r(".active", this);
|
|
67
|
+
t && o(t, "active");
|
|
68
|
+
const e = r(`[name="${this.name}"]`, this);
|
|
69
|
+
e && b(e, "active");
|
|
120
70
|
}
|
|
121
71
|
/**
|
|
122
72
|
* 初始化线条的方法,在微任务队列中执行。
|
|
@@ -125,53 +75,29 @@ class R extends v {
|
|
|
125
75
|
_updateLine() {
|
|
126
76
|
queueMicrotask(() => {
|
|
127
77
|
if (!this.name || this.type === "nav" || !this.rendered) return;
|
|
128
|
-
const
|
|
78
|
+
const t = r(".active", this);
|
|
129
79
|
if (!t) return;
|
|
130
|
-
const
|
|
80
|
+
const e = t.offsetLeft;
|
|
131
81
|
if (!this.$line) {
|
|
132
|
-
const
|
|
133
|
-
|
|
82
|
+
const a = n("div", { class: "l-tabbar--bar-line" });
|
|
83
|
+
a.part = "line", this.root.appendChild(a), this.$line = r(".l-tabbar--bar-line", this.root);
|
|
134
84
|
}
|
|
135
|
-
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${
|
|
136
|
-
left:
|
|
85
|
+
this.$line.style.cssText = `width:${t.offsetWidth}px;left:${e}px`, v(t, this) || this.scrollTo({
|
|
86
|
+
left: e,
|
|
137
87
|
behavior: "smooth"
|
|
138
88
|
});
|
|
139
89
|
});
|
|
140
90
|
}
|
|
141
91
|
#t() {
|
|
142
|
-
const
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
#e(e) {
|
|
150
|
-
const t = document.createDocumentFragment();
|
|
151
|
-
for (let a = 0, r = e.length; a < r; a++) {
|
|
152
|
-
const i = e[a], c = b("div", {
|
|
153
|
-
class: A([
|
|
154
|
-
"l-tabbar-item",
|
|
155
|
-
this.name === i.name ? "active" : void 0
|
|
156
|
-
]),
|
|
157
|
-
"l-name": i.name,
|
|
158
|
-
part: "item"
|
|
159
|
-
}), o = i.icon;
|
|
160
|
-
if (o) {
|
|
161
|
-
const s = b("div", { class: "l-tabbar-item-icon" });
|
|
162
|
-
let d = typeof o == "string" ? o : o();
|
|
163
|
-
typeof d == "string" ? s.innerHTML = d : s.appendChild(d), c.appendChild(s);
|
|
164
|
-
}
|
|
165
|
-
const n = i.text;
|
|
166
|
-
if (n) {
|
|
167
|
-
let s = typeof n == "string" ? n : n();
|
|
168
|
-
typeof s == "string" ? c.appendChild(b(s)) : c.appendChild(s);
|
|
169
|
-
}
|
|
170
|
-
t.appendChild(c);
|
|
92
|
+
const t = this.getAttr("justify-content");
|
|
93
|
+
if (h(t) ? this.style.removeProperty("justify-content") : this.style.setProperty("justify-content", t), h(this.gap))
|
|
94
|
+
this.style.removeProperty("--l-tabbar-item-gap"), o(this, "l-tabbar-gap");
|
|
95
|
+
else {
|
|
96
|
+
let e = this.gap;
|
|
97
|
+
c(e, { isPositive: !0 }) && (e = `${e}px`), b(this, "l-tabbar-gap"), this.style.setProperty("--l-tabbar-item-gap", e);
|
|
171
98
|
}
|
|
172
|
-
return t;
|
|
173
99
|
}
|
|
174
100
|
}
|
|
175
101
|
export {
|
|
176
|
-
|
|
102
|
+
_ as default
|
|
177
103
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class TabbarItem extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
name: string;
|
|
6
|
+
icon?: boolean;
|
|
7
|
+
onlyIcon?: boolean;
|
|
8
|
+
static get observedAttributes(): string[] | null | undefined;
|
|
9
|
+
connectedCallback(): void;
|
|
10
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
11
|
+
render(): DocumentFragment;
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import l from "../base.js";
|
|
2
|
+
import { parseAttrValue as s } from "../utils/index.js";
|
|
3
|
+
import { addClass as i, $one as a, $$ as r, removeClass as c } from "ph-utils/dom";
|
|
4
|
+
const d = ":host{color:#666;transition:all .3s ease-in-out;cursor:pointer;display:inline-flex;justify-content:center;align-items:center;line-height:1;flex-direction:column;flex-grow:var(--l-tabbar-item-grow, 0);box-sizing:border-box}:host(:hover){color:var(--l-tabbar-hover-color)}:host(.active){color:var(--l-tabbar-active-color)}.icon-wrapper{font-size:18px;margin-bottom:3px;display:flex;justify-content:center;align-items:center}.icon-wrapper.only{font-size:24px;margin-bottom:0}:host(.l-item--card){padding:0 15px;background:#f5f7fa;border:1px solid #f0f0f0}:host(.l-item--card:first-child){border-top-left-radius:var(--l-tabbar-card-border-radius)}:host(.l-item--card:last-child){border-top-right-radius:var(--l-tabbar-card-border-radius)}:host(.l-item--card.active){background:#fff}:host(.l-item--gap){border-top-left-radius:var(--l-tabbar-card-border-radius);border-top-right-radius:var(--l-tabbar-card-border-radius)}";
|
|
5
|
+
class m extends l {
|
|
6
|
+
static baseName = "tabbar-item";
|
|
7
|
+
name;
|
|
8
|
+
icon;
|
|
9
|
+
onlyIcon;
|
|
10
|
+
static get observedAttributes() {
|
|
11
|
+
return ["name", "label", "icon", "only-icon"];
|
|
12
|
+
}
|
|
13
|
+
connectedCallback() {
|
|
14
|
+
this.loadStyleText(d), console.log(this.parentElement);
|
|
15
|
+
const t = this.parentElement;
|
|
16
|
+
t.gap && i(this, "l-item--gap"), t.type === "card" && i(this, "l-item--card"), super.connectedCallback();
|
|
17
|
+
}
|
|
18
|
+
attributeChangedCallback(t, o, e) {
|
|
19
|
+
if (t === "icon" || t === "only-icon") {
|
|
20
|
+
const n = s(e, !1, "icon");
|
|
21
|
+
this[t] = n, this.#t();
|
|
22
|
+
} else
|
|
23
|
+
this[t] = e;
|
|
24
|
+
}
|
|
25
|
+
#t() {
|
|
26
|
+
if (!this.rendered) return;
|
|
27
|
+
let t = a(".icon-wrapper", this.root);
|
|
28
|
+
this.icon ? t ? this.onlyIcon ? i(t, "only") : c(t, "only") : (t = r("div", {
|
|
29
|
+
class: ["icon-wrapper", this.onlyIcon ? "only" : ""],
|
|
30
|
+
innerHTML: "<slot name='icon'></slot>"
|
|
31
|
+
}), this.root.prepend(t)) : t && t.remove();
|
|
32
|
+
let o = a("slot:not([name])", this.root);
|
|
33
|
+
if (this.onlyIcon)
|
|
34
|
+
o && o.remove();
|
|
35
|
+
else if (!o) {
|
|
36
|
+
const e = r("slot");
|
|
37
|
+
this.root.appendChild(e);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
render() {
|
|
41
|
+
const t = document.createDocumentFragment();
|
|
42
|
+
if (this.icon) {
|
|
43
|
+
const o = r("div", {
|
|
44
|
+
class: ["icon-wrapper", this.onlyIcon ? "only" : ""],
|
|
45
|
+
innerHTML: "<slot name='icon'></slot>"
|
|
46
|
+
});
|
|
47
|
+
t.appendChild(o);
|
|
48
|
+
}
|
|
49
|
+
if (!this.onlyIcon) {
|
|
50
|
+
const o = r("slot");
|
|
51
|
+
t.appendChild(o);
|
|
52
|
+
}
|
|
53
|
+
return t;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
export {
|
|
57
|
+
m as default
|
|
58
|
+
};
|
package/lib/utils/transition.js
CHANGED
|
@@ -8,7 +8,8 @@ import "ph-utils/color";
|
|
|
8
8
|
import "ph-utils/theme";
|
|
9
9
|
import "ph-utils/date";
|
|
10
10
|
import "ph-utils/web";
|
|
11
|
-
|
|
11
|
+
import "qrcode-generator-es";
|
|
12
|
+
class R extends a {
|
|
12
13
|
static baseName = "transition";
|
|
13
14
|
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
14
15
|
sheetRec;
|
|
@@ -51,5 +52,5 @@ class _ extends a {
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
export {
|
|
54
|
-
|
|
55
|
+
R as Transition
|
|
55
56
|
};
|
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "litos-ui",
|
|
3
3
|
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.15.1",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"devDependencies": {
|
|
7
|
-
"@eslint/js": "^9.
|
|
8
|
-
"@eslint/markdown": "^6.
|
|
9
|
-
"@types/node": "^
|
|
10
|
-
"eslint": "^9.
|
|
11
|
-
"globals": "^16.
|
|
7
|
+
"@eslint/js": "^9.30.1",
|
|
8
|
+
"@eslint/markdown": "^6.6.0",
|
|
9
|
+
"@types/node": "^24.0.10",
|
|
10
|
+
"eslint": "^9.30.1",
|
|
11
|
+
"globals": "^16.3.0",
|
|
12
12
|
"less": "^4.3.0",
|
|
13
|
-
"lightningcss": "^1.
|
|
14
|
-
"prettier": "^3.
|
|
13
|
+
"lightningcss": "^1.30.1",
|
|
14
|
+
"prettier": "^3.6.2",
|
|
15
15
|
"typescript": "^5.8.3",
|
|
16
|
-
"typescript-eslint": "^8.
|
|
17
|
-
"vite": "^
|
|
18
|
-
"vite-plugin-dts": "^4.5.
|
|
16
|
+
"typescript-eslint": "^8.35.1",
|
|
17
|
+
"vite": "^7.0.2",
|
|
18
|
+
"vite-plugin-dts": "^4.5.4",
|
|
19
19
|
"vitepress": "^1.6.3"
|
|
20
20
|
},
|
|
21
21
|
"files": [
|
|
@@ -52,9 +52,10 @@
|
|
|
52
52
|
},
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"iconify-icon": "^
|
|
55
|
+
"iconify-icon": "^3.0.0",
|
|
56
56
|
"ph-utils": "^0.15.4",
|
|
57
|
-
"
|
|
57
|
+
"qrcode-generator-es": "^1.1.4",
|
|
58
|
+
"shiki": "^3.7.0"
|
|
58
59
|
},
|
|
59
60
|
"scripts": {
|
|
60
61
|
"dev": "vite dev",
|