litos-ui 0.12.2 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/base.d.ts +23 -2
- package/lib/base.js +37 -8
- package/lib/button/index.d.ts +3 -1
- package/lib/button/index.js +18 -19
- 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 +6 -6
- 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 +3 -5
- package/lib/form/form_inner.js +29 -31
- package/lib/form/form_item.d.ts +1 -3
- package/lib/form/form_item.js +30 -41
- 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/icon/{mask_close.d.ts → close_filled.d.ts} +1 -1
- package/lib/icon/{mask_close.js → close_filled.js} +1 -1
- package/lib/index-dwS1N2uN.js +4 -0
- package/lib/index.d.ts +40 -6
- package/lib/index.js +120 -87
- package/lib/input/index.d.ts +6 -5
- package/lib/input/index.js +105 -57
- package/lib/list/index.d.ts +2 -3
- package/lib/list/index.js +17 -17
- package/lib/litos-ui.css +1 -1
- package/lib/loading/index.d.ts +45 -0
- package/lib/loading/index.js +141 -0
- package/lib/md_input/index.js +9 -9
- package/lib/menu/base.js +1 -0
- package/lib/menu/index.d.ts +31 -0
- package/lib/menu/index.js +95 -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 +15 -0
- package/lib/menu/sub_menu.js +82 -0
- package/lib/message/index.js +1 -1
- 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/select_ori/index.d.ts +1 -3
- package/lib/select_ori/index.js +12 -16
- 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 +1 -6
- package/lib/utils/index.js +47 -54
- package/lib/utils/transition.js +4 -2
- package/package.json +8 -8
- package/styles/vars.css +1 -1
- package/lib/checkbox/index.d.ts +0 -17
- package/lib/checkbox/index.js +0 -135
- package/lib/index-391POYEJ.js +0 -4
- package/lib/litos-ui.min.js +0 -1
- package/lib/radio/index.d.ts +0 -28
- package/lib/radio/index.js +0 -122
package/lib/base.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ export default class BaseComponent extends HTMLElement {
|
|
|
2
2
|
static baseName: string;
|
|
3
3
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
4
4
|
rendered: boolean;
|
|
5
|
-
constructor(shadow?: boolean);
|
|
5
|
+
constructor(shadow?: boolean, init?: Partial<ShadowRootInit>);
|
|
6
6
|
/**
|
|
7
7
|
* 返回一个数组,表示观察的属性列表
|
|
8
8
|
*/
|
|
9
9
|
static get observedAttributes(): string[] | undefined | null;
|
|
10
|
-
attributeChangedCallback(
|
|
10
|
+
attributeChangedCallback(_name: string, _oldValue: string, _newValue: string): void;
|
|
11
|
+
/** @deprecated */
|
|
11
12
|
get shadow(): ShadowRoot;
|
|
12
13
|
get root(): ShadowRoot | HTMLElement;
|
|
13
14
|
createStyle(text: string): void;
|
|
@@ -31,4 +32,24 @@ export default class BaseComponent extends HTMLElement {
|
|
|
31
32
|
connectedCallback(): void;
|
|
32
33
|
disconnectedCallback(): void;
|
|
33
34
|
render(): void | string | HTMLElement | HTMLElement[] | DocumentFragment;
|
|
35
|
+
/**
|
|
36
|
+
* 初始化事件
|
|
37
|
+
* @deprecated 自0.12.0起弃用,使用 afterInit() 替代
|
|
38
|
+
*/
|
|
39
|
+
initEvents(): void;
|
|
40
|
+
afterInit(): void;
|
|
41
|
+
/** 移除事件 */
|
|
42
|
+
/**
|
|
43
|
+
* 移除事件
|
|
44
|
+
* @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
|
|
45
|
+
*/
|
|
46
|
+
removeEvents(): void;
|
|
47
|
+
beforeDestroy(): void;
|
|
48
|
+
/**
|
|
49
|
+
* 触发自定义事件
|
|
50
|
+
* @param name 事件名称
|
|
51
|
+
* @param eventOption 自定义事件配置选项, 默认: bubbles: true
|
|
52
|
+
* @returns 是否成功触发事件
|
|
53
|
+
*/
|
|
54
|
+
emit(name: string, eventOption?: Partial<CustomEventInit>): boolean;
|
|
34
55
|
}
|
package/lib/base.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { getAttr as r } from "ph-utils/dom";
|
|
2
|
-
class
|
|
2
|
+
class i extends HTMLElement {
|
|
3
3
|
static baseName = "base-component";
|
|
4
4
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
5
5
|
rendered = !1;
|
|
6
|
-
constructor(t = !0) {
|
|
7
|
-
super(), t && this.attachShadow({ mode: "open" });
|
|
6
|
+
constructor(t = !0, e = {}) {
|
|
7
|
+
super(), this.rendered = !1, t && this.attachShadow({ mode: "open", ...e });
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
10
10
|
* 返回一个数组,表示观察的属性列表
|
|
@@ -13,8 +13,9 @@ class a extends HTMLElement {
|
|
|
13
13
|
return [];
|
|
14
14
|
}
|
|
15
15
|
// 当属性发生变化时调用的回调函数
|
|
16
|
-
attributeChangedCallback(t, e,
|
|
16
|
+
attributeChangedCallback(t, e, s) {
|
|
17
17
|
}
|
|
18
|
+
/** @deprecated */
|
|
18
19
|
get shadow() {
|
|
19
20
|
return this.shadowRoot;
|
|
20
21
|
}
|
|
@@ -40,18 +41,46 @@ class a extends HTMLElement {
|
|
|
40
41
|
if (t)
|
|
41
42
|
if (typeof t == "string") {
|
|
42
43
|
let e = document.createElement("div");
|
|
43
|
-
e.innerHTML = t, this.root.append(...e.
|
|
44
|
+
e.innerHTML = t, this.root.append(...e.childNodes), e = void 0;
|
|
44
45
|
} else t.length ? this.root.append(...t) : this.root.append(t);
|
|
45
46
|
}
|
|
46
47
|
connectedCallback() {
|
|
47
|
-
this.appendToRoot(this.render()), this.rendered = !0;
|
|
48
|
+
this.appendToRoot(this.render()), this.rendered = !0, this.initEvents(), this.afterInit();
|
|
48
49
|
}
|
|
49
50
|
disconnectedCallback() {
|
|
50
|
-
this.root.innerHTML = "", this.rendered = !1;
|
|
51
|
+
this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
|
|
51
52
|
}
|
|
52
53
|
render() {
|
|
53
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* 初始化事件
|
|
57
|
+
* @deprecated 自0.12.0起弃用,使用 afterInit() 替代
|
|
58
|
+
*/
|
|
59
|
+
initEvents() {
|
|
60
|
+
}
|
|
61
|
+
afterInit() {
|
|
62
|
+
}
|
|
63
|
+
/** 移除事件 */
|
|
64
|
+
/**
|
|
65
|
+
* 移除事件
|
|
66
|
+
* @deprecated 自0.12.0起弃用,使用 beforeDestroy() 替代
|
|
67
|
+
*/
|
|
68
|
+
removeEvents() {
|
|
69
|
+
}
|
|
70
|
+
beforeDestroy() {
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* 触发自定义事件
|
|
74
|
+
* @param name 事件名称
|
|
75
|
+
* @param eventOption 自定义事件配置选项, 默认: bubbles: true
|
|
76
|
+
* @returns 是否成功触发事件
|
|
77
|
+
*/
|
|
78
|
+
emit(t, e) {
|
|
79
|
+
return this.dispatchEvent(
|
|
80
|
+
new CustomEvent(t, { bubbles: !0, composed: !1, ...e })
|
|
81
|
+
);
|
|
82
|
+
}
|
|
54
83
|
}
|
|
55
84
|
export {
|
|
56
|
-
|
|
85
|
+
i as default
|
|
57
86
|
};
|
package/lib/button/index.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import BaseComponent from "../base";
|
|
|
2
2
|
export default class Button extends BaseComponent {
|
|
3
3
|
static baseName: string;
|
|
4
4
|
htmlType: "submit" | "reset" | "button";
|
|
5
|
-
|
|
5
|
+
/** 加载中文本 */
|
|
6
|
+
loadingText: string;
|
|
7
|
+
disabled: boolean;
|
|
6
8
|
static get observedAttributes(): string[];
|
|
7
9
|
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
8
10
|
connectedCallback(): void;
|
package/lib/button/index.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import { $one as h, addClass as g, removeClass as
|
|
4
|
-
import { adjust as
|
|
1
|
+
import { parseAttrValue as b, initAttr as s } from "../utils/index.js";
|
|
2
|
+
import c from "../base.js";
|
|
3
|
+
import { $one as h, addClass as g, removeClass as f, on as p, off as v, formatClass as u, formatStyle as m, getAttr as k } from "ph-utils/dom";
|
|
4
|
+
import { adjust as i } from "ph-utils/color";
|
|
5
5
|
import { a as x } from "../animation-DttknHkX.js";
|
|
6
|
-
const y = ":host{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-block;width:auto}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:
|
|
7
|
-
class
|
|
6
|
+
const y = ":host{--l-btn-text-color: #ffffff;--l-btn-hover-text-color: var(--l-btn-text-color);--l-btn-active-text-color: var(--l-btn-text-color);--l-btn-border-color: var(--l-primary-color, #722ed1);--l-btn-background: var(--l-btn-border-color);--l-btn-hover-border-color: var(--l-primary-color-light1, #9254de);--l-btn-hover-background: var(--l-btn-hover-border-color);--l-btn-active-border-color: var(--l-primary-color-dark1, #531dab);--l-btn-active-background: var(--l-btn-active-border-color);--l-btn-disabled-color: #c9c9c9;--l-btn-disabled-background: #fbfbfb;--l-btn-disabled-border-color: #e6e6e6;display:inline-block;width:auto;height:var(--l-form-edit-height, 32px);font-size:0}:host([block]){width:100%}.l-btn{width:100%;display:inline-flex;justify-content:center;align-items:center;cursor:pointer;outline:none;box-sizing:border-box;vertical-align:middle;padding:0 15px;line-height:1;height:100%;border-radius:3px;font-size:14px;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:5px;transition:border-color .3s,background-color .3s,color .3s}.l-btn:hover{border-color:var(--l-btn-hover-border-color, var(--l-btn-hover-background));color:var(--l-btn-hover-text-color);background:var(--l-btn-hover-background)}.l-btn:active{border-color:var(--l-btn-active-border-color, var(--l-btn-active-background));color:var(--l-btn-active-text-color);background:var(--l-btn-active-background)}.l-btn-normal{--l-btn-text-color: auto;--l-btn-background: transparent;--l-btn-border-color: #d9d9d9;--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab);--l-btn-hover-background: #fff;--l-btn-active-background: #fff;--l-btn-hover-border-color: var(--l-btn-hover-text-color);--l-btn-active-border-color: var(--l-btn-active-text-color)}.l-btn-primary{--l-btn-background: var(--l-primary-color, #722ed1);--l-btn-hover-background: var(--l-primary-color-light1, #9254de);--l-btn-active-background: var(--l-primary-color-dark1, #531dab);--l-btn-disabled-border-color: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-background: var(--l-primary-color-light2, #b37feb);--l-btn-disabled-color: #ffffff}.l-btn:disabled{border-color:var(--l-btn-disabled-border-color);background:var(--l-btn-disabled-background);color:var(--l-btn-disabled-color);cursor:not-allowed;opacity:1}.l-btn.l-btn-loading{cursor:default}.l-btn-text{--l-btn-background: transparent;--l-btn-border-color: transparent;--l-btn-hover-border-color: transparent;--l-btn-active-border-color: transparent;--l-btn-disabled-background: transparent;--l-btn-disabled-border-color: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;padding:5px}.l-btn-primary.l-btn-text{--l-btn-text-color: var(--l-primary-color, #722ed1);--l-btn-hover-text-color: var(--l-primary-color-light1, #9254de);--l-btn-active-text-color: var(--l-primary-color-dark1, #531dab)}.l-btn-ghost{--l-btn-text-color: var(--l-btn-border-color);--l-btn-background: transparent;--l-btn-hover-background: transparent;--l-btn-active-background: transparent;--l-btn-hover-text-color: var(--l-btn-hover-border-color);--l-btn-active-text-color: var(--l-btn-active-border-color)}.l-btn-round{border-radius:calc(var(--l-form-edit-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-edit-height, 32px);padding:0}.l-btn:not(.l-btn-text)+.l-btn{margin-left:10px}html.dark .l-btn:disabled{--l-btn-disabled-background: rgba(255, 255, 255, .08);--l-btn-disabled-color: rgba(255, 255, 255, .3);--l-btn-disabled-border-color: rgba(255, 255, 255, .3)}";
|
|
7
|
+
class M extends c {
|
|
8
8
|
static baseName = "button";
|
|
9
9
|
htmlType = "button";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
/** 加载中文本 */
|
|
11
|
+
loadingText = "";
|
|
12
|
+
disabled = !1;
|
|
13
13
|
// 初始化属性观察器
|
|
14
14
|
static get observedAttributes() {
|
|
15
15
|
return ["loading", "color", "disabled"];
|
|
@@ -19,40 +19,39 @@ class w extends d {
|
|
|
19
19
|
const l = h(".l-btn", this.root);
|
|
20
20
|
if (l)
|
|
21
21
|
if (r === "loading")
|
|
22
|
-
|
|
22
|
+
b(o, !1, r) ? (g(l, "l-btn-loading"), l.disabled = !0, l.innerHTML = this.loadingBody()) : (f(l, "l-btn-loading"), l.disabled = this.disabled, l.innerHTML = "<slot></slot>");
|
|
23
23
|
else if (r === "color") {
|
|
24
24
|
const e = this.getAttr("text", !1), n = this.getAttr("ghost", !1);
|
|
25
25
|
l.style.cssText = this.applyColor(o, e, n);
|
|
26
|
-
} else r === "disabled" && (l.disabled =
|
|
26
|
+
} else r === "disabled" && (l.disabled = b(o, !1, "disabled"));
|
|
27
27
|
}
|
|
28
28
|
connectedCallback() {
|
|
29
|
-
this.loadStyleText([
|
|
29
|
+
s(this), this.loadStyleText([x, y]), this.render(), (this.htmlType === "reset" || this.htmlType === "submit") && p(this, "click", this._handleClick);
|
|
30
30
|
}
|
|
31
31
|
disconnectedCallback() {
|
|
32
|
-
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") &&
|
|
32
|
+
super.disconnectedCallback(), (this.htmlType === "reset" || this.htmlType === "submit") && v(this, "click", this._handleClick);
|
|
33
33
|
}
|
|
34
34
|
render() {
|
|
35
|
-
const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1),
|
|
35
|
+
const r = this.getAttr("type", "normal"), t = document.createElement("button"), o = this.getAttr("loading", !1), l = this.getAttr("shape", "default"), e = this.getAttr("text", !1), n = this.getAttr("ghost", !1), d = [
|
|
36
36
|
"l-btn",
|
|
37
37
|
`l-btn-${r}`,
|
|
38
|
-
this.getAttr("block", !1) ? "l-btn-block" : "",
|
|
39
38
|
l === "round" ? "l-btn-round" : "",
|
|
40
39
|
l === "circle" ? "l-btn-circle" : "",
|
|
41
40
|
n ? "l-btn-ghost" : "",
|
|
42
41
|
e ? "l-btn-text" : "",
|
|
43
42
|
o ? "l-btn-loading" : ""
|
|
44
43
|
];
|
|
45
|
-
t.className = u(
|
|
44
|
+
t.className = u(d), t.disabled = this.getAttr("disabled", !1) || o, t.type = this.getAttr("html-type", "button");
|
|
46
45
|
const a = this.applyColor(this.getAttr("color"), e, n);
|
|
47
46
|
a && (t.style.cssText = a), o ? t.innerHTML = this.loadingBody() : t.innerHTML = "<slot></slot>", t.setAttribute("part", "default"), this.root.appendChild(t);
|
|
48
47
|
}
|
|
49
48
|
loadingBody() {
|
|
50
49
|
const r = this.getAttr("loading-text", ""), t = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
51
|
-
return r
|
|
50
|
+
return r ? t.push(`<span>${r}</span>`) : t.push("<slot></slot>"), t.join("");
|
|
52
51
|
}
|
|
53
52
|
applyColor(r, t = !1, o = !1) {
|
|
54
53
|
if (!r) return "";
|
|
55
|
-
const l =
|
|
54
|
+
const l = i(r, 1, !0), e = i(r, 3, !1);
|
|
56
55
|
return m({
|
|
57
56
|
"--l-btn-border-color": t ? "transparent" : r,
|
|
58
57
|
"--l-btn-text-color": o || t ? r : "#ffffff",
|
|
@@ -87,5 +86,5 @@ class w extends d {
|
|
|
87
86
|
}
|
|
88
87
|
}
|
|
89
88
|
export {
|
|
90
|
-
|
|
89
|
+
M as default
|
|
91
90
|
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import BaseComponent from "../base";
|
|
2
|
+
export default class Carousel extends BaseComponent {
|
|
3
|
+
#private;
|
|
4
|
+
static baseName: string;
|
|
5
|
+
/** 是否显示箭头 */
|
|
6
|
+
arrows: "hover" | "always" | "never";
|
|
7
|
+
currentIndex: number;
|
|
8
|
+
allIndex: number;
|
|
9
|
+
loop: boolean;
|
|
10
|
+
observer?: MutationObserver;
|
|
11
|
+
autoplay: boolean;
|
|
12
|
+
static get observedAttributes(): string[];
|
|
13
|
+
attributeChangedCallback(name: string, _oldValue: string, newValue: string): void;
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
afterInit(): void;
|
|
16
|
+
beforeDestroy(): void;
|
|
17
|
+
render(): DocumentFragment;
|
|
18
|
+
renderArrows(fragment: DocumentFragment): void;
|
|
19
|
+
renderNavigationButton(dir: "prev" | "next" | undefined, fragment: DocumentFragment): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import u from "../base.js";
|
|
2
|
+
import { getAttr as m, on as l, $one as h, off as r, $$ as c, $ as p, iterate as f, shouldEventNext as v } from "ph-utils/dom";
|
|
3
|
+
import { debounce as x } from "ph-utils/web";
|
|
4
|
+
import { parseAttrValue as d } from "../utils/index.js";
|
|
5
|
+
import b from "./timer.js";
|
|
6
|
+
const g = ":host{display:block;width:100%;height:180px;margin:0 auto;box-sizing:border-box;position:relative;overflow:hidden}.container{min-width:900%;height:100%;box-sizing:border-box;position:relative;display:flex}.nav-button{position:absolute;top:50%;transform:translateY(-50%);width:30px;height:30px;border:none;outline:none;border-radius:50%;cursor:pointer;display:flex;justify-content:center;align-items:center;z-index:20;font-size:16px;background-color:#292d3d4d;margin:0;padding:0;color:#fff;transition:background-color .3s}.nav-button:hover{background-color:#292d3d66}.nav-button:active{background-color:#292d3d80}.nav-prev{left:20px}.nav-next{right:20px}.pagination{position:absolute;bottom:10px;left:0;width:100%;z-index:2;display:flex;align-items:center;gap:8px;justify-content:center}.bullet{display:inline-block;width:8px;height:8px;border-radius:50%;background-color:#0000004d;cursor:pointer;transition:background-color .3s}.bullet.active{background-color:var(--l-primary-color, #722ed1)}";
|
|
7
|
+
class A extends u {
|
|
8
|
+
static baseName = "carousel";
|
|
9
|
+
/** 是否显示箭头 */
|
|
10
|
+
arrows = "hover";
|
|
11
|
+
currentIndex = 0;
|
|
12
|
+
allIndex = -1;
|
|
13
|
+
#s = 0;
|
|
14
|
+
// 当前偏移量
|
|
15
|
+
loop = !0;
|
|
16
|
+
observer;
|
|
17
|
+
autoplay = !1;
|
|
18
|
+
#e = void 0;
|
|
19
|
+
/* 手势 */
|
|
20
|
+
#o = 0;
|
|
21
|
+
#i = !1;
|
|
22
|
+
#d = 0;
|
|
23
|
+
#r = 0;
|
|
24
|
+
// 节点引用
|
|
25
|
+
#t;
|
|
26
|
+
static get observedAttributes() {
|
|
27
|
+
return ["arrows", "loop", "current-index", "autoplay"];
|
|
28
|
+
}
|
|
29
|
+
attributeChangedCallback(t, e, i) {
|
|
30
|
+
switch (t) {
|
|
31
|
+
case "arrows":
|
|
32
|
+
const s = d(i, "hover");
|
|
33
|
+
if (s !== this.arrows) {
|
|
34
|
+
this.arrows = s;
|
|
35
|
+
const a = document.createDocumentFragment();
|
|
36
|
+
this.renderArrows(a), this.root.appendChild(a);
|
|
37
|
+
}
|
|
38
|
+
break;
|
|
39
|
+
case "loop":
|
|
40
|
+
this.loop = d(i, !1, "loop");
|
|
41
|
+
break;
|
|
42
|
+
case "current-index":
|
|
43
|
+
const n = d(i, 0);
|
|
44
|
+
n !== this.currentIndex && this.#x(this.loop ? n + 1 : n);
|
|
45
|
+
break;
|
|
46
|
+
case "autoplay":
|
|
47
|
+
const o = d(i, !1, "autoplay");
|
|
48
|
+
o !== this.autoplay && (this.autoplay = o, this.#e && (o ? this.#e.start() : this.#e.stop()));
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
connectedCallback() {
|
|
53
|
+
this.loadStyleText(g), this.style.setProperty(
|
|
54
|
+
"--carousel-width",
|
|
55
|
+
`${Math.floor(this.clientWidth)}px`
|
|
56
|
+
);
|
|
57
|
+
const t = m(this, "height");
|
|
58
|
+
t && this.style.setProperty("height", `${t}px`), this.#m(), super.connectedCallback();
|
|
59
|
+
}
|
|
60
|
+
afterInit() {
|
|
61
|
+
this.setAttribute("data-page", "__stop__"), l(this.root, "click", this.#v), this.#f(), this.#e = b(() => {
|
|
62
|
+
this.#a("next");
|
|
63
|
+
}), this.autoplay && this.#e.start(), this.#t = h(".container", this.root), l(this.#t, "pointerdown", this.#y), l(this.#t, "pointerup", this.#I), l(this.#t, "pointermove", this.#$), l(this.#t, "pointercancel", this.#n), l(this.#t, "pointerleave", this.#n);
|
|
64
|
+
}
|
|
65
|
+
beforeDestroy() {
|
|
66
|
+
r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h), r(this.root, "click", this.#v), r(this.#t, "pointerdown", this.#y), r(this.#t, "pointerup", this.#I), r(this.#t, "pointermove", this.#$), r(this.#t, "pointercancel", this.#n), r(this.#t, "pointerleave", this.#n), this.#t = void 0, this.#u(!0), this.#e.stop(), this.#e = void 0;
|
|
67
|
+
}
|
|
68
|
+
render() {
|
|
69
|
+
const t = document.createDocumentFragment();
|
|
70
|
+
let e = "";
|
|
71
|
+
if (this.allIndex > 0) {
|
|
72
|
+
const n = this.loop ? this.currentIndex + 1 : this.currentIndex, o = Math.floor(n * this.clientWidth * -1);
|
|
73
|
+
e = `transform:translateX(${o}px);`;
|
|
74
|
+
const a = Math.floor(this.clientWidth * (this.allIndex + 3));
|
|
75
|
+
e += `min-width:${a}px;`, this.#s = o;
|
|
76
|
+
}
|
|
77
|
+
const i = c("div", {
|
|
78
|
+
class: "container",
|
|
79
|
+
style: e,
|
|
80
|
+
"data-container": "1"
|
|
81
|
+
});
|
|
82
|
+
i.appendChild(c("slot")), t.appendChild(i), this.renderArrows(t);
|
|
83
|
+
const s = c("div", { class: "pagination", part: "pagination" });
|
|
84
|
+
return this.allIndex >= 0 && s.replaceChildren(this.#p()), t.appendChild(s), t;
|
|
85
|
+
}
|
|
86
|
+
renderArrows(t) {
|
|
87
|
+
if (this.arrows !== "never")
|
|
88
|
+
this.renderNavigationButton("prev", t), this.renderNavigationButton("next", t), this.arrows === "hover" && (l(this, "mouseenter", this.#l), l(this, "mouseleave", this.#h));
|
|
89
|
+
else {
|
|
90
|
+
r(this, "mouseenter", this.#l), r(this, "mouseleave", this.#h);
|
|
91
|
+
const e = p(".nav-button", this.root);
|
|
92
|
+
e.length && f(e, (i) => {
|
|
93
|
+
i.remove();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
#p() {
|
|
98
|
+
const t = document.createDocumentFragment();
|
|
99
|
+
for (let e = 0; e <= this.allIndex; e++)
|
|
100
|
+
t.appendChild(
|
|
101
|
+
c("div", {
|
|
102
|
+
class: ["bullet", e === this.currentIndex ? "active" : ""],
|
|
103
|
+
"aria-label": `第 ${e + 1} 页`,
|
|
104
|
+
"data-page": `${e}`,
|
|
105
|
+
id: `bullet-${e}`
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
return t;
|
|
109
|
+
}
|
|
110
|
+
renderNavigationButton(t = "prev", e) {
|
|
111
|
+
let i = h(`.nav-${t}`, this.root);
|
|
112
|
+
if (i == null) {
|
|
113
|
+
const s = t === "prev" ? "left" : "right";
|
|
114
|
+
i = c("button", {
|
|
115
|
+
class: `nav-button nav-${t}`,
|
|
116
|
+
type: "button",
|
|
117
|
+
innerHTML: `<l-arrow-${s}-icon></l-arrow-${s}-icon>`,
|
|
118
|
+
"aria-label": t,
|
|
119
|
+
"data-page": t
|
|
120
|
+
}), e.appendChild(i);
|
|
121
|
+
}
|
|
122
|
+
this.arrows === "always" ? i.style.display = "flex" : i.style.display = "none";
|
|
123
|
+
}
|
|
124
|
+
#f() {
|
|
125
|
+
this.observer == null && (this.observer = new MutationObserver(this.#C)), this.observer.observe(this, { childList: !0 });
|
|
126
|
+
}
|
|
127
|
+
#u(t = !1) {
|
|
128
|
+
this.observer && (this.observer.disconnect(), t && (this.observer = void 0));
|
|
129
|
+
}
|
|
130
|
+
#w = x(() => {
|
|
131
|
+
const t = h("#cloneFirst", this);
|
|
132
|
+
t && t.remove();
|
|
133
|
+
const e = h("#cloneLast", this);
|
|
134
|
+
if (e && e.remove(), this.#m(), this.#t) {
|
|
135
|
+
if (this.allIndex > 0) {
|
|
136
|
+
const o = Math.floor(
|
|
137
|
+
this.clientWidth * (this.allIndex + 3)
|
|
138
|
+
);
|
|
139
|
+
this.#t.style.minWidth = `${o}px`;
|
|
140
|
+
} else
|
|
141
|
+
this.#t.style.minWidth = "900%";
|
|
142
|
+
const s = this.loop ? this.currentIndex + 1 : this.currentIndex, n = Math.floor(s * this.clientWidth * -1);
|
|
143
|
+
this.#t.style.transform = `translateX(${n}px)`, this.#s = n;
|
|
144
|
+
}
|
|
145
|
+
const i = h(".pagination", this.root);
|
|
146
|
+
i && i.replaceChildren(this.#p()), this.#f();
|
|
147
|
+
}, 300);
|
|
148
|
+
#m() {
|
|
149
|
+
const t = this.children, e = t.length;
|
|
150
|
+
if (e > 0 && this.loop) {
|
|
151
|
+
const i = t[0].cloneNode(!0);
|
|
152
|
+
i.id = "cloneFirst";
|
|
153
|
+
const s = t[e - 1].cloneNode(!0);
|
|
154
|
+
s.id = "cloneLast", this.children[e - 1].insertAdjacentElement("afterend", i), this.children[0].insertAdjacentElement("beforebegin", s);
|
|
155
|
+
}
|
|
156
|
+
this.allIndex = this.children.length - (this.loop ? 3 : 1);
|
|
157
|
+
}
|
|
158
|
+
#C = (t) => {
|
|
159
|
+
for (const e of t)
|
|
160
|
+
e.type === "childList" && (this.#u(), this.#w());
|
|
161
|
+
};
|
|
162
|
+
#v = (t) => {
|
|
163
|
+
const [e, i] = v(t, "data-page", this.root);
|
|
164
|
+
e && this.#a(i);
|
|
165
|
+
};
|
|
166
|
+
#a(t) {
|
|
167
|
+
this.#e.stop();
|
|
168
|
+
const e = this.loop ? this.currentIndex + 1 : this.currentIndex;
|
|
169
|
+
let i = e;
|
|
170
|
+
if (t === "prev")
|
|
171
|
+
this.loop && this.currentIndex === 0 ? i = 0 : i = e - 1, i < 0 && (i = 0);
|
|
172
|
+
else if (t === "next")
|
|
173
|
+
this.loop && this.currentIndex === this.allIndex ? i = this.allIndex + 2 : i = e + 1, !this.loop && i > this.allIndex && (i = this.allIndex);
|
|
174
|
+
else {
|
|
175
|
+
const s = Number(t);
|
|
176
|
+
s !== this.currentIndex && (i = this.loop ? s + 1 : s);
|
|
177
|
+
}
|
|
178
|
+
i !== e && this.#x(i), requestAnimationFrame(() => {
|
|
179
|
+
this.#c();
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
#x(t) {
|
|
183
|
+
if (this.#t) {
|
|
184
|
+
const s = Math.floor(t * this.clientWidth * -1), n = this.#t.style.transform;
|
|
185
|
+
this.#t.animate(
|
|
186
|
+
[{ transform: n }, { transform: `translateX(${s}px)` }],
|
|
187
|
+
{ duration: 300 }
|
|
188
|
+
).addEventListener(
|
|
189
|
+
"finish",
|
|
190
|
+
() => {
|
|
191
|
+
let a = s;
|
|
192
|
+
this.loop && t === this.allIndex + 2 ? a = Math.floor(this.clientWidth * -1) : this.loop && t === 0 && (a = Math.floor(this.clientWidth * (this.allIndex + 1) * -1)), this.#t.style.transform = `translateX(${a}px)`, this.#s = a;
|
|
193
|
+
},
|
|
194
|
+
{ once: !0 }
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
this.loop && this.allIndex > 0 && t === this.allIndex + 2 ? this.currentIndex = 0 : this.loop && this.allIndex > 0 && t === 0 ? this.currentIndex = this.allIndex : this.currentIndex = this.loop ? t - 1 : t;
|
|
198
|
+
const e = h(".bullet.active", this.root);
|
|
199
|
+
e && e.classList.remove("active");
|
|
200
|
+
const i = h(`#bullet-${this.currentIndex}`, this.root);
|
|
201
|
+
i && i.classList.add("active");
|
|
202
|
+
}
|
|
203
|
+
#l = () => {
|
|
204
|
+
if (this.arrows === "hover") {
|
|
205
|
+
const t = p(".nav-button", this.root);
|
|
206
|
+
f(t, (e) => {
|
|
207
|
+
e.style.display = "flex", this.#b(e, !0);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
};
|
|
211
|
+
#h = () => {
|
|
212
|
+
if (this.arrows === "hover") {
|
|
213
|
+
const t = p(".nav-button", this.root);
|
|
214
|
+
f(t, (e) => {
|
|
215
|
+
this.#b(e, !1);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
#b(t, e = !0) {
|
|
220
|
+
const s = t.getAttribute("data-page") === "prev" ? -10 : 10, n = [];
|
|
221
|
+
e ? n.push(
|
|
222
|
+
{ opacity: 0, transform: `translate3d(${s}px, -50%, 0)` },
|
|
223
|
+
{ opacity: 1, transform: "translate3d(0px, -50%, 0)" }
|
|
224
|
+
) : n.push(
|
|
225
|
+
{ opacity: 1, transform: "translate3d(0px, -50%, 0)" },
|
|
226
|
+
{ opacity: 0, transform: `translate3d(${s}px, -50%, 0)` }
|
|
227
|
+
);
|
|
228
|
+
const o = t.animate(n, {
|
|
229
|
+
duration: 300,
|
|
230
|
+
fill: "both"
|
|
231
|
+
});
|
|
232
|
+
e || o.addEventListener(
|
|
233
|
+
"finish",
|
|
234
|
+
() => {
|
|
235
|
+
t.style.display = "none";
|
|
236
|
+
},
|
|
237
|
+
{ once: !0 }
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
#g = () => {
|
|
241
|
+
const t = h(".container", this.root);
|
|
242
|
+
t.style.transition = "transform 0.3s", requestAnimationFrame(() => {
|
|
243
|
+
t.style.transform = `translateX(${this.#s}px)`;
|
|
244
|
+
}), t.addEventListener(
|
|
245
|
+
"transitionend",
|
|
246
|
+
() => {
|
|
247
|
+
t.style.transition = "";
|
|
248
|
+
},
|
|
249
|
+
{ once: !0 }
|
|
250
|
+
);
|
|
251
|
+
};
|
|
252
|
+
#y = (t) => {
|
|
253
|
+
this.#o = t.clientX, this.#i = !0, this.#d = Date.now(), this.#e.stop();
|
|
254
|
+
};
|
|
255
|
+
#$ = (t) => {
|
|
256
|
+
this.#i && (this.#r && cancelAnimationFrame(this.#r), this.#r = requestAnimationFrame(() => {
|
|
257
|
+
const e = Math.floor(t.clientX - this.#o);
|
|
258
|
+
if (!this.loop && (e < 0 && this.currentIndex === this.allIndex || e > 0 && this.currentIndex === 0))
|
|
259
|
+
return;
|
|
260
|
+
const i = this.#s + e;
|
|
261
|
+
this.#t.style.transform = `translateX(${i}px)`;
|
|
262
|
+
}), t.preventDefault());
|
|
263
|
+
};
|
|
264
|
+
#I = (t) => {
|
|
265
|
+
if (!this.#i) return;
|
|
266
|
+
const e = Date.now() - this.#d, i = t.clientX - this.#o;
|
|
267
|
+
if (this.#i = !1, i === 0) return;
|
|
268
|
+
let s = "cancel";
|
|
269
|
+
e <= 200 ? i >= 20 ? s = "prev" : i <= -20 && (s = "next") : i >= this.clientWidth / 2 ? s = "prev" : i <= -this.clientWidth / 2 && (s = "next"), s === "cancel" ? this.#g() : this.#a(s), this.#c();
|
|
270
|
+
};
|
|
271
|
+
#c = () => {
|
|
272
|
+
this.autoplay && this.#e.start();
|
|
273
|
+
};
|
|
274
|
+
#n = () => {
|
|
275
|
+
this.#i && (this.#i = !1, this.#g(), this.#c());
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
export {
|
|
279
|
+
A as default
|
|
280
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import e from "../base.js";
|
|
2
|
+
import { $$ as t } from "ph-utils/dom";
|
|
3
|
+
const o = ":host{width:var(--carousel-width, 100%);height:100%;box-sizing:border-box;display:block}:host(.active){display:block}";
|
|
4
|
+
class r extends e {
|
|
5
|
+
static baseName = "carousel-item";
|
|
6
|
+
connectedCallback() {
|
|
7
|
+
this.loadStyleText(o), super.connectedCallback();
|
|
8
|
+
}
|
|
9
|
+
render() {
|
|
10
|
+
return t("slot");
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
r as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
function o(a, l = 3e3) {
|
|
2
|
+
let n = 0, t = !1, e = null;
|
|
3
|
+
function u() {
|
|
4
|
+
t || (t = !0, n = 0, e = requestAnimationFrame(r));
|
|
5
|
+
}
|
|
6
|
+
function f() {
|
|
7
|
+
t = !1, e && (cancelAnimationFrame(e), e = null);
|
|
8
|
+
}
|
|
9
|
+
function r(i) {
|
|
10
|
+
t && (n || (n = i), i - n >= l && (a(), n = i), e = requestAnimationFrame(r));
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
start: u,
|
|
14
|
+
stop: f
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export {
|
|
18
|
+
o as default
|
|
19
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import FormInner from "../form/form_inner";
|
|
2
|
+
export default class Check extends FormInner {
|
|
3
|
+
#private;
|
|
4
|
+
/** 是否选中 */
|
|
5
|
+
private _checked;
|
|
6
|
+
label?: string;
|
|
7
|
+
/** 是否为按钮样式 */
|
|
8
|
+
button: boolean;
|
|
9
|
+
_inputType: string;
|
|
10
|
+
setChecked(isChecked: boolean): void;
|
|
11
|
+
getChecked(): boolean;
|
|
12
|
+
constructor();
|
|
13
|
+
static get observedAttributes(): string[];
|
|
14
|
+
connectedCallback(): void;
|
|
15
|
+
afterInit(): void;
|
|
16
|
+
beforeDestroy(): void;
|
|
17
|
+
render(): DocumentFragment;
|
|
18
|
+
protected attributeChange(name: string, _oldValue: string, newValue: string): void;
|
|
19
|
+
protected checkedChange(): void;
|
|
20
|
+
protected disabledChange(): void;
|
|
21
|
+
_doChangeAction(): void;
|
|
22
|
+
}
|