litos-ui 0.13.0 → 0.14.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/base.d.ts +1 -1
- package/lib/base.js +3 -3
- package/lib/button/index.d.ts +4 -1
- package/lib/button/index.js +28 -13
- package/lib/carousel/index.d.ts +20 -0
- package/lib/carousel/index.js +280 -0
- package/lib/carousel/item.d.ts +6 -0
- package/lib/carousel/item.js +15 -0
- package/lib/carousel/timer.d.ts +5 -0
- package/lib/carousel/timer.js +19 -0
- package/lib/check/check.d.ts +22 -0
- package/lib/check/check.js +81 -0
- package/lib/check/checkbox.d.ts +7 -0
- package/lib/check/checkbox.js +25 -0
- package/lib/check/checkbox_group.d.ts +9 -0
- package/lib/check/checkbox_group.js +33 -0
- package/lib/check/index.d.ts +12 -0
- package/lib/check/index.js +35 -0
- package/lib/check/radio.d.ts +6 -0
- package/lib/check/radio.js +19 -0
- package/lib/check/radio_group.d.ts +6 -0
- package/lib/check/radio_group.js +24 -0
- package/lib/check-BlDsQQo0.js +4 -0
- package/lib/color_picker/index.d.ts +1 -1
- package/lib/color_picker/index.js +5 -5
- package/lib/form/form_inner.d.ts +1 -8
- package/lib/form/form_inner.js +31 -39
- package/lib/form/form_item.d.ts +1 -1
- package/lib/form/form_item.js +30 -37
- package/lib/form/index.js +5 -5
- package/lib/icon/close_filled.d.ts +1 -1
- package/lib/index.d.ts +12 -4
- package/lib/index.js +80 -72
- package/lib/input/index.js +10 -10
- package/lib/list/index.d.ts +1 -2
- package/lib/list/index.js +17 -17
- package/lib/md_input/index.js +9 -9
- package/lib/menu/index.d.ts +2 -0
- package/lib/menu/index.js +47 -42
- package/lib/menu/sub_menu.d.ts +4 -2
- package/lib/menu/sub_menu.js +59 -41
- package/lib/select_ori/index.d.ts +1 -1
- package/lib/select_ori/index.js +1 -1
- package/lib/utils/index.d.ts +1 -1
- package/lib/utils/index.js +49 -49
- package/lib/utils/transition.js +3 -2
- package/package.json +1 -1
- package/lib/checkbox/index.d.ts +0 -17
- package/lib/checkbox/index.js +0 -135
- package/lib/radio/index.d.ts +0 -28
- package/lib/radio/index.js +0 -122
package/lib/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a, impactDetect as f, initAttr as s, parseAttrValue as
|
|
1
|
+
import { createTransition as t, getPopoverOffsetX as r, getPopoverOffsetY as a, impactDetect as f, initAttr as s, parseAttrValue as u, regist as l, setAttrs as m, tagAttr as p, tagAttrs as d, useId as x } from "./utils/index.js";
|
|
2
2
|
import { set as c, remove as I } from "./utils/clickoutside.js";
|
|
3
|
-
import { default as
|
|
3
|
+
import { default as C } from "./base.js";
|
|
4
4
|
import { default as h } from "./message/index.js";
|
|
5
5
|
import { default as M } from "./popover/index.js";
|
|
6
|
-
import { default as
|
|
7
|
-
import { default as
|
|
8
|
-
import { default as
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
6
|
+
import { default as R } from "./popconfirm/index.js";
|
|
7
|
+
import { default as k } from "./dialog/index.js";
|
|
8
|
+
import { default as D } from "./dialog/dialog_container.js";
|
|
9
|
+
import { default as b } from "./loading/index.js";
|
|
10
|
+
import { default as L } from "./modal/index.js";
|
|
11
11
|
import { default as B } from "./icon/base.js";
|
|
12
|
-
import { default as
|
|
13
|
-
import { default as
|
|
14
|
-
import { default as
|
|
15
|
-
import { default as
|
|
16
|
-
import { default as
|
|
17
|
-
import { default as
|
|
12
|
+
import { default as G } from "./icon/arrow_down.js";
|
|
13
|
+
import { default as U } from "./icon/arrow_left.js";
|
|
14
|
+
import { default as W } from "./icon/arrow_right.js";
|
|
15
|
+
import { default as Y } from "./icon/arrow_up.js";
|
|
16
|
+
import { default as q } from "./icon/caret_top.js";
|
|
17
|
+
import { default as E } from "./icon/caret_bottom.js";
|
|
18
18
|
import { default as J } from "./icon/font_icon.js";
|
|
19
19
|
import { default as N } from "./icon/loading.js";
|
|
20
20
|
import { default as Z } from "./icon/search.js";
|
|
@@ -22,81 +22,89 @@ import { default as $ } from "./icon/sun.js";
|
|
|
22
22
|
import { default as eo } from "./icon/moon.js";
|
|
23
23
|
import { default as ro } from "./icon/reduction.js";
|
|
24
24
|
import { default as fo } from "./icon/refresh_left.js";
|
|
25
|
-
import { default as
|
|
26
|
-
import { default as
|
|
25
|
+
import { default as uo } from "./icon/refresh_right.js";
|
|
26
|
+
import { default as mo } from "./icon/sort.js";
|
|
27
27
|
import { default as xo } from "./icon/theme_default.js";
|
|
28
28
|
import { default as co } from "./icon/close.js";
|
|
29
29
|
import { default as io } from "./icon/info.js";
|
|
30
|
-
import { default as
|
|
30
|
+
import { default as go } from "./icon/success.js";
|
|
31
31
|
import { default as Ao } from "./icon/warn.js";
|
|
32
32
|
import { default as Po } from "./icon/close_filled.js";
|
|
33
|
-
import { default as
|
|
34
|
-
import { default as
|
|
35
|
-
import { default as
|
|
36
|
-
import { default as
|
|
37
|
-
import { default as
|
|
38
|
-
import { default as Fo } from "./
|
|
39
|
-
import { default as
|
|
40
|
-
import { default as
|
|
41
|
-
import { default as
|
|
42
|
-
import { default as
|
|
43
|
-
import { default as
|
|
44
|
-
import { default as Ho } from "./
|
|
45
|
-
import { default as Ko } from "./
|
|
46
|
-
import { default as Qo } from "./
|
|
47
|
-
import { default as _o } from "./
|
|
48
|
-
import { default as oe } from "./
|
|
49
|
-
import { default as te } from "./
|
|
50
|
-
import { default as ae } from "./
|
|
51
|
-
import { default as se } from "./menu/
|
|
33
|
+
import { default as So } from "./form/index.js";
|
|
34
|
+
import { default as wo } from "./form/form_item.js";
|
|
35
|
+
import { default as To } from "./check/radio_group.js";
|
|
36
|
+
import { default as vo } from "./check/radio.js";
|
|
37
|
+
import { default as Oo } from "./check/checkbox.js";
|
|
38
|
+
import { default as Fo } from "./check/checkbox_group.js";
|
|
39
|
+
import { default as yo } from "./button/index.js";
|
|
40
|
+
import { default as Vo } from "./input/index.js";
|
|
41
|
+
import { default as Xo } from "./select_ori/index.js";
|
|
42
|
+
import { default as jo } from "./switch/index.js";
|
|
43
|
+
import { default as zo } from "./md_input/index.js";
|
|
44
|
+
import { default as Ho } from "./list/index.js";
|
|
45
|
+
import { default as Ko } from "./polygon/index.js";
|
|
46
|
+
import { default as Qo } from "./color_picker/index.js";
|
|
47
|
+
import { default as _o } from "./tabbar/index.js";
|
|
48
|
+
import { default as oe } from "./theme/index.js";
|
|
49
|
+
import { default as te } from "./theme/theme_color.js";
|
|
50
|
+
import { default as ae } from "./date_picker/index.js";
|
|
51
|
+
import { default as se } from "./menu/index.js";
|
|
52
|
+
import { default as le } from "./menu/menu_item.js";
|
|
53
|
+
import { default as pe } from "./menu/sub_menu.js";
|
|
54
|
+
import { default as xe } from "./carousel/index.js";
|
|
55
|
+
import { default as ce } from "./carousel/item.js";
|
|
52
56
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
G as ArrowDownIcon,
|
|
58
|
+
U as ArrowLeftIcon,
|
|
59
|
+
W as ArrowRightIcon,
|
|
60
|
+
Y as ArrowUpIcon,
|
|
61
|
+
C as BaseComponent,
|
|
58
62
|
B as BaseIcon,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
yo as Button,
|
|
64
|
+
E as CaretBottomIcon,
|
|
65
|
+
q as CaretTopIcon,
|
|
66
|
+
xe as Carousel,
|
|
67
|
+
ce as CarouselItem,
|
|
68
|
+
Oo as Checkbox,
|
|
69
|
+
Fo as CheckboxGroup,
|
|
63
70
|
Po as CloseFilledIcon,
|
|
64
71
|
co as CloseIcon,
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
72
|
+
Qo as ColorPicker,
|
|
73
|
+
ae as DatePicker,
|
|
74
|
+
k as Dialog,
|
|
75
|
+
D as DialogContainer,
|
|
69
76
|
J as FontIcon,
|
|
70
|
-
|
|
71
|
-
|
|
77
|
+
So as Form,
|
|
78
|
+
wo as FormItem,
|
|
72
79
|
io as InfoIcon,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
Vo as Input,
|
|
81
|
+
Ho as List,
|
|
82
|
+
b as Loading,
|
|
76
83
|
N as LoadingIcon,
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
zo as MdInput,
|
|
85
|
+
se as Menu,
|
|
86
|
+
le as MenuItem,
|
|
80
87
|
h as Message,
|
|
81
|
-
|
|
88
|
+
L as Modal,
|
|
82
89
|
eo as MoonIcon,
|
|
83
|
-
|
|
84
|
-
|
|
90
|
+
Ko as Polygon,
|
|
91
|
+
R as Popconfirm,
|
|
85
92
|
M as Popover,
|
|
86
|
-
|
|
93
|
+
vo as Radio,
|
|
94
|
+
To as RadioGroup,
|
|
87
95
|
ro as ReductionIcon,
|
|
88
96
|
fo as RefreshLeftIcon,
|
|
89
|
-
|
|
97
|
+
uo as RefreshRightIcon,
|
|
90
98
|
Z as SearchIcon,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
99
|
+
Xo as SelectOri,
|
|
100
|
+
mo as SortIcon,
|
|
101
|
+
pe as SubMenu,
|
|
102
|
+
go as SuccessIcon,
|
|
95
103
|
$ as SunIcon,
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
jo as Switch,
|
|
105
|
+
_o as Tabbar,
|
|
106
|
+
oe as Theme,
|
|
107
|
+
te as ThemeColor,
|
|
100
108
|
xo as ThemeDefaultIcon,
|
|
101
109
|
Ao as WarnIcon,
|
|
102
110
|
c as addClickOutside,
|
|
@@ -105,10 +113,10 @@ export {
|
|
|
105
113
|
a as getPopoverOffsetY,
|
|
106
114
|
f as impactDetect,
|
|
107
115
|
s as initAttr,
|
|
108
|
-
|
|
109
|
-
|
|
116
|
+
u as parseAttrValue,
|
|
117
|
+
l as regist,
|
|
110
118
|
I as removeClickOutside,
|
|
111
|
-
|
|
119
|
+
m as setAttrs,
|
|
112
120
|
p as tagAttr,
|
|
113
121
|
d as tagAttrs,
|
|
114
122
|
x as useId
|
package/lib/input/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { $one as h, on as a, formatStyle as
|
|
1
|
+
import { $one as h, on as a, formatStyle as p, addClass as o, off as u, $ as d, $$ as n, removeClass as f } from "ph-utils/dom";
|
|
2
2
|
import { initAttr as c, parseAttrValue as m } from "../utils/index.js";
|
|
3
|
-
import
|
|
4
|
-
import { add as
|
|
3
|
+
import b from "../form/form_inner.js";
|
|
4
|
+
import { add as g, remove as v } from "../utils/event.js";
|
|
5
5
|
import { i as C } from "../index-dwS1N2uN.js";
|
|
6
|
-
class y extends
|
|
6
|
+
class y extends b {
|
|
7
7
|
static baseName = "input";
|
|
8
8
|
/** 原生 input 的 type */
|
|
9
9
|
type = "text";
|
|
@@ -31,10 +31,10 @@ class y extends g {
|
|
|
31
31
|
return ["disabled", "error"];
|
|
32
32
|
}
|
|
33
33
|
connectedCallback() {
|
|
34
|
-
c(this), this.loadStyleText([C]), super.connectedCallback(), this.$inner = h(".l-input__inner", this.root), a(this.$inner, "input", this._input), a(this.$inner, "change", this.#i), this.style.cssText =
|
|
34
|
+
c(this), this.loadStyleText([C]), super.connectedCallback(), this.$inner = h(".l-input__inner", this.root), a(this.$inner, "input", this._input), a(this.$inner, "change", this.#i), this.style.cssText = p(this._getStyleObj()) + this.getAttr("style", ""), this.error && o(this, "is-error"), this.getName() && this.formAttrs.id && g(this.formAttrs.id, "validateChange", this._validateChange);
|
|
35
35
|
}
|
|
36
36
|
disconnectedCallback() {
|
|
37
|
-
super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange),
|
|
37
|
+
super.disconnectedCallback(), this.formAttrs.id && v(this.formAttrs.id, "validateChange", this._validateChange), u(this.$inner, "input", this._input);
|
|
38
38
|
}
|
|
39
39
|
attributeChange(t, i, e) {
|
|
40
40
|
if (t === "error") {
|
|
@@ -44,7 +44,7 @@ class y extends g {
|
|
|
44
44
|
}
|
|
45
45
|
render() {
|
|
46
46
|
const t = document.createDocumentFragment();
|
|
47
|
-
if (
|
|
47
|
+
if (d('[slot="prefix"]', this).length > 0) {
|
|
48
48
|
const r = n("slot", {
|
|
49
49
|
name: "prefix"
|
|
50
50
|
}), l = n("span", {
|
|
@@ -62,7 +62,7 @@ class y extends g {
|
|
|
62
62
|
part: "default",
|
|
63
63
|
type: this.type
|
|
64
64
|
});
|
|
65
|
-
if (t.appendChild(e),
|
|
65
|
+
if (t.appendChild(e), d('[slot="suffix"]', this).length > 0) {
|
|
66
66
|
const r = n("slot", {
|
|
67
67
|
name: "suffix"
|
|
68
68
|
}), l = n("span", {
|
|
@@ -105,7 +105,7 @@ class y extends g {
|
|
|
105
105
|
t.appendChild(i), this.root.appendChild(t), a(t, "click", this.#e);
|
|
106
106
|
}
|
|
107
107
|
} else
|
|
108
|
-
t && (
|
|
108
|
+
t && (u(t, "click", this.#e), t.remove());
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
#e = () => {
|
|
@@ -137,7 +137,7 @@ class y extends g {
|
|
|
137
137
|
return this.block === !0 || this.formItemAttrs.innerBlock === !0 || this.formAttrs.innerBlock === !0;
|
|
138
138
|
}
|
|
139
139
|
_updateError() {
|
|
140
|
-
f(this, "is-error");
|
|
140
|
+
this.error ? o(this, "is-error") : f(this, "is-error");
|
|
141
141
|
}
|
|
142
142
|
_validateChange = (t, i) => {
|
|
143
143
|
const e = this.getName();
|
package/lib/list/index.d.ts
CHANGED
|
@@ -6,9 +6,8 @@ export default class List extends BaseComponent {
|
|
|
6
6
|
/** 是否显示无限加载模式 */
|
|
7
7
|
infinite: boolean;
|
|
8
8
|
private observer?;
|
|
9
|
-
private loadMoreEmit;
|
|
10
9
|
private $more?;
|
|
11
|
-
|
|
10
|
+
private _page;
|
|
12
11
|
static get observedAttributes(): string[] | null | undefined;
|
|
13
12
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
14
13
|
connectedCallback(): void;
|
package/lib/list/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import r from "../base.js";
|
|
2
|
-
import {
|
|
3
|
-
import { $one as
|
|
4
|
-
import { a } from "../animation-DttknHkX.js";
|
|
5
|
-
const
|
|
2
|
+
import { parseAttrValue as n } from "../utils/index.js";
|
|
3
|
+
import { $one as s } from "ph-utils/dom";
|
|
4
|
+
import { a as l } from "../animation-DttknHkX.js";
|
|
5
|
+
const a = ":host{display:block;overflow:auto;-webkit-overflow-scrolling:touch;height:100%;position:relative}.l-list-loadmore{padding:10px;display:flex;align-items:center;justify-content:center;color:#999}.l-list-icon{font-size:24px;margin-right:10px;transform:rotate3d(0,0,1,80deg)}";
|
|
6
6
|
class b extends r {
|
|
7
7
|
static baseName = "list";
|
|
8
8
|
/** 是否已经全部加载完成 */
|
|
@@ -10,27 +10,27 @@ class b extends r {
|
|
|
10
10
|
/** 是否显示无限加载模式 */
|
|
11
11
|
infinite = !0;
|
|
12
12
|
observer;
|
|
13
|
-
loadMoreEmit;
|
|
14
13
|
$more;
|
|
15
|
-
|
|
16
|
-
super(), n(this), this.loadMoreEmit = new CustomEvent("load-more");
|
|
17
|
-
}
|
|
14
|
+
_page = 0;
|
|
18
15
|
static get observedAttributes() {
|
|
19
|
-
return ["finish"];
|
|
16
|
+
return ["finish", "infinite"];
|
|
20
17
|
}
|
|
21
18
|
attributeChangedCallback(i, t, o) {
|
|
22
19
|
if (i === "finish") {
|
|
23
|
-
const
|
|
24
|
-
this.finish !==
|
|
20
|
+
const e = n(o, !1, i);
|
|
21
|
+
this.finish !== e && (this.finish = e, this._finishChange());
|
|
22
|
+
} else if (i === "infinite") {
|
|
23
|
+
const e = n(o, !0, i);
|
|
24
|
+
this.infinite !== e && (this.infinite = e);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
connectedCallback() {
|
|
28
|
-
this.loadStyleText([
|
|
29
|
-
i[0].isIntersecting && !this.finish && this.
|
|
30
|
-
}), this.$more =
|
|
28
|
+
this.loadStyleText([a, l]), super.connectedCallback(), this.infinite && (this.observer = new IntersectionObserver((i) => {
|
|
29
|
+
i[0].isIntersecting && !this.finish && (this._page++, this.setAttribute("loading", ""), this.emit("load", { detail: { page: this._page } }));
|
|
30
|
+
}), this.$more = s(".l-list-loadmore", this.root), !this.finish && this.$more && this.observer.observe(this.$more));
|
|
31
31
|
}
|
|
32
32
|
disconnectedCallback() {
|
|
33
|
-
super.disconnectedCallback(), this.observer && (this.$more && (this.observer.unobserve(this.$more), this.$more = void 0), this.observer.disconnect(), this.observer = void 0)
|
|
33
|
+
super.disconnectedCallback(), this.observer && (this.$more && (this.observer.unobserve(this.$more), this.$more = void 0), this.observer.disconnect(), this.observer = void 0);
|
|
34
34
|
}
|
|
35
35
|
render() {
|
|
36
36
|
const i = ["<slot></slot>"];
|
|
@@ -46,9 +46,9 @@ class b extends r {
|
|
|
46
46
|
_finishChange() {
|
|
47
47
|
if (this.$more) {
|
|
48
48
|
this.observer && (this.finish ? this.observer.unobserve(this.$more) : this.observer.observe(this.$more));
|
|
49
|
-
const i =
|
|
49
|
+
const i = s(".l-list-loadmore-text", this.$more);
|
|
50
50
|
i && (i.textContent = this._loadingText());
|
|
51
|
-
let t =
|
|
51
|
+
let t = s(".l-list-icon", this.$more);
|
|
52
52
|
this.finish ? t && t.remove() : t == null && (t = document.createElement("l-loading-icon"), t.className = "l-list-icon l-rotate-anim", this.$more.prepend(t));
|
|
53
53
|
}
|
|
54
54
|
}
|
package/lib/md_input/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { addClass as
|
|
1
|
+
import { addClass as n, $$ as r, $one as l, on as a, off as d, removeClass as u } from "ph-utils/dom";
|
|
2
2
|
import p from "../form/form_inner.js";
|
|
3
3
|
import { initAttr as m } from "../utils/index.js";
|
|
4
4
|
import { isBlank as s, random as h } from "ph-utils";
|
|
@@ -17,18 +17,18 @@ class v extends p {
|
|
|
17
17
|
m(this), this.loadStyleText(c), super.connectedCallback(), this.#e();
|
|
18
18
|
}
|
|
19
19
|
disconnectedCallback() {
|
|
20
|
-
super.disconnectedCallback(), this.#
|
|
20
|
+
super.disconnectedCallback(), this.#i();
|
|
21
21
|
}
|
|
22
22
|
render() {
|
|
23
|
-
s(this.value) ||
|
|
24
|
-
const t = document.createDocumentFragment(), e = `l-md-input-${h(8)}`,
|
|
23
|
+
s(this.value) || n(this, "l-has-value"), this.outline && n(this, "l-md-input-outline");
|
|
24
|
+
const t = document.createDocumentFragment(), e = `l-md-input-${h(8)}`, i = r("input", {
|
|
25
25
|
class: "l-md-input__inner",
|
|
26
26
|
type: this.htmlType,
|
|
27
|
-
name: this.
|
|
27
|
+
name: this.getName(),
|
|
28
28
|
inputmode: this.inputmode,
|
|
29
29
|
id: e
|
|
30
30
|
});
|
|
31
|
-
if (t.appendChild(
|
|
31
|
+
if (t.appendChild(i), this.label) {
|
|
32
32
|
const o = r("label", {
|
|
33
33
|
class: "l-md-input__label",
|
|
34
34
|
for: e
|
|
@@ -46,13 +46,13 @@ class v extends p {
|
|
|
46
46
|
const t = l("input", this.root);
|
|
47
47
|
t && a(t, "input", this.#t);
|
|
48
48
|
}
|
|
49
|
-
#
|
|
49
|
+
#i() {
|
|
50
50
|
const t = l("input", this.root);
|
|
51
51
|
t && d(t, "input", this.#t);
|
|
52
52
|
}
|
|
53
53
|
#t = (t) => {
|
|
54
|
-
const
|
|
55
|
-
this.setValue(
|
|
54
|
+
const i = t.target.value;
|
|
55
|
+
this.setValue(i), s(i) ? u(this, "l-has-value") : n(this, "l-has-value");
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
export {
|
package/lib/menu/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export default class Menu extends BaseComponent {
|
|
|
8
8
|
orientation: "horizontal" | "vertical";
|
|
9
9
|
/** 主题 */
|
|
10
10
|
theme: "light" | "dark";
|
|
11
|
+
/** 是否手风琴模式, 只有一个子菜单展开 */
|
|
12
|
+
accordion: boolean;
|
|
11
13
|
connectedCallback(): void;
|
|
12
14
|
static get observedAttributes(): string[];
|
|
13
15
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
package/lib/menu/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { on as
|
|
2
|
-
import
|
|
3
|
-
import { initAttr as
|
|
4
|
-
const
|
|
5
|
-
class
|
|
1
|
+
import { on as d, off as c, $$ as u, $ as h, iterate as f, $one as a } from "ph-utils/dom";
|
|
2
|
+
import m from "../base.js";
|
|
3
|
+
import { initAttr as b } from "../utils/index.js";
|
|
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)}";
|
|
5
|
+
class x extends m {
|
|
6
6
|
static baseName = "menu";
|
|
7
7
|
/** 当前选中的菜单项 key 数组, 用 , 分割 */
|
|
8
8
|
selectedKey = "";
|
|
@@ -10,54 +10,54 @@ class v extends f {
|
|
|
10
10
|
orientation = "vertical";
|
|
11
11
|
/** 主题 */
|
|
12
12
|
theme = "light";
|
|
13
|
-
/**
|
|
14
|
-
|
|
13
|
+
/** 是否手风琴模式, 只有一个子菜单展开 */
|
|
14
|
+
accordion = !1;
|
|
15
15
|
connectedCallback() {
|
|
16
|
-
|
|
16
|
+
b(this), this.classList.add(
|
|
17
17
|
"l-menu",
|
|
18
18
|
`l-menu--${this.orientation}`,
|
|
19
19
|
`l-menu-${this.theme}`
|
|
20
|
-
), this.loadStyleText(
|
|
20
|
+
), this.loadStyleText(p), super.connectedCallback();
|
|
21
21
|
}
|
|
22
22
|
static get observedAttributes() {
|
|
23
23
|
return ["selectedKeys", "orientation"];
|
|
24
24
|
}
|
|
25
|
-
attributeChangedCallback(
|
|
25
|
+
attributeChangedCallback(t, i, e) {
|
|
26
26
|
if (this.rendered) {
|
|
27
|
-
if (
|
|
28
|
-
this.selectedKey =
|
|
29
|
-
else if (
|
|
27
|
+
if (t === "selectedKeys")
|
|
28
|
+
this.selectedKey !== e && (this.selectedKey = e, this.updateSelectedKeys(e));
|
|
29
|
+
else if (t === "orientation") {
|
|
30
30
|
const s = this.classList;
|
|
31
|
-
s.remove(`l-menu--${
|
|
31
|
+
s.remove(`l-menu--${i}`), s.add(`l-menu--${e}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
afterInit() {
|
|
36
|
-
|
|
36
|
+
d(this, "click", this.#t), this.updateSelectedKeys(this.selectedKey);
|
|
37
37
|
}
|
|
38
38
|
beforeDestroy() {
|
|
39
|
-
|
|
39
|
+
c(this, "click", this.#t);
|
|
40
40
|
}
|
|
41
41
|
render() {
|
|
42
|
-
return
|
|
42
|
+
return u("slot");
|
|
43
43
|
}
|
|
44
|
-
#t = (
|
|
45
|
-
const { type:
|
|
46
|
-
|
|
44
|
+
#t = (t) => {
|
|
45
|
+
const { type: i, key: e, keyPaths: s, target: l } = this.#e(
|
|
46
|
+
t.target
|
|
47
47
|
);
|
|
48
|
-
l &&
|
|
48
|
+
l && (i === 2 ? l.hasAttribute("expanded") ? l.removeAttribute("expanded") : (l.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(s, !0)) : i === 1 && (this.#i(s), this.updateSelectedKeys(e), this.emit("select", { detail: { key: e, keyPaths: s } })));
|
|
49
49
|
};
|
|
50
|
-
#i
|
|
51
|
-
let
|
|
52
|
-
const
|
|
50
|
+
#e(t, i) {
|
|
51
|
+
let e = 0, s = "", l;
|
|
52
|
+
const o = [];
|
|
53
53
|
do {
|
|
54
|
-
const
|
|
55
|
-
if (["L-MENU", "BODY"].includes(
|
|
54
|
+
const r = t.tagName;
|
|
55
|
+
if (["L-MENU", "BODY"].includes(r))
|
|
56
56
|
break;
|
|
57
|
-
const n =
|
|
58
|
-
n && (
|
|
59
|
-
} while (
|
|
60
|
-
return { type:
|
|
57
|
+
const n = t.getAttribute("key");
|
|
58
|
+
n && (s || (s = n), o.unshift(n), i && i(t, n)), e === 0 && (r === "L-MENU-ITEM" ? (e = 1, l = t) : r === "L-SUB-MENU" && (l = t, e = 2)), t = t.parentElement;
|
|
59
|
+
} while (e >= 0);
|
|
60
|
+
return { type: e, key: s, keyPaths: o, target: l };
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
63
|
* 展开与提供的 keys 对应的子菜单。
|
|
@@ -69,22 +69,27 @@ class v extends f {
|
|
|
69
69
|
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
70
70
|
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
71
71
|
*/
|
|
72
|
-
expandSubmenus(
|
|
73
|
-
const
|
|
74
|
-
|
|
72
|
+
expandSubmenus(t, i = !1) {
|
|
73
|
+
const e = h("l-sub-menu[key]", this);
|
|
74
|
+
f(e, (s) => {
|
|
75
75
|
const l = s.getAttribute("key") || "";
|
|
76
|
-
|
|
76
|
+
t.includes(l) ? s.setAttribute("expanded", "") : i && s.removeAttribute("expanded");
|
|
77
77
|
});
|
|
78
78
|
}
|
|
79
|
-
updateSelectedKeys(
|
|
80
|
-
this.selectedKey =
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
79
|
+
updateSelectedKeys(t) {
|
|
80
|
+
this.selectedKey = t;
|
|
81
|
+
const i = a(`l-menu-item[key="${t}"]`, this);
|
|
82
|
+
i && (i.setAttribute("active", ""), this.#e(i, (e) => {
|
|
83
|
+
e.setAttribute("active", ""), e.setAttribute("expanded", "");
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
#i(t) {
|
|
87
|
+
const i = a("l-menu-item[active]", this);
|
|
88
|
+
i && this.#e(i, (e, s) => {
|
|
89
|
+
t.includes(s) || e.removeAttribute("active");
|
|
90
|
+
});
|
|
86
91
|
}
|
|
87
92
|
}
|
|
88
93
|
export {
|
|
89
|
-
|
|
94
|
+
x as default
|
|
90
95
|
};
|
package/lib/menu/sub_menu.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
export default class
|
|
2
|
+
export default class SubMenu extends BaseComponent {
|
|
3
3
|
#private;
|
|
4
4
|
static baseName: string;
|
|
5
5
|
/** 默认折叠子菜单 */
|
|
6
|
-
|
|
6
|
+
expanded: boolean;
|
|
7
|
+
/** 是否激活状态, 通常是下面的子菜单项被选中 */
|
|
8
|
+
active: boolean;
|
|
7
9
|
connectedCallback(): void;
|
|
8
10
|
afterInit(): void;
|
|
9
11
|
beforeDestroy(): void;
|