litos-ui 0.16.1 → 0.17.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 +11 -2
- package/lib/base.js +59 -27
- package/lib/button/index.d.ts +18 -3
- package/lib/button/index.js +65 -68
- package/lib/check/check.d.ts +14 -5
- package/lib/check/check.js +67 -29
- package/lib/check/checkbox.js +5 -12
- package/lib/check/checkbox_group.d.ts +0 -5
- package/lib/check/checkbox_group.js +3 -29
- package/lib/check/index.d.ts +14 -4
- package/lib/check/index.js +48 -28
- package/lib/check/radio.js +6 -14
- package/lib/check/radio_group.d.ts +1 -2
- package/lib/check/radio_group.js +5 -19
- package/lib/check-CksURvTv.js +4 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/form/form_inner.d.ts +17 -10
- package/lib/form/form_inner.js +83 -80
- package/lib/form/form_item.d.ts +23 -23
- package/lib/form/form_item.js +107 -90
- package/lib/form/index.d.ts +21 -14
- package/lib/form/index.js +92 -70
- package/lib/form/types.d.ts +7 -0
- package/lib/form/types.js +1 -0
- package/lib/index-Blf4-a2-.js +4 -0
- package/lib/index-CrMiSe0x.js +249 -0
- package/lib/index.js +162 -160
- package/lib/input/index.d.ts +24 -25
- package/lib/input/index.js +99 -89
- package/lib/loading/index.d.ts +2 -0
- package/lib/loading/index.js +50 -64
- package/lib/message/index.js +9 -9
- package/lib/modal/index.d.ts +1 -6
- package/lib/modal/index.js +40 -46
- package/lib/select_ori/index.js +1 -1
- package/lib/utils/context_provide.d.ts +9 -0
- package/lib/utils/context_provide.js +22 -0
- package/lib/utils/index.d.ts +2 -0
- package/lib/utils/index.js +41 -33
- package/package.json +8 -8
- package/styles/loading.css +5 -3
- package/lib/check-C7YSuH60.js +0 -4
- package/lib/index-DvcllHRh.js +0 -4
- package/lib/utils/event.d.ts +0 -30
package/lib/base.d.ts
CHANGED
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
export default class BaseComponent extends HTMLElement {
|
|
1
|
+
export default class BaseComponent<T = Record<string, any>> extends HTMLElement {
|
|
2
2
|
static baseName: string;
|
|
3
3
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
4
4
|
rendered: boolean;
|
|
5
|
+
protected _state: T;
|
|
6
|
+
protected _pendingUpdate: boolean;
|
|
7
|
+
protected _pendingTask?: number;
|
|
8
|
+
protected _changedProperties: Set<string>;
|
|
5
9
|
constructor(shadow?: boolean, init?: Partial<ShadowRootInit>);
|
|
6
10
|
/**
|
|
7
11
|
* 返回一个数组,表示观察的属性列表
|
|
8
12
|
*/
|
|
9
13
|
static get observedAttributes(): string[] | undefined | null;
|
|
10
|
-
attributeChangedCallback(
|
|
14
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
15
|
+
protected attributeChanged(name: string, oldValue: string, newValue: string): void;
|
|
16
|
+
cancelPending(): void;
|
|
17
|
+
batchUpdate(): void;
|
|
18
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
11
19
|
/** @deprecated */
|
|
12
20
|
get shadow(): ShadowRoot;
|
|
13
21
|
get root(): ShadowRoot | HTMLElement;
|
|
@@ -52,4 +60,5 @@ export default class BaseComponent extends HTMLElement {
|
|
|
52
60
|
* @returns 是否成功触发事件
|
|
53
61
|
*/
|
|
54
62
|
emit(name: string, eventOption?: Partial<CustomEventInit>): boolean;
|
|
63
|
+
emitInject(name: string, callback: (context: Signal<any>) => void): void;
|
|
55
64
|
}
|
package/lib/base.js
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
import { getAttr as
|
|
2
|
-
class
|
|
1
|
+
import { getAttr as i } from "ph-utils/dom";
|
|
2
|
+
class a extends HTMLElement {
|
|
3
3
|
static baseName = "base-component";
|
|
4
4
|
/** 组件是否渲染完成, 是否已经调用 connectedCallback */
|
|
5
|
-
rendered
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
rendered;
|
|
6
|
+
// state
|
|
7
|
+
_state;
|
|
8
|
+
// 是否正在批量更新
|
|
9
|
+
_pendingUpdate;
|
|
10
|
+
_pendingTask;
|
|
11
|
+
// 延迟任务id
|
|
12
|
+
_changedProperties;
|
|
13
|
+
// 已改变的属性集合
|
|
14
|
+
constructor(e = !0, t = {}) {
|
|
15
|
+
super(), this.rendered = !1, this._state = {}, this._pendingUpdate = !1, this._changedProperties = /* @__PURE__ */ new Set(), e && this.attachShadow({ mode: "open", ...t });
|
|
8
16
|
}
|
|
9
17
|
/**
|
|
10
18
|
* 返回一个数组,表示观察的属性列表
|
|
@@ -13,7 +21,21 @@ class i extends HTMLElement {
|
|
|
13
21
|
return [];
|
|
14
22
|
}
|
|
15
23
|
// 当属性发生变化时调用的回调函数
|
|
16
|
-
attributeChangedCallback(
|
|
24
|
+
attributeChangedCallback(e, t, n) {
|
|
25
|
+
t !== n && (this.attributeChanged(e, t, n), this._changedProperties.add(e), this.rendered && this.batchUpdate());
|
|
26
|
+
}
|
|
27
|
+
attributeChanged(e, t, n) {
|
|
28
|
+
}
|
|
29
|
+
cancelPending() {
|
|
30
|
+
this._pendingTask && (cancelAnimationFrame(this._pendingTask), this._pendingTask = void 0, this._pendingUpdate = !1);
|
|
31
|
+
}
|
|
32
|
+
batchUpdate() {
|
|
33
|
+
this._pendingUpdate || (this.cancelPending(), this._pendingUpdate = !0, requestAnimationFrame(() => {
|
|
34
|
+
const e = new Set(this._changedProperties);
|
|
35
|
+
this._changedProperties.clear(), this.updateDOM(e), this._pendingUpdate = !1;
|
|
36
|
+
}));
|
|
37
|
+
}
|
|
38
|
+
updateDOM(e) {
|
|
17
39
|
}
|
|
18
40
|
/** @deprecated */
|
|
19
41
|
get shadow() {
|
|
@@ -22,33 +44,33 @@ class i extends HTMLElement {
|
|
|
22
44
|
get root() {
|
|
23
45
|
return this.shadowRoot || this;
|
|
24
46
|
}
|
|
25
|
-
createStyle(
|
|
26
|
-
const
|
|
27
|
-
|
|
47
|
+
createStyle(e) {
|
|
48
|
+
const t = document.createElement("style");
|
|
49
|
+
t.textContent = e.trim(), this.root.appendChild(t);
|
|
28
50
|
}
|
|
29
|
-
createLink(
|
|
30
|
-
const
|
|
31
|
-
|
|
51
|
+
createLink(e) {
|
|
52
|
+
const t = document.createElement("link");
|
|
53
|
+
t.rel = "stylesheet", t.href = e, this.root.appendChild(t);
|
|
32
54
|
}
|
|
33
|
-
loadStyleText(
|
|
34
|
-
let
|
|
35
|
-
Array.isArray(
|
|
55
|
+
loadStyleText(e) {
|
|
56
|
+
let t = e;
|
|
57
|
+
Array.isArray(t) && (t = t.join("")), this.createStyle(t);
|
|
36
58
|
}
|
|
37
|
-
getAttr(
|
|
38
|
-
return
|
|
59
|
+
getAttr(e, t) {
|
|
60
|
+
return i(this, e, t);
|
|
39
61
|
}
|
|
40
|
-
appendToRoot(
|
|
41
|
-
if (
|
|
42
|
-
if (typeof
|
|
43
|
-
let
|
|
44
|
-
|
|
45
|
-
} else
|
|
62
|
+
appendToRoot(e) {
|
|
63
|
+
if (e)
|
|
64
|
+
if (typeof e == "string") {
|
|
65
|
+
let t = document.createElement("div");
|
|
66
|
+
t.innerHTML = e, this.root.append(...t.childNodes), t = void 0;
|
|
67
|
+
} else e.length ? this.root.append(...e) : this.root.append(e);
|
|
46
68
|
}
|
|
47
69
|
connectedCallback() {
|
|
48
70
|
this.appendToRoot(this.render()), this.rendered = !0, this.initEvents(), this.afterInit();
|
|
49
71
|
}
|
|
50
72
|
disconnectedCallback() {
|
|
51
|
-
this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
|
|
73
|
+
this.cancelPending(), this.removeEvents(), this.beforeDestroy(), this.root.innerHTML = "", this.rendered = !1;
|
|
52
74
|
}
|
|
53
75
|
render() {
|
|
54
76
|
}
|
|
@@ -75,12 +97,22 @@ class i extends HTMLElement {
|
|
|
75
97
|
* @param eventOption 自定义事件配置选项, 默认: bubbles: true
|
|
76
98
|
* @returns 是否成功触发事件
|
|
77
99
|
*/
|
|
78
|
-
emit(
|
|
100
|
+
emit(e, t) {
|
|
79
101
|
return this.dispatchEvent(
|
|
80
|
-
new CustomEvent(
|
|
102
|
+
new CustomEvent(e, { bubbles: !0, composed: !1, ...t })
|
|
81
103
|
);
|
|
82
104
|
}
|
|
105
|
+
emitInject(e, t) {
|
|
106
|
+
this.emit(e, {
|
|
107
|
+
bubbles: !0,
|
|
108
|
+
composed: !0,
|
|
109
|
+
detail: {
|
|
110
|
+
context: e,
|
|
111
|
+
callback: t
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
83
115
|
}
|
|
84
116
|
export {
|
|
85
|
-
|
|
117
|
+
a as default
|
|
86
118
|
};
|
package/lib/button/index.d.ts
CHANGED
|
@@ -1,13 +1,28 @@
|
|
|
1
1
|
import BaseComponent from "../base";
|
|
2
|
-
|
|
2
|
+
type ButtonState = {
|
|
3
|
+
loading: boolean;
|
|
4
|
+
htmlType: string;
|
|
5
|
+
text: boolean;
|
|
6
|
+
ghost: boolean;
|
|
7
|
+
color?: string;
|
|
8
|
+
height?: string;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
type: "normal" | "primary";
|
|
11
|
+
shape: "default" | "round" | "circle";
|
|
12
|
+
loadingText: string;
|
|
13
|
+
};
|
|
14
|
+
export default class Button extends BaseComponent<ButtonState> {
|
|
3
15
|
static baseName: string;
|
|
4
16
|
_disabled: boolean;
|
|
17
|
+
$btn?: HTMLButtonElement;
|
|
18
|
+
constructor();
|
|
5
19
|
get disabled(): boolean;
|
|
6
20
|
set disabled(value: boolean);
|
|
7
21
|
setLoading(loading: boolean): void;
|
|
8
22
|
setDisabled(value: boolean): void;
|
|
9
23
|
static get observedAttributes(): string[];
|
|
10
|
-
|
|
24
|
+
protected attributeChanged(name: string, _oldValue: string, newValue: string): void;
|
|
25
|
+
protected updateDOM(changedProps: Set<string>): void;
|
|
11
26
|
connectedCallback(): void;
|
|
12
27
|
disconnectedCallback(): void;
|
|
13
28
|
isFormButton(): boolean;
|
|
@@ -17,5 +32,5 @@ export default class Button extends BaseComponent {
|
|
|
17
32
|
applyColor(color: string, text?: boolean, ghost?: boolean): string;
|
|
18
33
|
private _updateHeight;
|
|
19
34
|
private _handleClick;
|
|
20
|
-
private _getForm;
|
|
21
35
|
}
|
|
36
|
+
export {};
|
package/lib/button/index.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { kebabToCamel as b, parseAttrValue as d, initAttr as c } from "../utils/index.js";
|
|
2
2
|
import h from "../base.js";
|
|
3
|
-
import {
|
|
4
|
-
import { adjust as
|
|
5
|
-
import { a as
|
|
6
|
-
const
|
|
7
|
-
class
|
|
3
|
+
import { addClass as p, removeClass as g, on as v, off as f, formatClass as u, formatStyle as m } from "ph-utils/dom";
|
|
4
|
+
import { adjust as i } from "ph-utils/color";
|
|
5
|
+
import { a as k } from "../animation-DttknHkX.js";
|
|
6
|
+
const x = ":host{--l-btn-padding: 0 15px;--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;--l-btn-height: var(--l-form-control-height, 32px);display:inline-flex;width:auto;height:var(--l-btn-height);text-indent:0;box-sizing:border-box;border-radius:var(--l-border-radius, 3px)}: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:var(--l-btn-padding);line-height:1;height:100%;border-radius:inherit;color:var(--l-btn-text-color);background:var(--l-btn-background);border:1px solid var(--l-btn-border-color);position:relative;gap:var(--l-btn-gap, 5px);font-size:inherit;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;--l-btn-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-control-height, 32px) / 2)}.l-btn-circle{border-radius:50%;width:var(--l-form-control-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 B extends h {
|
|
8
8
|
static baseName = "button";
|
|
9
9
|
// public htmlType: "submit" | "reset" | "button" = "button";
|
|
10
10
|
_disabled = !1;
|
|
11
|
+
$btn;
|
|
12
|
+
constructor() {
|
|
13
|
+
super(), this._state = {
|
|
14
|
+
loading: !1,
|
|
15
|
+
htmlType: "button",
|
|
16
|
+
text: !1,
|
|
17
|
+
ghost: !1,
|
|
18
|
+
disabled: !1,
|
|
19
|
+
type: "normal",
|
|
20
|
+
shape: "default",
|
|
21
|
+
loadingText: "加载中……"
|
|
22
|
+
};
|
|
23
|
+
}
|
|
11
24
|
get disabled() {
|
|
12
25
|
return this._disabled;
|
|
13
26
|
}
|
|
@@ -15,111 +28,95 @@ class H extends h {
|
|
|
15
28
|
this.setDisabled(t);
|
|
16
29
|
}
|
|
17
30
|
setLoading(t) {
|
|
18
|
-
|
|
19
|
-
r && (t ? (g(r, "l-btn-loading"), r.disabled = !0, r.innerHTML = this.loadingBody()) : (f(r, "l-btn-loading"), r.disabled = this.disabled, r.innerHTML = "<slot></slot>"));
|
|
31
|
+
this.$btn && (t ? (p(this.$btn, "l-btn-loading"), this.$btn.disabled = !0, this.$btn.innerHTML = this.loadingBody()) : (g(this.$btn, "l-btn-loading"), this.$btn.disabled = this.disabled, this.$btn.innerHTML = "<slot></slot>"));
|
|
20
32
|
}
|
|
21
33
|
setDisabled(t) {
|
|
22
|
-
this._disabled = t;
|
|
23
|
-
const r = b(".l-btn", this.root);
|
|
24
|
-
r && (r.disabled = t);
|
|
34
|
+
this._disabled = t, this.$btn && (this.$btn.disabled = t);
|
|
25
35
|
}
|
|
26
36
|
// 初始化属性观察器
|
|
27
37
|
static get observedAttributes() {
|
|
28
|
-
return ["loading", "color", "disabled", "height"];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
38
|
+
return ["loading", "color", "text", "ghost", "disabled", "height", "html-type", "type", "shape", "loading-text"];
|
|
39
|
+
}
|
|
40
|
+
attributeChanged(t, r, o) {
|
|
41
|
+
switch (t) {
|
|
42
|
+
case "color":
|
|
43
|
+
case "height":
|
|
44
|
+
case "shape":
|
|
45
|
+
case "type":
|
|
46
|
+
this._state[t] = o;
|
|
47
|
+
break;
|
|
48
|
+
case "text":
|
|
49
|
+
case "ghost":
|
|
50
|
+
case "disabled":
|
|
51
|
+
case "loading":
|
|
52
|
+
this._state[t] = d(o, !1, t);
|
|
53
|
+
break;
|
|
54
|
+
case "html-type":
|
|
55
|
+
case "loading-text":
|
|
56
|
+
this._state[b(t)] = o;
|
|
57
|
+
break;
|
|
47
58
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
t
|
|
59
|
+
}
|
|
60
|
+
updateDOM(t) {
|
|
61
|
+
this.$btn && (t.has("loading") && this.setLoading(this._state.loading), t.has("disabled") && this.setDisabled(this.disabled), t.has("color") && this._state.color && (this.$btn.style.cssText = this.applyColor(this._state.color, this._state.text, this._state.ghost))), t.has("height") && this._updateHeight(this._state.height);
|
|
51
62
|
}
|
|
52
63
|
connectedCallback() {
|
|
53
|
-
c(this), this.loadStyleText([
|
|
64
|
+
c(this), this.loadStyleText([k, x]), this.render(), this.isFormButton() && v(this, "click", this._handleClick), this._updateHeight(this._state.height);
|
|
54
65
|
}
|
|
55
66
|
disconnectedCallback() {
|
|
56
|
-
super.disconnectedCallback(), this.isFormButton() &&
|
|
67
|
+
super.disconnectedCallback(), this.isFormButton() && f(this, "click", this._handleClick), this.$btn = void 0;
|
|
57
68
|
}
|
|
58
69
|
isFormButton() {
|
|
59
70
|
const t = this.getHtmlType();
|
|
60
71
|
return t === "submit" || t === "reset";
|
|
61
72
|
}
|
|
62
73
|
getHtmlType() {
|
|
63
|
-
return this.
|
|
74
|
+
return this._state.htmlType;
|
|
64
75
|
}
|
|
65
76
|
render() {
|
|
66
|
-
const t = this.
|
|
77
|
+
const t = this._state.type, r = document.createElement("button"), o = this._state.loading, e = this._state.shape, l = this._state.text, a = this._state.ghost, s = [
|
|
67
78
|
"l-btn",
|
|
68
79
|
`l-btn-${t}`,
|
|
69
80
|
e === "round" ? "l-btn-round" : "",
|
|
70
81
|
e === "circle" ? "l-btn-circle" : "",
|
|
71
|
-
|
|
72
|
-
|
|
82
|
+
a ? "l-btn-ghost" : "",
|
|
83
|
+
l ? "l-btn-text" : "",
|
|
73
84
|
o ? "l-btn-loading" : ""
|
|
74
85
|
];
|
|
75
|
-
r.className = u(
|
|
76
|
-
const
|
|
77
|
-
|
|
86
|
+
r.className = u(s), (this.disabled || o) && (r.disabled = !0), r.type = this._state.htmlType;
|
|
87
|
+
const n = this.applyColor(this._state.color || "", l, a);
|
|
88
|
+
n && (r.style.cssText = n), o ? r.innerHTML = this.loadingBody() : r.innerHTML = "<slot></slot>", r.setAttribute("part", "default"), this.$btn = r, this.root.appendChild(r);
|
|
78
89
|
}
|
|
79
90
|
loadingBody() {
|
|
80
|
-
const t = this.
|
|
81
|
-
console.log(t);
|
|
91
|
+
const t = this._state.loadingText, r = ['<l-loading-icon class="l-rotate-anim"></l-loading-icon>'];
|
|
82
92
|
return t ? r.push(`<span>${t}</span>`) : r.push("<slot></slot>"), r.join("");
|
|
83
93
|
}
|
|
84
94
|
applyColor(t, r = !1, o = !1) {
|
|
85
95
|
if (!t) return "";
|
|
86
|
-
const e =
|
|
96
|
+
const e = i(t, 1, !0), l = i(t, 3, !1);
|
|
87
97
|
return m({
|
|
88
98
|
"--l-btn-border-color": r ? "transparent" : t,
|
|
89
99
|
"--l-btn-text-color": o || r ? t : "#ffffff",
|
|
90
100
|
"--l-btn-hover-text-color": o || r ? e : "#ffffff",
|
|
91
101
|
"--l-btn-background": o || r ? "transparent" : t,
|
|
92
|
-
"--l-btn-active-text-color": o || r ?
|
|
102
|
+
"--l-btn-active-text-color": o || r ? l : "#ffffff",
|
|
93
103
|
"--l-btn-hover-border-color": r ? "transparent" : e,
|
|
94
104
|
"--l-btn-hover-background": o || r ? "transparent" : e,
|
|
95
|
-
"--l-btn-active-background": o || r ? "transparent" :
|
|
96
|
-
"--l-btn-active-border-color": r ? "transparent" :
|
|
105
|
+
"--l-btn-active-background": o || r ? "transparent" : l,
|
|
106
|
+
"--l-btn-active-border-color": r ? "transparent" : l
|
|
97
107
|
});
|
|
98
108
|
}
|
|
99
109
|
_updateHeight(t) {
|
|
100
110
|
t && (typeof t == "number" && (t = `${t}px`), this.style.setProperty("--l-btn-height", t));
|
|
101
111
|
}
|
|
102
|
-
_handleClick = (
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
112
|
+
_handleClick = () => {
|
|
113
|
+
(this._state.htmlType === "reset" || this._state.htmlType === "submit") && this.emit("form-action", {
|
|
114
|
+
bubbles: !0,
|
|
115
|
+
composed: !0,
|
|
116
|
+
detail: this._state.htmlType
|
|
117
|
+
});
|
|
108
118
|
};
|
|
109
|
-
_getForm() {
|
|
110
|
-
let t = this.parentElement, r;
|
|
111
|
-
for (; t != null; ) {
|
|
112
|
-
const o = t.tagName;
|
|
113
|
-
if (o === "L-FORM") {
|
|
114
|
-
r = t;
|
|
115
|
-
break;
|
|
116
|
-
}
|
|
117
|
-
if (o === "BODY") break;
|
|
118
|
-
t = t.parentElement;
|
|
119
|
-
}
|
|
120
|
-
return t = null, r;
|
|
121
|
-
}
|
|
122
119
|
}
|
|
123
120
|
export {
|
|
124
|
-
|
|
121
|
+
B as default
|
|
125
122
|
};
|
package/lib/check/check.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import FormInner from "../form/form_inner";
|
|
2
|
-
|
|
2
|
+
type CheckState = {
|
|
3
|
+
/** 是否为按钮样式 */
|
|
4
|
+
button: boolean;
|
|
5
|
+
label?: string;
|
|
6
|
+
indeterminate: boolean;
|
|
7
|
+
};
|
|
8
|
+
export default class Check extends FormInner<CheckState> {
|
|
3
9
|
#private;
|
|
4
10
|
/** 是否选中 */
|
|
5
11
|
private _checked;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
12
|
+
_inputType: "radio" | "checkbox";
|
|
13
|
+
$input?: HTMLInputElement;
|
|
14
|
+
_groupCtx?: Signal<string[]>;
|
|
15
|
+
_groupCtxStop?: SignalStop;
|
|
10
16
|
setChecked(isChecked: boolean): void;
|
|
11
17
|
getChecked(): boolean;
|
|
12
18
|
constructor();
|
|
@@ -18,5 +24,8 @@ export default class Check extends FormInner {
|
|
|
18
24
|
protected attributeChange(name: string, _oldValue: string, newValue: string): void;
|
|
19
25
|
protected checkedChange(): void;
|
|
20
26
|
protected disabledChange(): void;
|
|
27
|
+
private _updateIndeterminate;
|
|
28
|
+
emitChange(): void;
|
|
21
29
|
_doChangeAction(): void;
|
|
22
30
|
}
|
|
31
|
+
export {};
|
package/lib/check/check.js
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
|
+
import { e as l } from "../index-CrMiSe0x.js";
|
|
1
2
|
import d from "../form/form_inner.js";
|
|
2
|
-
import {
|
|
3
|
-
import { addClass as
|
|
4
|
-
class
|
|
3
|
+
import { stopSignal as o, parseAttrValue as c } from "../utils/index.js";
|
|
4
|
+
import { addClass as n, on as u, off as p, $$ as i, removeClass as r, toggleClass as k } from "ph-utils/dom";
|
|
5
|
+
class f extends d {
|
|
5
6
|
/** 是否选中 */
|
|
6
|
-
_checked
|
|
7
|
-
|
|
8
|
-
/** 是否为按钮样式 */
|
|
9
|
-
button = !1;
|
|
10
|
-
_inputType = "radio";
|
|
7
|
+
_checked;
|
|
8
|
+
_inputType;
|
|
11
9
|
// input类型
|
|
10
|
+
$input;
|
|
11
|
+
_groupCtx;
|
|
12
|
+
_groupCtxStop;
|
|
12
13
|
setChecked(e) {
|
|
13
14
|
this._checked = e, this.checkedChange();
|
|
14
15
|
}
|
|
@@ -16,7 +17,7 @@ class m extends d {
|
|
|
16
17
|
return this._checked;
|
|
17
18
|
}
|
|
18
19
|
constructor() {
|
|
19
|
-
super(), Object.defineProperty(this, "checked", {
|
|
20
|
+
super(), this._checked = !1, this._inputType = "radio", Object.defineProperty(this, "checked", {
|
|
20
21
|
configurable: !0,
|
|
21
22
|
enumerable: !0,
|
|
22
23
|
get: this.getChecked,
|
|
@@ -24,57 +25,94 @@ class m extends d {
|
|
|
24
25
|
});
|
|
25
26
|
}
|
|
26
27
|
static get observedAttributes() {
|
|
27
|
-
return ["
|
|
28
|
+
return ["checked", "label", "button", "indeterminate", ...d.observedAttributes];
|
|
28
29
|
}
|
|
29
30
|
connectedCallback() {
|
|
30
|
-
|
|
31
|
+
super.connectedCallback(), this.getChecked() && this.setChecked(!0), this.isDisabled() && n(this, "is-disabled"), this._updateIndeterminate(), this.emitInject("check-context-request", (e) => {
|
|
32
|
+
this._groupCtx = e;
|
|
33
|
+
}), this._groupCtxStop = l(() => {
|
|
34
|
+
if (this.value == null) return;
|
|
35
|
+
const e = this._groupCtx ? this._groupCtx() : [];
|
|
36
|
+
this.setChecked(e.includes(this.value));
|
|
37
|
+
});
|
|
31
38
|
}
|
|
32
39
|
afterInit() {
|
|
33
|
-
|
|
40
|
+
u(this, "click", this.#e);
|
|
34
41
|
}
|
|
35
42
|
beforeDestroy() {
|
|
36
|
-
|
|
43
|
+
p(this, "click", this.#e), this._groupCtxStop = o(this._groupCtxStop);
|
|
37
44
|
}
|
|
38
45
|
render() {
|
|
39
|
-
const e = document.createDocumentFragment(),
|
|
46
|
+
const e = document.createDocumentFragment(), s = i("input", {
|
|
40
47
|
type: this._inputType,
|
|
41
48
|
class: "l-check__input",
|
|
42
49
|
name: this.getName(),
|
|
43
50
|
value: this.value,
|
|
44
|
-
checked: this.getChecked()
|
|
51
|
+
checked: this.getChecked(),
|
|
52
|
+
disabled: this.isDisabled() ? "disabled" : void 0
|
|
45
53
|
});
|
|
46
|
-
if (this
|
|
54
|
+
if (this.$input = s, e.appendChild(s), !this._state.button) {
|
|
47
55
|
const a = i("span", { class: "l-check__inner" });
|
|
48
56
|
e.appendChild(a);
|
|
49
57
|
}
|
|
50
58
|
const t = i("label", {
|
|
51
59
|
class: "l-check__label",
|
|
52
60
|
part: "label"
|
|
53
|
-
}),
|
|
54
|
-
textContent: this.label
|
|
61
|
+
}), h = i("slot", {
|
|
62
|
+
textContent: this._state.label
|
|
55
63
|
});
|
|
56
|
-
return t.appendChild(
|
|
64
|
+
return t.appendChild(h), e.appendChild(t), e;
|
|
57
65
|
}
|
|
58
|
-
attributeChange(e,
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
attributeChange(e, s, t) {
|
|
67
|
+
switch (e) {
|
|
68
|
+
case "checked":
|
|
69
|
+
const h = c(t, !1, "checked");
|
|
70
|
+
this.setChecked(h);
|
|
71
|
+
break;
|
|
72
|
+
case "button":
|
|
73
|
+
this._state[e] = c(t, !1, e);
|
|
74
|
+
break;
|
|
75
|
+
case "indeterminate":
|
|
76
|
+
const a = c(t, !1, e);
|
|
77
|
+
this._state.indeterminate = a, this._updateIndeterminate();
|
|
78
|
+
break;
|
|
79
|
+
case "label":
|
|
80
|
+
this._state.label = t;
|
|
81
|
+
break;
|
|
62
82
|
}
|
|
63
83
|
}
|
|
64
84
|
checkedChange() {
|
|
65
|
-
this.getChecked() ?
|
|
66
|
-
const e = u("input", this.root);
|
|
67
|
-
e && (e.checked = this._checked);
|
|
85
|
+
this.getChecked() ? n(this, "is-checked") : r(this, "is-checked"), this.$input && (this.$input.checked = this.getChecked());
|
|
68
86
|
}
|
|
69
87
|
disabledChange() {
|
|
70
|
-
|
|
88
|
+
k(this, "is-disabled"), this.$input && (this.$input.disabled = this.isDisabled());
|
|
89
|
+
}
|
|
90
|
+
_updateIndeterminate() {
|
|
91
|
+
this._state.indeterminate ? n(this, "is-indeterminate") : r(this, "is-indeterminate");
|
|
71
92
|
}
|
|
72
93
|
#e = () => {
|
|
73
|
-
this.isDisabled()
|
|
94
|
+
if (!this.isDisabled())
|
|
95
|
+
if (this.value && this._groupCtx)
|
|
96
|
+
this.emitChange();
|
|
97
|
+
else {
|
|
98
|
+
const e = this._inputType === "radio" ? !0 : !this.getChecked();
|
|
99
|
+
this.setChecked(e), this.emitChange();
|
|
100
|
+
}
|
|
74
101
|
};
|
|
102
|
+
emitChange() {
|
|
103
|
+
this.emit("change", {
|
|
104
|
+
detail: {
|
|
105
|
+
value: this.value,
|
|
106
|
+
name: this.getName(),
|
|
107
|
+
checked: this.getChecked()
|
|
108
|
+
},
|
|
109
|
+
composed: !0,
|
|
110
|
+
bubbles: !0
|
|
111
|
+
});
|
|
112
|
+
}
|
|
75
113
|
_doChangeAction() {
|
|
76
114
|
}
|
|
77
115
|
}
|
|
78
116
|
export {
|
|
79
|
-
|
|
117
|
+
f as default
|
|
80
118
|
};
|
package/lib/check/checkbox.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import e from "./check.js";
|
|
2
|
-
import { c as r } from "../check-
|
|
3
|
-
const o = '.l-check__inner
|
|
4
|
-
class
|
|
2
|
+
import { c as r } from "../check-CksURvTv.js";
|
|
3
|
+
const o = ':host(.is-indeterminate) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host(.is-indeterminate) .l-check__inner:after{content:"";width:calc(var(--l-check-size) * .4);height:1px;display:block;border:1px solid #fff;border-right:none;border-top:none;border-left:none;transform:rotate(0);margin-top:0}.l-check__inner:after,:host(.is-checked) .l-check__inner:after{content:"";width:calc(var(--l-check-size) * .6);height:calc(var(--l-check-size) * .3);display:block;border:solid 1px transparent;border-right:none;border-top:none;transform:rotate(-45deg);transition:border-color .2s ease-in-out;margin-top:-3px}:host(.is-checked) .l-check__inner{background-color:var(--l-primary-color, #722ed1)}:host(.is-checked) .l-check__inner:after{border-color:#fff}:host(.is-disabled) .l-check__inner{background-color:var(--l-disabled-color, #e6e6e6);border-color:var(--l-disabled-color, #e6e6e6)}';
|
|
4
|
+
class i extends e {
|
|
5
5
|
static baseName = "checkbox";
|
|
6
6
|
constructor() {
|
|
7
7
|
super(), this._inputType = "checkbox";
|
|
@@ -10,16 +10,9 @@ class a extends e {
|
|
|
10
10
|
this.loadStyleText([r, o]), super.connectedCallback();
|
|
11
11
|
}
|
|
12
12
|
_doChangeAction() {
|
|
13
|
-
this.getChecked() ? this.
|
|
14
|
-
detail: {
|
|
15
|
-
value: this.value,
|
|
16
|
-
name: this.getName(),
|
|
17
|
-
checked: this.getChecked()
|
|
18
|
-
},
|
|
19
|
-
composed: !0
|
|
20
|
-
});
|
|
13
|
+
this.getChecked() ? this.setChecked(!1) : this.setChecked(!0), this.emitChange();
|
|
21
14
|
}
|
|
22
15
|
}
|
|
23
16
|
export {
|
|
24
|
-
|
|
17
|
+
i as default
|
|
25
18
|
};
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import CheckGroup from ".";
|
|
2
2
|
export default class CheckboxGroup extends CheckGroup {
|
|
3
3
|
static baseName: string;
|
|
4
|
-
set value(value: string);
|
|
5
|
-
get value(): string;
|
|
6
|
-
afterInit(): void;
|
|
7
|
-
protected updateChangedStatus(): void;
|
|
8
|
-
valueChange(value: string): void;
|
|
9
4
|
}
|