litos-ui 0.17.5 → 0.18.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/animation-CTt9qgA7.js +4 -0
- package/lib/base-Dm0WS1pK.js +62 -0
- package/lib/base.js +111 -147
- package/lib/button/index.d.ts +8 -3
- package/lib/button/index.js +2 -137
- package/lib/button-CC5PmAb1.js +146 -0
- package/lib/calendar/index.d.ts +10 -5
- package/lib/calendar/index.js +2 -123
- package/lib/calendar-GpYHNmXG.js +149 -0
- package/lib/carousel/index.js +2 -280
- package/lib/carousel/item.js +2 -15
- package/lib/carousel-dT3FJPQo.js +272 -0
- package/lib/check/checkbox.js +2 -18
- package/lib/check/checkbox_group.js +6 -6
- package/lib/check/radio.js +2 -15
- package/lib/check/radio_group.js +9 -9
- package/lib/check-B0XraJvb.js +73 -0
- package/lib/check-CvGaONEx.js +117 -0
- package/lib/checkbox-DbWsmAaL.js +16 -0
- package/lib/collapse/index.d.ts +18 -11
- package/lib/collapse/index.js +2 -88
- package/lib/collapse/item.d.ts +28 -9
- package/lib/collapse/item.js +2 -115
- package/lib/collapse/types.d.ts +7 -0
- package/lib/collapse-C3IRHLeg.js +104 -0
- package/lib/color_picker/index.js +2 -42
- package/lib/color_picker-D0brKFm-.js +41 -0
- package/lib/date_picker/index.d.ts +23 -0
- package/lib/date_picker/index.js +3 -0
- package/lib/date_picker-DQGoiN8v.js +103 -0
- package/lib/date_picker_ori/index.js +2 -129
- package/lib/date_picker_ori-aRuSSi9D.js +122 -0
- package/lib/description_panel/index.js +2 -66
- package/lib/description_panel-BY2yljeC.js +57 -0
- package/lib/dialog/dialog_container.js +2 -131
- package/lib/dialog/index.js +67 -85
- package/lib/dialog_container-DcN87wj0.js +126 -0
- package/lib/esm-sVEoAVPu.js +244 -0
- package/lib/form/form_item.d.ts +1 -0
- package/lib/form/form_item.js +2 -136
- package/lib/form/index.js +2 -147
- package/lib/form-DdU0yK0k.js +154 -0
- package/lib/form_inner-DR9tyB_r.js +117 -0
- package/lib/form_item-Bv-YafZK.js +137 -0
- package/lib/icon/arrow_down.js +12 -12
- package/lib/icon/arrow_left.js +9 -9
- package/lib/icon/arrow_right.js +9 -9
- package/lib/icon/arrow_up.js +12 -12
- package/lib/icon/base.d.ts +16 -2
- package/lib/icon/base.js +2 -38
- package/lib/icon/calendar.d.ts +5 -0
- package/lib/icon/calendar.js +10 -0
- package/lib/icon/caret_bottom.js +9 -9
- package/lib/icon/caret_top.js +9 -9
- package/lib/icon/close.js +9 -9
- package/lib/icon/close_filled.js +12 -12
- package/lib/icon/d_arrow_left.js +12 -12
- package/lib/icon/d_arrow_right.js +12 -12
- package/lib/icon/font_icon.d.ts +2 -3
- package/lib/icon/font_icon.js +35 -39
- package/lib/icon/info.js +12 -12
- package/lib/icon/loading.js +9 -9
- package/lib/icon/moon.js +12 -12
- package/lib/icon/more.js +12 -12
- package/lib/icon/reduction.js +12 -12
- package/lib/icon/refresh.d.ts +5 -0
- package/lib/icon/refresh.js +10 -0
- package/lib/icon/refresh_left.js +12 -12
- package/lib/icon/refresh_right.js +9 -9
- package/lib/icon/search.js +9 -9
- package/lib/icon/select.js +12 -12
- package/lib/icon/sort.js +9 -9
- package/lib/icon/success.js +12 -12
- package/lib/icon/sun.js +12 -12
- package/lib/icon/theme_default.js +12 -12
- package/lib/icon/warn.js +12 -12
- package/lib/icon/zoom_in.js +12 -12
- package/lib/icon/zoom_out.js +12 -12
- package/lib/image/image_preview.js +2 -104
- package/lib/image/index.js +2 -176
- package/lib/image-COPKk8Jm.js +162 -0
- package/lib/image_preview-CYEup07F.js +92 -0
- package/lib/index.d.ts +5 -81
- package/lib/index.js +78 -169
- package/lib/input/index.d.ts +6 -2
- package/lib/input/index.js +188 -203
- package/lib/input-DjKxcxry.js +4 -0
- package/lib/input_inner-BKJg9n9A.js +4 -0
- package/lib/item-B7Elh5xE.js +14 -0
- package/lib/item-CvoJt3wp.js +60 -0
- package/lib/item-DRsOV_Tc.js +119 -0
- package/lib/list/index.js +2 -58
- package/lib/list-CU7vHS6s.js +51 -0
- package/lib/loading/index.d.ts +3 -2
- package/lib/loading/index.js +109 -127
- package/lib/mask/index.js +2 -105
- package/lib/mask-CEznzwji.js +112 -0
- package/lib/md_input/index.js +2 -60
- package/lib/md_input-DSQx5TMW.js +58 -0
- package/lib/menu/index.d.ts +30 -13
- package/lib/menu/index.js +2 -105
- package/lib/menu/types.d.ts +6 -0
- package/lib/menu/types.js +0 -0
- package/lib/menu-CzV6lOlw.js +224 -0
- package/lib/message/index.js +67 -60
- package/lib/modal/index.js +2 -196
- package/lib/modal/modal_box.js +87 -86
- package/lib/modal-DWyWrN-D.js +192 -0
- package/lib/page_header/index.js +2 -109
- package/lib/page_header-BJkEstRw.js +101 -0
- package/lib/pagination/index.js +2 -248
- package/lib/pagination-5t7AOeFV.js +210 -0
- package/lib/polygon/index.js +2 -27
- package/lib/polygon-C4Ow2lxi.js +20 -0
- package/lib/qrcode/index.d.ts +13 -4
- package/lib/qrcode/index.js +2 -57
- package/lib/qrcode-BKG2MibP.js +64 -0
- package/lib/radio-2mNSYujz.js +13 -0
- package/lib/select/index.js +3 -401
- package/lib/select-CAgggYh7.js +326 -0
- package/lib/select_ori/index.js +47 -50
- package/lib/space/index.js +2 -35
- package/lib/space-Bv-p0DL8.js +38 -0
- package/lib/switch/index.js +2 -50
- package/lib/switch-BaVBi5Ip.js +48 -0
- package/lib/tabbar/index.js +2 -109
- package/lib/tabbar/item.js +2 -58
- package/lib/tabbar-CI1xSj1G.js +96 -0
- package/lib/table/index.js +2 -269
- package/lib/table-DfL2hFqA.js +234 -0
- package/lib/tabs/index.js +38 -42
- package/lib/tag/index.js +2 -72
- package/lib/tag-72DwCkvq.js +76 -0
- package/lib/theme/index.js +2 -89
- package/lib/theme/theme_color.js +22 -26
- package/lib/theme-BRTI2-Yk.js +83 -0
- package/lib/utils/clickoutside.js +18 -18
- package/lib/utils/context_provide.js +21 -21
- package/lib/utils/event.js +13 -18
- package/lib/utils/index.js +55 -58
- package/lib/utils/popover.d.ts +4 -1
- package/lib/utils/popover.js +276 -352
- package/lib/utils/transition.js +33 -31
- package/package.json +14 -14
- package/styles/container.css +4 -0
- package/styles/datepicker.css +55 -0
- package/styles/popover.css +14 -1
- package/lib/animation-DttknHkX.js +0 -4
- package/lib/calendar/langs.js +0 -8
- package/lib/carousel/timer.js +0 -19
- package/lib/check/check.js +0 -118
- package/lib/check/index.js +0 -68
- package/lib/check-CksURvTv.js +0 -4
- package/lib/form/form_inner.js +0 -125
- package/lib/form/types.js +0 -1
- package/lib/index-CrMiSe0x.js +0 -249
- package/lib/index-DY6m9Wbe.js +0 -4
- package/lib/litos-ui.css +0 -1
- package/lib/menu/menu_item.d.ts +0 -6
- package/lib/menu/menu_item.js +0 -21
- package/lib/menu/sub_menu.d.ts +0 -15
- package/lib/menu/sub_menu.js +0 -83
- package/lib/table/types.js +0 -1
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { initAttr as e } from "./utils/index.js";
|
|
2
|
+
import { t } from "./form_inner-DR9tyB_r.js";
|
|
3
|
+
import { $$ as n, $one as r, addClass as i, off as a, on as o, removeClass as s } from "ph-utils/dom";
|
|
4
|
+
import { isBlank as c, random as l } from "ph-utils";
|
|
5
|
+
//#region src/components/md_input/index.less?inline
|
|
6
|
+
var u = ":host{--l-input-width:180px;width:var(--l-input-width,180px);height:var(--l-form-control-height,32px);display:inline-block;position:relative}.l-md-input__inner{box-sizing:border-box;background:0 0;border:0 solid silver;border-bottom-width:1px;outline:none;width:100%;height:100%;transition:border-color .3s}.l-md-input__inner:focus{border-color:var(--l-primary-color,#722ed1)}:host(.l-has-value) .l-md-input__label,.l-md-input__inner:focus+.l-md-input__label{font-size:12px;transform:translateY(-150%)}.l-md-input__inner:focus+.l-md-input__label{color:var(--nt-primary-color,#722ed1)}.l-md-input__label{color:#8c8c8c;cursor:text;align-items:center;font-size:13px;line-height:1;transition:color .3s,transform .3s;display:flex;position:absolute;top:50%;bottom:0;left:0;transform:translateY(-50%)}:host(.l-md-input-outline){--l-input-label-background:#fff}:host(.l-md-input-outline) .l-md-input__inner{border-width:1px;border-radius:4px;padding:0 10px}:host(.l-md-input-outline) .l-md-input__label{left:10px}:host(.l-md-input-outline) .l-md-input__inner:focus{border-width:2px}:host(.l-md-input-outline) .l-md-input__inner:focus+.l-md-input__label,:host(.l-md-input-outline.l-has-value) .l-md-input__label{background-color:#fff;padding-left:4px;padding-right:4px}", d = class extends t {
|
|
7
|
+
static baseName = "md-input";
|
|
8
|
+
outline = !1;
|
|
9
|
+
htmlType = "text";
|
|
10
|
+
inputmode;
|
|
11
|
+
label;
|
|
12
|
+
static get observedAttributes() {
|
|
13
|
+
return ["disabled"];
|
|
14
|
+
}
|
|
15
|
+
connectedCallback() {
|
|
16
|
+
e(this), this.loadStyleText(u), super.connectedCallback(), this.#e();
|
|
17
|
+
}
|
|
18
|
+
disconnectedCallback() {
|
|
19
|
+
super.disconnectedCallback(), this.#t();
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
c(this.value) || i(this, "l-has-value"), this.outline && i(this, "l-md-input-outline");
|
|
23
|
+
let e = document.createDocumentFragment(), t = `l-md-input-${l(8)}`, r = n("input", {
|
|
24
|
+
class: "l-md-input__inner",
|
|
25
|
+
type: this.htmlType,
|
|
26
|
+
name: this.getName(),
|
|
27
|
+
inputmode: this.inputmode,
|
|
28
|
+
id: t
|
|
29
|
+
});
|
|
30
|
+
if (e.appendChild(r), this.label) {
|
|
31
|
+
let r = n("label", {
|
|
32
|
+
class: "l-md-input__label",
|
|
33
|
+
for: t
|
|
34
|
+
});
|
|
35
|
+
r.textContent = this.label, e.appendChild(r);
|
|
36
|
+
}
|
|
37
|
+
return e;
|
|
38
|
+
}
|
|
39
|
+
setValue(e) {
|
|
40
|
+
super.setValue(e);
|
|
41
|
+
let t = r("input", this.root);
|
|
42
|
+
t && (t.value = e);
|
|
43
|
+
}
|
|
44
|
+
#e() {
|
|
45
|
+
let e = r("input", this.root);
|
|
46
|
+
e && o(e, "input", this.#n);
|
|
47
|
+
}
|
|
48
|
+
#t() {
|
|
49
|
+
let e = r("input", this.root);
|
|
50
|
+
e && a(e, "input", this.#n);
|
|
51
|
+
}
|
|
52
|
+
#n = (e) => {
|
|
53
|
+
let t = e.target.value;
|
|
54
|
+
this.setValue(t), c(t) ? s(this, "l-has-value") : i(this, "l-has-value");
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { d as t };
|
package/lib/menu/index.d.ts
CHANGED
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import type { MenuItem } from "./types";
|
|
3
|
+
type MenuState = {
|
|
4
|
+
/** 是否手风琴模式, 只有一个子菜单展开 */
|
|
5
|
+
accordion?: boolean;
|
|
5
6
|
/** 当前选中的菜单项 key 数组, 用 , 分割 */
|
|
6
7
|
selectedIndex: string;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
};
|
|
9
|
+
export default class Menu extends BaseComponent<MenuState> {
|
|
10
|
+
#private;
|
|
11
|
+
static baseName: string;
|
|
11
12
|
/** 是否手风琴模式, 只有一个子菜单展开 */
|
|
12
13
|
accordion: boolean;
|
|
13
|
-
|
|
14
|
+
private _items;
|
|
15
|
+
private _menuEl?;
|
|
16
|
+
private _activeKeys;
|
|
17
|
+
constructor();
|
|
14
18
|
static get observedAttributes(): string[];
|
|
15
|
-
|
|
19
|
+
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
16
20
|
afterInit(): void;
|
|
17
21
|
beforeDestroy(): void;
|
|
18
|
-
|
|
22
|
+
render_v2(): {
|
|
23
|
+
template?: string | HTMLElement | DocumentFragment;
|
|
24
|
+
style?: string | string[];
|
|
25
|
+
};
|
|
26
|
+
_handleClick: (e: Event) => void;
|
|
19
27
|
/**
|
|
20
28
|
* 展开与提供的 keys 对应的子菜单。
|
|
21
29
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* 则通过将其 `collapse` 属性设置为 "off" 来展开子菜单,并将该 key 添加到 `#selectedKeys` 集合中。
|
|
30
|
+
* 遍历当前组件内所有子菜单,如果子菜单的 key 在提供的 keys 中,
|
|
31
|
+
* 则展开该子菜单;如果 collapseOther 为 true,则折叠不在 keys 中的子菜单。
|
|
25
32
|
*
|
|
26
33
|
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
27
34
|
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
28
35
|
*/
|
|
29
36
|
expandSubmenus(keys: string[], collapseOther?: boolean): void;
|
|
30
37
|
updateSelectedKeys(key: string): void;
|
|
38
|
+
private _toggleSubMenu;
|
|
39
|
+
private _onTransitionEnd;
|
|
40
|
+
set items(menuItems: MenuItem[]);
|
|
41
|
+
get items(): MenuItem[];
|
|
42
|
+
private _renderItems;
|
|
43
|
+
private _renderItem;
|
|
44
|
+
private _renderMenuItem;
|
|
45
|
+
private _renderSubMenu;
|
|
46
|
+
private _renderTitle;
|
|
31
47
|
}
|
|
48
|
+
export {};
|
package/lib/menu/index.js
CHANGED
|
@@ -1,105 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { initAttr as b, parseAttrValue as p } from "../utils/index.js";
|
|
4
|
-
const x = ":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 A extends m {
|
|
6
|
-
static baseName = "menu";
|
|
7
|
-
/** 当前选中的菜单项 key 数组, 用 , 分割 */
|
|
8
|
-
selectedIndex = "";
|
|
9
|
-
/** 水平/垂直菜单 */
|
|
10
|
-
orientation = "vertical";
|
|
11
|
-
/** 主题 */
|
|
12
|
-
theme = "light";
|
|
13
|
-
/** 是否手风琴模式, 只有一个子菜单展开 */
|
|
14
|
-
accordion = !1;
|
|
15
|
-
connectedCallback() {
|
|
16
|
-
b(this), this.classList.add(
|
|
17
|
-
"l-menu",
|
|
18
|
-
`l-menu--${this.orientation}`,
|
|
19
|
-
`l-menu-${this.theme}`
|
|
20
|
-
), this.loadStyleText(x), super.connectedCallback();
|
|
21
|
-
}
|
|
22
|
-
static get observedAttributes() {
|
|
23
|
-
return ["selected-index", "orientation", "accordion"];
|
|
24
|
-
}
|
|
25
|
-
attributeChangedCallback(t, s, i) {
|
|
26
|
-
if (t === "accordion") {
|
|
27
|
-
const e = p(i, !1, "accordion");
|
|
28
|
-
e !== this.accordion && (this.accordion = e);
|
|
29
|
-
}
|
|
30
|
-
if (this.rendered) {
|
|
31
|
-
if (t === "selected-index")
|
|
32
|
-
this.selectedIndex !== i && this.updateSelectedKeys(i);
|
|
33
|
-
else if (t === "orientation") {
|
|
34
|
-
const e = this.classList;
|
|
35
|
-
e.remove(`l-menu--${s}`), e.add(`l-menu--${i}`);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
afterInit() {
|
|
40
|
-
c(this, "click", this.#t), this.updateSelectedKeys(this.selectedIndex);
|
|
41
|
-
}
|
|
42
|
-
beforeDestroy() {
|
|
43
|
-
u(this, "click", this.#t);
|
|
44
|
-
}
|
|
45
|
-
render() {
|
|
46
|
-
return h("slot");
|
|
47
|
-
}
|
|
48
|
-
#t = (t) => {
|
|
49
|
-
const { type: s, key: i, keyPaths: e, target: n } = this.#e(
|
|
50
|
-
t.target
|
|
51
|
-
);
|
|
52
|
-
n && (s === 2 ? n.hasAttribute("expanded") ? n.removeAttribute("expanded") : (n.setAttribute("expanded", ""), this.accordion && this.expandSubmenus(e, !0)) : s === 1 && (this.#i(e), this.updateSelectedKeys(i), this.emit("select", { detail: { key: i, keyPaths: e } })));
|
|
53
|
-
};
|
|
54
|
-
#e(t, s) {
|
|
55
|
-
let i = 0, e = "", n;
|
|
56
|
-
const o = [];
|
|
57
|
-
do {
|
|
58
|
-
const d = t.tagName;
|
|
59
|
-
if (["L-MENU", "BODY"].includes(d))
|
|
60
|
-
break;
|
|
61
|
-
const r = t.getAttribute("index");
|
|
62
|
-
r && (e || (e = r), o.unshift(r), s && s(t, r)), i === 0 && (d === "L-MENU-ITEM" ? (i = 1, n = t) : d === "L-SUB-MENU" && (n = t, i = 2)), t = t.parentElement;
|
|
63
|
-
} while (i >= 0);
|
|
64
|
-
return { type: i, key: e, keyPaths: o, target: n };
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* 展开与提供的 keys 对应的子菜单。
|
|
68
|
-
*
|
|
69
|
-
* 此方法会在当前上下文中选择所有带有 `l-sub-menu` 标签和 `key` 属性的元素,
|
|
70
|
-
* 并对其进行迭代。如果子菜单的 `key` 属性与提供的 keys 中的任意一个匹配,
|
|
71
|
-
* 则通过将其 `collapse` 属性设置为 "off" 来展开子菜单,并将该 key 添加到 `#selectedKeys` 集合中。
|
|
72
|
-
*
|
|
73
|
-
* @param keys - 表示要展开的子菜单的 key 的字符串数组。
|
|
74
|
-
* @param collapseOther - 可选参数,默认为 false。是否折叠其他子菜单。
|
|
75
|
-
*/
|
|
76
|
-
expandSubmenus(t, s = !1) {
|
|
77
|
-
const i = l("l-sub-menu[index]", this);
|
|
78
|
-
a(i, (e) => {
|
|
79
|
-
const n = e.getAttribute("index") || "";
|
|
80
|
-
t.includes(n) ? e.setAttribute("expanded", "") : s && e.removeAttribute("expanded");
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
updateSelectedKeys(t) {
|
|
84
|
-
this.selectedIndex = t;
|
|
85
|
-
const s = f(`l-menu-item[index="${t}"]`, this);
|
|
86
|
-
if (s) {
|
|
87
|
-
const i = this.#e(s, (e) => {
|
|
88
|
-
e.setAttribute("active", ""), e.setAttribute("expanded", "");
|
|
89
|
-
});
|
|
90
|
-
this.#i(i.keyPaths);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
#i(t) {
|
|
94
|
-
const s = l("l-menu-item[active]", this);
|
|
95
|
-
a(s, (i) => {
|
|
96
|
-
const e = i.getAttribute("index") || "";
|
|
97
|
-
t.includes(e) || this.#e(i, (n, o) => {
|
|
98
|
-
t.includes(o) || (n.removeAttribute("expanded"), n.removeAttribute("active"));
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
export {
|
|
104
|
-
A as default
|
|
105
|
-
};
|
|
1
|
+
import { t as e } from "../menu-CzV6lOlw.js";
|
|
2
|
+
export { e as default };
|
|
File without changes
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import e from "./base.js";
|
|
2
|
+
import { parseAttrValue as t } from "./utils/index.js";
|
|
3
|
+
import { $ as n, $$ as r, $one as i, iterate as a, off as o, on as s } from "ph-utils/dom";
|
|
4
|
+
//#region src/components/menu/index.less?inline
|
|
5
|
+
var c = ":host{--l-menu-width:240px;--l-menu-height:auto;--l-menu-level:0;--l-menu-item-height:40px;--l-menu-item-padding-x:10px;--l-menu-item-indent:15px;--l-menu-item-radius:0;--l-menu-item-hover-background:var(--l-primary-color-light5,#f9f0ff);--l-menu-item-active-color:var(--l-primary-color,#722ed1);--l-menu-item-active-background:var(--l-primary-color-light5,#f9f0ff);--l-menu-border-color:var(--l-border-color,#dedede);--l-menu-border-width:1px;--l-menu-arrow-color:var(--l-info-color,#8c8c8c);width:var(--l-menu-width);height:var(--l-menu-height);box-sizing:border-box;display:block}.l-menu{min-width:0;color:inherit;box-sizing:border-box;border-right:var(--l-menu-border-width) solid var(--l-menu-border-color);font-size:14px;transition:height .3s,width .3s;display:block;position:relative;overflow:hidden}.l-menu .l-menu{--l-menu-border-color:transparent}.l-menu-item,.l-submenu-title{padding:0 var(--l-menu-item-padding-x) 0 calc(var(--l-menu-item-padding-x) + var(--l-menu-level) * var(--l-menu-item-indent));height:var(--l-menu-item-height);cursor:pointer;box-sizing:border-box;white-space:nowrap;text-overflow:ellipsis;border-radius:var(--l-menu-item-radius);border-right:2px solid #0000;align-items:center;gap:6px;transition:color .3s,background-color .3s,border-color .3s,transform .2s;display:flex;position:relative;overflow:hidden}.l-menu-item:hover,.l-submenu-title:hover{background-color:var(--l-menu-item-hover-background)}.l-menu-item.active{background-color:var(--l-menu-item-active-background);color:var(--l-menu-item-active-color);font-weight:500}.l-menu-icon-wrap{flex:none;align-items:center;font-size:14px;line-height:1;display:inline-flex}.l-menu-submenu{width:100%;display:block;overflow:hidden}.l-submenu-arrow-icon{color:var(--l-menu-arrow-color);transition:transform .3s;position:absolute;top:50%;right:10px;transform:translateY(-50%)rotate(90deg)}.l-menu-submenu.collapsed .l-submenu-arrow-icon{transform:translateY(-50%)rotate(0)}.l-menu--collapsed{display:none}.l-menu--hide{visibility:hidden;pointer-events:none;position:absolute}.l-menu-submenu.active .l-submenu-title{color:var(--l-menu-item-active-color)}@media (prefers-reduced-motion:reduce){.l-menu,.l-menu-item,.l-submenu-title,.l-submenu-arrow-icon{transition:none!important}}", l = 350, u = class extends e {
|
|
6
|
+
static baseName = "menu";
|
|
7
|
+
accordion = !1;
|
|
8
|
+
_items;
|
|
9
|
+
_menuEl;
|
|
10
|
+
_activeKeys;
|
|
11
|
+
#e;
|
|
12
|
+
#t;
|
|
13
|
+
#n;
|
|
14
|
+
constructor() {
|
|
15
|
+
super(), this._items = [], this._activeKeys = /* @__PURE__ */ new Set(), this.#n = /* @__PURE__ */ new Map(), this.#e = /* @__PURE__ */ new Map(), this.#t = /* @__PURE__ */ new Map(), this.version = 2, this._state = { selectedIndex: "" };
|
|
16
|
+
}
|
|
17
|
+
static get observedAttributes() {
|
|
18
|
+
return ["selected-index", "accordion"];
|
|
19
|
+
}
|
|
20
|
+
attributeChanged(e, n, r) {
|
|
21
|
+
switch (e) {
|
|
22
|
+
case "selected-index":
|
|
23
|
+
this._state.selectedIndex = r || "", this.rendered && this.updateSelectedKeys(this._state.selectedIndex);
|
|
24
|
+
break;
|
|
25
|
+
case "accordion":
|
|
26
|
+
this.accordion = t(r, !1, "accordion"), this._state.accordion = this.accordion;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
afterInit() {
|
|
31
|
+
this.classList.add("l-menu", "l-menu--vertical"), s(this.root, "click", this._handleClick), s(this.root, "transitionend", this._onTransitionEnd), this._menuEl = i(".l-menu", this.root);
|
|
32
|
+
}
|
|
33
|
+
beforeDestroy() {
|
|
34
|
+
o(this.root, "click", this._handleClick), o(this.root, "transitionend", this._onTransitionEnd), this.#n.forEach((e) => clearTimeout(e)), this.#n.clear(), this.#e.forEach((e) => cancelAnimationFrame(e)), this.#e.clear(), this.#t.clear(), this._menuEl = void 0;
|
|
35
|
+
}
|
|
36
|
+
render_v2() {
|
|
37
|
+
return {
|
|
38
|
+
style: c,
|
|
39
|
+
template: r("div", { class: "l-menu" })
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
_handleClick = (e) => {
|
|
43
|
+
let { type: t, key: n, keyPaths: r, target: i } = this.#r(e.target);
|
|
44
|
+
if (i) if (t === 2) {
|
|
45
|
+
let e = i.hasAttribute("expanded");
|
|
46
|
+
this._toggleSubMenu(i, !e), !e && this.accordion && this.#o(i);
|
|
47
|
+
} else t === 1 && (this.#i(r), this.updateSelectedKeys(n), this.emit("select", { detail: {
|
|
48
|
+
key: n,
|
|
49
|
+
keyPaths: r
|
|
50
|
+
} }));
|
|
51
|
+
};
|
|
52
|
+
#r(e, t) {
|
|
53
|
+
let n = 0, r = "", i, a = [];
|
|
54
|
+
do {
|
|
55
|
+
if (!e) break;
|
|
56
|
+
let o = e.getAttribute("index");
|
|
57
|
+
if (o && (r ||= o, a.unshift(o), t && t(e, o)), n === 0) {
|
|
58
|
+
let t = e.getAttribute("menu-role");
|
|
59
|
+
t && (n = Number(t), i = e);
|
|
60
|
+
}
|
|
61
|
+
e = e.parentElement;
|
|
62
|
+
} while (n >= 0);
|
|
63
|
+
return {
|
|
64
|
+
type: n,
|
|
65
|
+
key: r,
|
|
66
|
+
keyPaths: a,
|
|
67
|
+
target: i
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
expandSubmenus(e, t = !1) {
|
|
71
|
+
let r = n(".l-menu-submenu[index]", this.root), i = new Set(e);
|
|
72
|
+
a(r, (e) => {
|
|
73
|
+
let n = e.getAttribute("index") || "";
|
|
74
|
+
i.has(n) ? this._toggleSubMenu(e, !0) : t && this._toggleSubMenu(e, !1);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
updateSelectedKeys(e) {
|
|
78
|
+
this._state.selectedIndex = e;
|
|
79
|
+
let t = e ? i(`.l-menu-item[index="${e}"]`, this.root) : null;
|
|
80
|
+
if (t) {
|
|
81
|
+
let e = this.#r(t, (e) => {
|
|
82
|
+
e.classList.add("active"), e.getAttribute("menu-role") === "2" && this._toggleSubMenu(e, !0);
|
|
83
|
+
});
|
|
84
|
+
this.#i(e.keyPaths);
|
|
85
|
+
} else this.#i([]);
|
|
86
|
+
}
|
|
87
|
+
#i(e) {
|
|
88
|
+
let t = n(".l-menu [index].active", this.root), r = new Set(e);
|
|
89
|
+
a(t, (e) => {
|
|
90
|
+
let t = e.getAttribute("index") || "";
|
|
91
|
+
r.has(t) || this.#r(e, (e, t) => {
|
|
92
|
+
r.has(t) || e.classList.remove("active");
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
_toggleSubMenu(e, t) {
|
|
97
|
+
let n = e.getAttribute("index") || "", r = i(".l-menu", e);
|
|
98
|
+
if (r && t !== e.hasAttribute("expanded")) {
|
|
99
|
+
if (this.#a(n), this.#t.set(n, { expand: t }), t) {
|
|
100
|
+
e.setAttribute("expanded", ""), e.classList.remove("collapsed"), r.classList.add("l-menu--hide"), r.classList.remove("l-menu--collapsed"), r.style.removeProperty("height");
|
|
101
|
+
let t = requestAnimationFrame(() => {
|
|
102
|
+
this.#e.delete(n);
|
|
103
|
+
let t = r.getBoundingClientRect();
|
|
104
|
+
r.style.height = "0", r.classList.remove("l-menu--hide"), requestAnimationFrame(() => {
|
|
105
|
+
e.hasAttribute("expanded") && (r.style.height = `${t.height}px`);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
this.#e.set(n, t);
|
|
109
|
+
} else {
|
|
110
|
+
e.removeAttribute("expanded");
|
|
111
|
+
let t = r.getBoundingClientRect();
|
|
112
|
+
r.style.height = `${t.height}px`, e.classList.add("collapsed");
|
|
113
|
+
let i = requestAnimationFrame(() => {
|
|
114
|
+
this.#e.delete(n), e.hasAttribute("expanded") || (r.style.height = "0");
|
|
115
|
+
});
|
|
116
|
+
this.#e.set(n, i);
|
|
117
|
+
}
|
|
118
|
+
this.#n.set(n, window.setTimeout(() => {
|
|
119
|
+
this.#n.delete(n), this._onTransitionEnd({
|
|
120
|
+
target: r,
|
|
121
|
+
propertyName: "height"
|
|
122
|
+
});
|
|
123
|
+
}, l));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
#a(e) {
|
|
127
|
+
let t = this.#n.get(e);
|
|
128
|
+
t && (clearTimeout(t), this.#n.delete(e));
|
|
129
|
+
let n = this.#e.get(e);
|
|
130
|
+
n && (cancelAnimationFrame(n), this.#e.delete(e));
|
|
131
|
+
}
|
|
132
|
+
#o(e) {
|
|
133
|
+
let t = e.parentElement;
|
|
134
|
+
t && a(n(".l-menu-submenu[expanded]", t), (t) => {
|
|
135
|
+
t !== e && this._toggleSubMenu(t, !1);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
_onTransitionEnd = (e) => {
|
|
139
|
+
if (e.propertyName !== "height") return;
|
|
140
|
+
let t = e.target;
|
|
141
|
+
if (!t.classList.contains("l-menu")) return;
|
|
142
|
+
let n = t.closest(".l-menu-submenu");
|
|
143
|
+
if (!n) return;
|
|
144
|
+
let r = n.getAttribute("index") || "", i = this.#n.get(r);
|
|
145
|
+
i && (clearTimeout(i), this.#n.delete(r));
|
|
146
|
+
let a = this.#t.get(r);
|
|
147
|
+
if (a && a.expand !== n.hasAttribute("expanded")) {
|
|
148
|
+
this.#t.delete(r);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
this.#t.delete(r), t.style.removeProperty("height"), n.hasAttribute("expanded") || t.classList.add("l-menu--collapsed");
|
|
152
|
+
};
|
|
153
|
+
set items(e) {
|
|
154
|
+
this._items = e, this._menuEl && this._menuEl.replaceChildren(this._renderItems());
|
|
155
|
+
}
|
|
156
|
+
get items() {
|
|
157
|
+
return this._items;
|
|
158
|
+
}
|
|
159
|
+
_renderItems() {
|
|
160
|
+
this._state.selectedIndex ? this._activeKeys = new Set(this.#s(this._items, this._state.selectedIndex)) : this._activeKeys = /* @__PURE__ */ new Set();
|
|
161
|
+
let e = document.createDocumentFragment();
|
|
162
|
+
for (let t = 0, n = this._items.length; t < n; t++) e.appendChild(this._renderItem(this._items[t], 0));
|
|
163
|
+
return e;
|
|
164
|
+
}
|
|
165
|
+
_renderItem(e, t = 0) {
|
|
166
|
+
return e.children && e.children.length > 0 ? this._renderSubMenu(e, t) : this._renderMenuItem(e);
|
|
167
|
+
}
|
|
168
|
+
_renderMenuItem(e) {
|
|
169
|
+
let t = r("div", {
|
|
170
|
+
class: ["l-menu-item", this._activeKeys.has(e.key) ? "active" : ""],
|
|
171
|
+
index: e.key,
|
|
172
|
+
"menu-role": "1"
|
|
173
|
+
});
|
|
174
|
+
if (e.icon) {
|
|
175
|
+
let n = e.icon(e);
|
|
176
|
+
n.setAttribute("slot", "icon");
|
|
177
|
+
let i = r("span", { class: "l-menu-icon-wrap" });
|
|
178
|
+
i.appendChild(n), t.appendChild(i);
|
|
179
|
+
}
|
|
180
|
+
return t.appendChild(this._renderTitle(e)), t;
|
|
181
|
+
}
|
|
182
|
+
_renderSubMenu(e, t) {
|
|
183
|
+
let n = this._activeKeys.has(e.key), i = r("div", {
|
|
184
|
+
index: e.key,
|
|
185
|
+
class: ["l-menu-submenu", n ? "active" : void 0],
|
|
186
|
+
"menu-role": "2"
|
|
187
|
+
});
|
|
188
|
+
n && i.setAttribute("expanded", ""), i.setAttribute("data-level", String(t));
|
|
189
|
+
let a = r("div", { class: "l-submenu-title" });
|
|
190
|
+
if (e.icon) {
|
|
191
|
+
let t = e.icon(e), n = r("span", { class: "l-menu-icon-wrap" });
|
|
192
|
+
n.appendChild(t), a.appendChild(n);
|
|
193
|
+
}
|
|
194
|
+
a.appendChild(this._renderTitle(e));
|
|
195
|
+
let o = r("l-arrow-right-icon", { class: "l-submenu-arrow-icon" });
|
|
196
|
+
if (a.appendChild(o), i.appendChild(a), e.children) {
|
|
197
|
+
let a = r("div", { class: ["l-menu", n ? void 0 : "l-menu--collapsed"] });
|
|
198
|
+
a.style.setProperty("--l-menu-level", String(t + 1));
|
|
199
|
+
for (let n = 0, r = e.children.length; n < r; n++) a.appendChild(this._renderItem(e.children[n], t + 1));
|
|
200
|
+
i.appendChild(a);
|
|
201
|
+
}
|
|
202
|
+
return i;
|
|
203
|
+
}
|
|
204
|
+
_renderTitle(e) {
|
|
205
|
+
let t;
|
|
206
|
+
return t = typeof e.label == "string" ? r("span", { textContent: e.label }) : e.label(e), t;
|
|
207
|
+
}
|
|
208
|
+
#s(e, t) {
|
|
209
|
+
let n = (e, r) => {
|
|
210
|
+
for (let i of e) {
|
|
211
|
+
let e = [...r, i.key];
|
|
212
|
+
if (t === i.key) return e;
|
|
213
|
+
if (i.children) {
|
|
214
|
+
let t = n(i.children, e);
|
|
215
|
+
if (t.length > 0) return t;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return [];
|
|
219
|
+
};
|
|
220
|
+
return n(e, []);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
//#endregion
|
|
224
|
+
export { u as t };
|
package/lib/message/index.js
CHANGED
|
@@ -1,66 +1,73 @@
|
|
|
1
|
-
import { regist as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { regist as e, useId as t } from "../utils/index.js";
|
|
2
|
+
import n from "../icon/close_filled.js";
|
|
3
|
+
import r from "../icon/success.js";
|
|
4
|
+
import i from "../icon/warn.js";
|
|
5
|
+
import a from "../icon/info.js";
|
|
6
|
+
import { transition as o } from "ph-utils/dom";
|
|
7
|
+
//#region src/components/message/index.ts
|
|
8
|
+
var s = [], c = [[
|
|
9
|
+
"opacity",
|
|
10
|
+
"0",
|
|
11
|
+
"0.3s"
|
|
12
|
+
], [
|
|
13
|
+
"transform",
|
|
14
|
+
"translate3d(-50%, -100%, 0)",
|
|
15
|
+
"0.3s"
|
|
16
|
+
]], l = !0;
|
|
12
17
|
function u(e) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
18
|
+
let t = s.findIndex((t) => t.id === e);
|
|
19
|
+
if (t === -1) return;
|
|
20
|
+
let n = s.splice(t, 1)[0];
|
|
21
|
+
if (n == null) return;
|
|
22
|
+
o(n, c, "leave", () => {
|
|
23
|
+
n.remove();
|
|
24
|
+
});
|
|
25
|
+
let r = 15 + n.offsetHeight, i = s.length;
|
|
26
|
+
if (i !== 0) for (let e = t; e < i; e++) {
|
|
27
|
+
let t = s[e], n = parseInt(t.style.top, 10) - r;
|
|
28
|
+
t.style.setProperty("top", `${n}px`);
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
].join(""), t;
|
|
31
|
+
function d(e) {
|
|
32
|
+
let t = document.createElement("div");
|
|
33
|
+
t.id = e.id;
|
|
34
|
+
let n = e.type || "info", r = `l-message l-message-${n}`;
|
|
35
|
+
e.customClass && (r += " " + e.customClass), t.className = r, t.style.setProperty("top", `${e.offset}px`), e.zindex && t.style.setProperty("z-index", `${e.zindex}`), e.width && t.style.setProperty("width", e.width);
|
|
36
|
+
let i = n;
|
|
37
|
+
return i === "error" && (i = "close-filled"), t.innerHTML = [
|
|
38
|
+
"<div class=\"l-message-container\">",
|
|
39
|
+
`<l-${i}-icon class="l-message-icon"></l-${i}-icon>`,
|
|
40
|
+
`<span class="l-message-content">${e.message}</span>`,
|
|
41
|
+
"</div>"
|
|
42
|
+
].join(""), t;
|
|
40
43
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
44
|
+
var f = ((f) => {
|
|
45
|
+
l &&= (e([
|
|
46
|
+
n,
|
|
47
|
+
r,
|
|
48
|
+
i,
|
|
49
|
+
a
|
|
50
|
+
]), !1);
|
|
51
|
+
let p = s.reduce((e, t) => e + t.offsetHeight + 15, 15), m = t(), h = typeof f == "string" ? { message: f } : f;
|
|
52
|
+
h.id = m, h.offset = p;
|
|
53
|
+
let g = d(h);
|
|
54
|
+
s.push(g), document.body.appendChild(g), o(g, c, "enter");
|
|
55
|
+
let _ = h.duration;
|
|
56
|
+
return _ ??= 3e3, _ !== 0 && setTimeout(() => {
|
|
57
|
+
u(m);
|
|
58
|
+
}, _), m;
|
|
51
59
|
});
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
60
|
+
function p(e, t = "info") {
|
|
61
|
+
let n = typeof e == "string" ? { message: e } : e;
|
|
62
|
+
return n.type ||= t, f(n);
|
|
55
63
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
export {
|
|
65
|
-
F as default
|
|
64
|
+
var m = {
|
|
65
|
+
info: (e) => p(e, "info"),
|
|
66
|
+
success: (e) => p(e, "success"),
|
|
67
|
+
error: (e) => p(e, "error"),
|
|
68
|
+
warn: (e) => p(e, "warn"),
|
|
69
|
+
show: (e) => p(e),
|
|
70
|
+
close: u
|
|
66
71
|
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { m as default };
|