litos-ui 0.8.0 → 0.10.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.js +26 -30
- package/lib/button/index.js +55 -59
- package/lib/checkbox/index.d.ts +17 -0
- package/lib/checkbox/index.js +135 -0
- package/lib/color_picker/index.js +17 -21
- package/lib/form/form_inner.js +46 -49
- package/lib/form/form_item.js +49 -54
- package/lib/form/index.js +62 -66
- package/lib/icon/arrow_down.js +4 -7
- package/lib/icon/arrow_left.js +4 -7
- package/lib/icon/arrow_right.js +4 -7
- package/lib/icon/arrow_up.js +4 -7
- package/lib/icon/base.js +21 -25
- package/lib/icon/caret_bottom.js +4 -7
- package/lib/icon/caret_top.js +4 -7
- package/lib/icon/font_icon.js +13 -17
- package/lib/icon/info.js +4 -7
- package/lib/icon/loading.js +4 -7
- package/lib/icon/mask_close.js +4 -7
- package/lib/icon/moon.js +4 -7
- package/lib/icon/reduction.js +4 -7
- package/lib/icon/refresh_left.js +4 -7
- package/lib/icon/refresh_right.js +4 -7
- package/lib/icon/search.js +4 -7
- package/lib/icon/sort.js +4 -7
- package/lib/icon/success.js +4 -7
- package/lib/icon/sun.js +4 -7
- package/lib/icon/theme_default.js +4 -7
- package/lib/icon/warn.js +4 -7
- package/lib/index.d.ts +4 -0
- package/lib/index.js +30 -26
- package/lib/input/index.js +66 -71
- package/lib/list/index.js +23 -27
- package/lib/litos-ui.css +1 -1
- package/lib/litos-ui.min.js +1 -1
- package/lib/md_input/index.d.ts +15 -0
- package/lib/md_input/index.js +60 -0
- package/lib/polygon/index.js +14 -18
- package/lib/popconfirm/index.js +11 -14
- package/lib/popover/index.js +107 -113
- package/lib/radio/index.js +53 -57
- package/lib/select_ori/index.js +23 -27
- package/lib/switch/index.js +34 -44
- package/lib/tabbar/index.js +117 -126
- package/lib/theme/index.js +71 -74
- package/lib/theme/theme_color.js +17 -27
- package/lib/{form/form_events.d.ts → utils/event.d.ts} +5 -7
- package/lib/utils/event.js +16 -18
- package/lib/utils/index.js +21 -21
- package/lib/utils/transition.js +23 -27
- package/package.json +1 -1
- package/lib/form/form_events.js +0 -24
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { addClass as i, $$ as r, $one as l, on as a, off as d, removeClass as u } from "ph-utils/dom";
|
|
2
|
+
import p from "../form/form_inner.js";
|
|
3
|
+
import { initAttr as m } from "../utils/index.js";
|
|
4
|
+
import { isBlank as s, random as h } from "ph-utils";
|
|
5
|
+
const c = ":host{--l-input-width: 180px;position:relative;width:var(--l-input-width, 180px);height:var(--l-form-edit-height, 32px);display:inline-block}.l-md-input__inner{width:100%;height:100%;border:0;background:transparent;border-style:solid;border-color:silver;border-bottom-width:1px;box-sizing:border-box;outline:none;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{transform:translate3d(0,-150%,0);font-size:12px}.l-md-input__inner:focus+.l-md-input__label{color:var(--nt-primary-color, #722ed1)}.l-md-input__label{display:flex;align-items:center;position:absolute;top:50%;bottom:0;left:0;transition:color .3s,transform .3s;color:#8c8c8c;cursor:text;line-height:1;transform:translate3d(0,-50%,0);font-size:13px}:host(.l-md-input-outline){--l-input-label-background: #ffffff}: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{padding-left:4px;padding-right:4px;background-color:#fff}";
|
|
6
|
+
class v extends p {
|
|
7
|
+
static baseName = "md-input";
|
|
8
|
+
/** 是否显示四周边框 */
|
|
9
|
+
outline = !1;
|
|
10
|
+
htmlType = "text";
|
|
11
|
+
inputmode;
|
|
12
|
+
label;
|
|
13
|
+
static get observedAttributes() {
|
|
14
|
+
return ["disabled"];
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
m(this), this.loadStyleText(c), super.connectedCallback(), this.#e();
|
|
18
|
+
}
|
|
19
|
+
disconnectedCallback() {
|
|
20
|
+
super.disconnectedCallback(), this.#n();
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
s(this.value) || i(this, "l-has-value"), this.outline && i(this, "l-md-input-outline");
|
|
24
|
+
const t = document.createDocumentFragment(), e = `l-md-input-${h(8)}`, n = r("input", {
|
|
25
|
+
class: "l-md-input__inner",
|
|
26
|
+
type: this.htmlType,
|
|
27
|
+
name: this.name,
|
|
28
|
+
inputmode: this.inputmode,
|
|
29
|
+
id: e
|
|
30
|
+
});
|
|
31
|
+
if (t.appendChild(n), this.label) {
|
|
32
|
+
const o = r("label", {
|
|
33
|
+
class: "l-md-input__label",
|
|
34
|
+
for: e
|
|
35
|
+
});
|
|
36
|
+
o.textContent = this.label, t.appendChild(o);
|
|
37
|
+
}
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
setValue(t) {
|
|
41
|
+
super.setValue(t);
|
|
42
|
+
const e = l("input", this.root);
|
|
43
|
+
e && (e.value = t);
|
|
44
|
+
}
|
|
45
|
+
#e() {
|
|
46
|
+
const t = l("input", this.root);
|
|
47
|
+
t && a(t, "input", this.#t);
|
|
48
|
+
}
|
|
49
|
+
#n() {
|
|
50
|
+
const t = l("input", this.root);
|
|
51
|
+
t && d(t, "input", this.#t);
|
|
52
|
+
}
|
|
53
|
+
#t = (t) => {
|
|
54
|
+
const n = t.target.value;
|
|
55
|
+
this.setValue(n), s(n) ? u(this, "l-has-value") : i(this, "l-has-value");
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
export {
|
|
59
|
+
v as default
|
|
60
|
+
};
|
package/lib/polygon/index.js
CHANGED
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { formatClass as t, formatStyle as e } from "ph-utils/dom";
|
|
2
|
+
import g from "../base.js";
|
|
3
|
+
import { initAttr as n } from "../utils/index.js";
|
|
4
|
+
const p = ".l-polygon{--l-polygen-size: 10px;--l-polygen-width: var(--l-polygen-size);--l-polygen-height: var(--l-polygen-size);--l-polygen-background: #666;display:inline-block;width:var(--l-polygen-width);height:var(--l-polygen-height);background:var(--l-polygen-background);transition:background .3s ease-in-out}.l-polygon-triangle-top{clip-path:polygon(calc(var(--l-polygen-width) / 2) 0,var(--l-polygen-width) var(--l-polygen-height),0 var(--l-polygen-height))}.l-polygon-triangle-top-left{clip-path:polygon(0 0,var(--l-polygen-width) 0,0 var(--l-polygen-height))}.l-polygon-triangle-top-right{clip-path:polygon(0 0,var(--l-polygen-width) 0,var(--l-polygen-width) var(--l-polygen-height))}.l-polygon-triangle-right{clip-path:polygon(0 0,var(--l-polygen-width) calc(var(--l-polygen-height) / 2),0 var(--l-polygen-height))}.l-polygon-triangle-left{clip-path:polygon(var(--l-polygen-width) 0,var(--l-polygen-width) var(--l-polygen-height),0 calc(var(--l-polygen-height) / 2))}.l-polygon-triangle-bottom{clip-path:polygon(0 0,var(--l-polygen-width) 0,calc(var(--l-polygen-width) / 2) var(--l-polygen-height))}.l-polygon-triangle-bottom-left{clip-path:polygon(0 0,0 var(--l-polygen-height),var(--l-polygen-width) var(--l-polygen-height))}.l-polygon-triangle-bottom-right{clip-path:polygon(var(--l-polygen-width) 0,var(--l-polygen-width) var(--l-polygen-height),0 var(--l-polygen-height))}";
|
|
5
|
+
class y extends g {
|
|
6
|
+
static baseName = "polygon";
|
|
7
|
+
shape = "triangle-top";
|
|
8
|
+
background;
|
|
9
9
|
constructor() {
|
|
10
|
-
super();
|
|
11
|
-
e(this, "shape", "triangle-top");
|
|
12
|
-
e(this, "background");
|
|
13
|
-
h(this);
|
|
10
|
+
super(), n(this);
|
|
14
11
|
}
|
|
15
12
|
connectedCallback() {
|
|
16
|
-
this.loadStyleText(
|
|
13
|
+
this.loadStyleText(p), super.connectedCallback();
|
|
17
14
|
}
|
|
18
15
|
render() {
|
|
19
|
-
const
|
|
16
|
+
const l = t([
|
|
20
17
|
"l-polygon",
|
|
21
18
|
this.shape ? `l-polygon-${this.shape}` : ""
|
|
22
|
-
]),
|
|
19
|
+
]), o = e([
|
|
23
20
|
this.background ? `--l-polygen-background: ${this.background}` : ""
|
|
24
21
|
]);
|
|
25
|
-
return `<div part="default" class="${
|
|
22
|
+
return `<div part="default" class="${l}" style="${o}"></div>`;
|
|
26
23
|
}
|
|
27
24
|
}
|
|
28
|
-
e(c, "baseName", "polygon");
|
|
29
25
|
export {
|
|
30
|
-
|
|
26
|
+
y as default
|
|
31
27
|
};
|
package/lib/popconfirm/index.js
CHANGED
|
@@ -1,33 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const f = ".l-popover-popconfirm{min-width:200px}.l-popconfirm-container{display:flex;align-items:center}.l-popconfirm-icon-wrapper{margin-right:10px;display:inline-flex;color:var(--nt-warn-color, #f90)}.l-popconfirm-footer{display:flex;align-items:center;justify-content:flex-end;margin-top:7px;gap:5px}.l-popconfirm-footer l-button::part(default){height:24px;padding:0 6px;font-size:13px}";
|
|
7
|
-
class h extends l {
|
|
1
|
+
import i from "../popover/index.js";
|
|
2
|
+
import { on as e, shouldEventNext as p, $one as c } from "ph-utils/dom";
|
|
3
|
+
const r = ".l-popover-popconfirm{min-width:200px}.l-popconfirm-container{display:flex;align-items:center}.l-popconfirm-icon-wrapper{margin-right:10px;display:inline-flex;color:var(--nt-warn-color, #f90)}.l-popconfirm-footer{display:flex;align-items:center;justify-content:flex-end;margin-top:7px;gap:5px}.l-popconfirm-footer l-button::part(default){height:24px;padding:0 6px;font-size:13px}";
|
|
4
|
+
class f extends i {
|
|
5
|
+
static baseName = "popconfirm";
|
|
8
6
|
constructor() {
|
|
9
7
|
super();
|
|
10
8
|
}
|
|
11
9
|
connectedCallback() {
|
|
12
|
-
this.loadStyleText(
|
|
13
|
-
const [o,
|
|
10
|
+
this.loadStyleText(r), this.trigger = "click", this.theme = "popconfirm", super.connectedCallback(), e(this.root, "click", (t) => {
|
|
11
|
+
const [o, n] = p(t, "l-action", this);
|
|
14
12
|
o && (this.dispatchEvent(
|
|
15
|
-
new CustomEvent(
|
|
13
|
+
new CustomEvent(n, {
|
|
16
14
|
detail: {
|
|
17
|
-
action:
|
|
15
|
+
action: n
|
|
18
16
|
}
|
|
19
17
|
})
|
|
20
18
|
), this.hide());
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
21
|
contentHTML() {
|
|
24
|
-
const t =
|
|
22
|
+
const t = c('[slot="icon"]', this), o = [];
|
|
25
23
|
return o.push('<div class="l-popconfirm-container">'), o.push('<div class="l-popconfirm-icon-wrapper">'), o.push(
|
|
26
24
|
t ? '<slot name="icon"></slot>' : "<l-warn-icon></l-warn-icon>"
|
|
27
25
|
), o.push(`</div>${super.contentHTML()}</div>`), o.push('<div class="l-popconfirm-footer">'), o.push('<l-button l-action="cancel">取消</l-button>'), o.push('<l-button type="primary" l-action="ok">确定</l-button>'), o.push("</div>"), o.join("");
|
|
28
26
|
}
|
|
29
27
|
}
|
|
30
|
-
e(h, "baseName", "popconfirm");
|
|
31
28
|
export {
|
|
32
|
-
|
|
29
|
+
f as default
|
|
33
30
|
};
|
package/lib/popover/index.js
CHANGED
|
@@ -1,59 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import x from "../base.js";
|
|
2
|
+
import { initAttr as k, useId as $, getPopoverOffsetY as C, getPopoverOffsetX as y, impactDetect as z } from "../utils/index.js";
|
|
3
|
+
import { set as T, remove as A } from "../utils/clickoutside.js";
|
|
4
|
+
import { $one as p, $$ as g, on as s, off as i } from "ph-utils/dom";
|
|
5
|
+
const P = ':host{width:max-content;position:relative}.l-popover--content{--l-popover-border-color: #e4e4e4;--l-popover-color: #666666;--l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, .12);--l-popover-background: #ffffff;--l-popover-arrow-size: 8px;--l-popover-offset: 10px;position:absolute;width:max-content;box-shadow:var(--l-popover-box-shadow);background:var(--l-popover-background);border:1px solid var(--l-popover-border-color);border-radius:4px;padding:10px;z-index:30;color:var(--l-popover-color);box-sizing:border-box}.l-popover-tooltip{--l-popover-color: #fff;--l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, .3);--l-popover-background: #383838;--l-popover-arrow-size: 6px;border-radius:5px;padding:8px;font-size:12px;line-height:1}.l-popover--arrow{position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);z-index:-1}.l-popover--arrow:before{content:"";position:absolute;width:var(--l-popover-arrow-size, 8px);height:var(--l-popover-arrow-size, 8px);transform:rotate3d(0,0,1,45deg);background-color:var(--l-popover-background);border-width:1px;border-style:solid}.l-popover-top,.l-popover-top-start,.l-popover-top-end{bottom:calc(100% + var(--l-popover-offset, 10px))}.l-popover-bottom,.l-popover-bottom-start,.l-popover-bottom-end{top:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top-start,.l-popover-bottom-start{left:0}.l-popover-top-end,.l-popover-bottom-end{right:0}.l-popover-bottom,.l-popover-top{left:50%;transform:translate3d(-50%,0,0)}.l-popover-left-start,.l-popover-left,.l-popover-left-end{right:calc(100% + var(--l-popover-offset, 10px))}.l-popover-left-start,.l-popover-right-start{top:0}.l-popover-left-end,.l-popover-right-end{bottom:0}.l-popover-left,.l-popover-right{top:50%;transform:translate3d(0,-50%,0)}.l-popover-right-start,.l-popover-right,.l-popover-right-end{left:calc(100% + var(--l-popover-offset, 10px))}.l-popover-top .l-popover--arrow,.l-popover-bottom .l-popover--arrow{left:50%;margin-left:-4px}.l-popover-top .l-popover--arrow:before,.l-popover-top-start .l-popover--arrow:before,.l-popover-top-end .l-popover--arrow:before{border-color:transparent var(--l-popover-border-color) var(--l-popover-border-color) transparent}.l-popover-bottom .l-popover--arrow:before,.l-popover-bottom-start .l-popover--arrow:before,.l-popover-bottom-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) transparent transparent var(--l-popover-border-color)}.l-popover-top .l-popover--arrow,.l-popover-top-start .l-popover--arrow,.l-popover-top-end .l-popover--arrow{bottom:calc((var(--l-popover-arrow-size, 8px) / -2) + 1px)}.l-popover-top-start .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow{left:10px}.l-popover-top-end .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{right:10px}.l-popover-bottom .l-popover--arrow,.l-popover-bottom-start .l-popover--arrow,.l-popover-bottom-end .l-popover--arrow{top:calc((var(--l-popover-arrow-size, 8px) / -2) - 1px)}.l-popover-left .l-popover--arrow,.l-popover-left-start .l-popover--arrow,.l-popover-left-end .l-popover--arrow{margin-top:-4px;right:-4px}.l-popover-left-start .l-popover--arrow:before,.l-popover-left .l-popover--arrow:before,.l-popover-left-end .l-popover--arrow:before{border-color:var(--l-popover-border-color) var(--l-popover-border-color) transparent transparent}.l-popover-right .l-popover--arrow,.l-popover-right-start .l-popover--arrow,.l-popover-right-end .l-popover--arrow{margin-top:-4px;left:-4px}.l-popover-right-start .l-popover--arrow:before,.l-popover-right .l-popover--arrow:before,.l-popover-right-end .l-popover--arrow:before{border-color:transparent transparent var(--l-popover-border-color) var(--l-popover-border-color)}.l-popover-left .l-popover--arrow,.l-popover-right .l-popover--arrow{top:50%}.l-popover-left-start .l-popover--arrow,.l-popover-right-start .l-popover--arrow{top:10px}.l-popover-left-end .l-popover--arrow,.l-popover-right-end .l-popover--arrow{bottom:10px}';
|
|
6
|
+
class M extends x {
|
|
7
|
+
static baseName = "popover";
|
|
8
|
+
placement = "top";
|
|
9
|
+
content;
|
|
10
|
+
showArrow = !0;
|
|
11
|
+
trigger = "hover";
|
|
12
|
+
disabled = !1;
|
|
13
|
+
isShow = !1;
|
|
14
|
+
/** 宽度, 'trigger' 表示 popover 的宽度会和它的触发元素一致 */
|
|
15
|
+
width;
|
|
16
|
+
/** 隐藏时销毁 DOM 结构 */
|
|
17
|
+
destroyOnHide = !1;
|
|
18
|
+
/** 浮层偏移量 */
|
|
19
|
+
offset;
|
|
20
|
+
/** 浮层定位方式 */
|
|
21
|
+
position = "absolute";
|
|
22
|
+
theme = "default";
|
|
23
|
+
/**
|
|
24
|
+
* @property inline = false
|
|
25
|
+
*/
|
|
26
|
+
_t;
|
|
16
27
|
constructor() {
|
|
17
|
-
super();
|
|
18
|
-
h(this, l);
|
|
19
|
-
t(this, "placement", "top");
|
|
20
|
-
t(this, "content");
|
|
21
|
-
t(this, "showArrow", !0);
|
|
22
|
-
t(this, "trigger", "hover");
|
|
23
|
-
t(this, "disabled", !1);
|
|
24
|
-
t(this, "isShow", !1);
|
|
25
|
-
/** 宽度, 'trigger' 表示 popover 的宽度会和它的触发元素一致 */
|
|
26
|
-
t(this, "width");
|
|
27
|
-
/** 隐藏时销毁 DOM 结构 */
|
|
28
|
-
t(this, "destroyOnHide", !1);
|
|
29
|
-
/** 浮层偏移量 */
|
|
30
|
-
t(this, "offset");
|
|
31
|
-
/** 浮层定位方式 */
|
|
32
|
-
t(this, "position", "absolute");
|
|
33
|
-
t(this, "theme", "default");
|
|
34
|
-
/**
|
|
35
|
-
* @property inline = false
|
|
36
|
-
*/
|
|
37
|
-
t(this, "_t");
|
|
38
|
-
h(this, x, (o) => {
|
|
39
|
-
o.target.id !== this.id && this.hide();
|
|
40
|
-
});
|
|
41
|
-
h(this, a, (o) => {
|
|
42
|
-
this.show(o.target);
|
|
43
|
-
});
|
|
44
|
-
h(this, n, () => {
|
|
45
|
-
this.hide();
|
|
46
|
-
});
|
|
47
|
-
h(this, w, (o) => {
|
|
48
|
-
this.trigger === "click" ? this.toggle(o.target) : this.trigger === "focus" && this.show(o.target);
|
|
49
|
-
});
|
|
50
|
-
D(this);
|
|
28
|
+
super(), k(this);
|
|
51
29
|
}
|
|
52
30
|
connectedCallback() {
|
|
53
|
-
this.loadStyleText(
|
|
31
|
+
this.loadStyleText(P), this.#t(), super.connectedCallback(), this.renderContent(), this.#p();
|
|
54
32
|
}
|
|
55
33
|
disconnectedCallback() {
|
|
56
|
-
super.disconnectedCallback(),
|
|
34
|
+
super.disconnectedCallback(), this.#l();
|
|
57
35
|
}
|
|
58
36
|
render() {
|
|
59
37
|
const o = document.createElement("slot");
|
|
@@ -61,39 +39,63 @@ class Q extends j {
|
|
|
61
39
|
}
|
|
62
40
|
renderContent() {
|
|
63
41
|
if (!this.isShow) return;
|
|
64
|
-
let o =
|
|
42
|
+
let o = p(".l-popover--content", this.root);
|
|
65
43
|
if (o) {
|
|
66
44
|
o.style.removeProperty("display");
|
|
67
45
|
return;
|
|
68
46
|
}
|
|
69
|
-
if (o =
|
|
47
|
+
if (o = g("div", {
|
|
70
48
|
class: [
|
|
71
49
|
"l-popover--content",
|
|
72
50
|
`l-popover-${this.placement}`,
|
|
73
51
|
this.theme === "default" ? void 0 : `l-popover-${this.theme}`
|
|
74
52
|
]
|
|
75
53
|
}), this.offset && (o.style.cssText = "--l-popover-offset: ${this.offset}px;"), o.part = "content", o.innerHTML = this.contentHTML(), this.showArrow) {
|
|
76
|
-
const
|
|
54
|
+
const r = g("div", {
|
|
77
55
|
class: "l-popover--arrow"
|
|
78
56
|
});
|
|
79
|
-
o.appendChild(
|
|
57
|
+
o.appendChild(r);
|
|
80
58
|
}
|
|
81
|
-
this.trigger === "hover" && (
|
|
59
|
+
this.trigger === "hover" && (s(o, "mouseenter", this.#o), s(o, "mouseleave", this.#r)), this.root.appendChild(o);
|
|
82
60
|
}
|
|
83
61
|
contentHTML() {
|
|
84
62
|
return this.content ? `<span>${this.content}</span>` : "<slot></slot>";
|
|
85
63
|
}
|
|
64
|
+
#t() {
|
|
65
|
+
const o = this.getAttr("inline", !1);
|
|
66
|
+
this.style.display = o ? "inline-block" : "block", this.id || (this.id = `${$()}-popover`);
|
|
67
|
+
}
|
|
86
68
|
hideContent() {
|
|
87
|
-
const o =
|
|
88
|
-
o && (this.destroyOnHide ? (this.trigger === "hover" && (
|
|
69
|
+
const o = p(".l-popover--content", this.root);
|
|
70
|
+
o && (this.destroyOnHide ? (this.trigger === "hover" && (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)), this.root.removeChild(o)) : o.style.display = "none");
|
|
71
|
+
}
|
|
72
|
+
#p() {
|
|
73
|
+
const o = p('[slot="trigger"]', this);
|
|
74
|
+
o && (this.trigger === "hover" ? (s(o, "mouseenter", this.#o), s(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (s(o, "click", this.#e), T(o, this.#s)));
|
|
75
|
+
}
|
|
76
|
+
#l() {
|
|
77
|
+
const o = p('[slot="trigger"]', this);
|
|
78
|
+
o && (this.trigger === "hover" ? (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)) : (this.trigger === "click" || this.trigger === "focus") && (i(o, "click", this.#e), A(o)));
|
|
89
79
|
}
|
|
80
|
+
#s = (o) => {
|
|
81
|
+
o.target.id !== this.id && this.hide();
|
|
82
|
+
};
|
|
83
|
+
#o = (o) => {
|
|
84
|
+
this.show(o.target);
|
|
85
|
+
};
|
|
86
|
+
#r = () => {
|
|
87
|
+
this.hide();
|
|
88
|
+
};
|
|
89
|
+
#e = (o) => {
|
|
90
|
+
this.trigger === "click" ? this.toggle(o.target) : this.trigger === "focus" && this.show(o.target);
|
|
91
|
+
};
|
|
90
92
|
show(o) {
|
|
91
93
|
if (!this.disabled) {
|
|
92
94
|
if (this.isShow) {
|
|
93
|
-
|
|
95
|
+
this.#i();
|
|
94
96
|
return;
|
|
95
97
|
}
|
|
96
|
-
this.isShow = !0, this.renderContent(),
|
|
98
|
+
this.isShow = !0, this.renderContent(), this.#a(o);
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
hide() {
|
|
@@ -104,59 +106,51 @@ class Q extends j {
|
|
|
104
106
|
toggle(o) {
|
|
105
107
|
this.isShow ? this.hide() : this.show(o);
|
|
106
108
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
R,
|
|
151
|
-
B,
|
|
152
|
-
_,
|
|
153
|
-
this.offset
|
|
154
|
-
);
|
|
155
|
-
s = y.mainAlign, i = y.crossAlign, v != null && f.style.setProperty("width", `${v}px`);
|
|
156
|
-
const z = `l-popover-${s}${i === "" ? "" : "-" + i}`, $ = f.className.split(" ");
|
|
157
|
-
$[1] !== z && ($[1] = `${z}`, f.className = $.join(" "));
|
|
109
|
+
#i() {
|
|
110
|
+
this._t && (clearTimeout(this._t), this._t = void 0);
|
|
111
|
+
}
|
|
112
|
+
#a(o) {
|
|
113
|
+
let r = "bottom", e = "";
|
|
114
|
+
const v = this.placement.split("-");
|
|
115
|
+
v != null && (r = v[0], e = v[1] || "");
|
|
116
|
+
let t;
|
|
117
|
+
o == null && (o = p('[slot="trigger"]', this));
|
|
118
|
+
const l = p(".l-popover--content", this.root);
|
|
119
|
+
if (l) {
|
|
120
|
+
let a = l.getBoundingClientRect();
|
|
121
|
+
const n = o.getBoundingClientRect();
|
|
122
|
+
let d = document.documentElement;
|
|
123
|
+
const b = d.scrollLeft, w = d.scrollTop;
|
|
124
|
+
this.width != null && (this.width === "trigger" ? t = n.width : t = this.width), t != null && (a.width = t);
|
|
125
|
+
const m = C(
|
|
126
|
+
n,
|
|
127
|
+
a,
|
|
128
|
+
r,
|
|
129
|
+
e,
|
|
130
|
+
this.offset
|
|
131
|
+
), u = y(
|
|
132
|
+
n,
|
|
133
|
+
a,
|
|
134
|
+
r,
|
|
135
|
+
e,
|
|
136
|
+
this.offset
|
|
137
|
+
), c = z(
|
|
138
|
+
n,
|
|
139
|
+
a,
|
|
140
|
+
r,
|
|
141
|
+
e,
|
|
142
|
+
b,
|
|
143
|
+
w,
|
|
144
|
+
u,
|
|
145
|
+
m,
|
|
146
|
+
this.offset
|
|
147
|
+
);
|
|
148
|
+
r = c.mainAlign, e = c.crossAlign, t != null && l.style.setProperty("width", `${t}px`);
|
|
149
|
+
const f = `l-popover-${r}${e === "" ? "" : "-" + e}`, h = l.className.split(" ");
|
|
150
|
+
h[1] !== f && (h[1] = `${f}`, l.className = h.join(" "));
|
|
151
|
+
}
|
|
158
152
|
}
|
|
159
|
-
}
|
|
153
|
+
}
|
|
160
154
|
export {
|
|
161
|
-
|
|
155
|
+
M as default
|
|
162
156
|
};
|
package/lib/radio/index.js
CHANGED
|
@@ -1,52 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
s(this, "type");
|
|
13
|
-
s(this, "label");
|
|
14
|
-
s(this, "checked", !1);
|
|
15
|
-
s(this, "_ignoreInitAttrs", []);
|
|
16
|
-
s(this, "_radioChange", (e) => {
|
|
17
|
-
const o = e.target;
|
|
18
|
-
let t = o.parentElement;
|
|
19
|
-
for (; t != null && !m(t, "l-radio"); )
|
|
20
|
-
t = t.parentElement;
|
|
21
|
-
const i = d(".is-checked", this.root);
|
|
22
|
-
i && f(i, "is-checked"), this.value = o.value, t && b(t, "is-checked"), this.dispatchEvent(new CustomEvent("change"));
|
|
23
|
-
});
|
|
24
|
-
console.log(), E(this);
|
|
25
|
-
}
|
|
1
|
+
import { initAttr as $, tagAttr as s, parseAttrValue as x } from "../utils/index.js";
|
|
2
|
+
import y from "../form/form_inner.js";
|
|
3
|
+
import { $one as a, hasClass as u, addClass as n, $ as c, iterate as h, getAttr as C, removeClass as b, formatClass as A, on as E, off as I } from "ph-utils/dom";
|
|
4
|
+
import { random as p } from "ph-utils";
|
|
5
|
+
const w = ':host{display:flex;align-items:center}.l-radio{--l-radio-size: 16px;--l-radio-label-color: #333;--l-radio-disabled-color: #e6e6e6;--l-radio-disabled-label-color: var(--l-disabled-color, #c0c4cc);--l-radio-checked-color: var(--l-primary-color, #722ed1);--l-radio-item-margin: 10px;display:inline-flex;align-items:center;position:relative;cursor:pointer}.l-radio__label{transition:color .3s ease-in-out;margin-left:5px}.l-radio__input{position:absolute;z-index:-1;width:0;height:0;opacity:0}.l-radio__inner{display:flex;justify-content:center;align-items:center;width:var(--l-radio-size);height:var(--l-radio-size);border:1px solid #dcddd9;border-radius:50%;box-sizing:border-box;transition:border-color .3s ease-in-out}.l-radio__inner:before{content:"";display:block;width:60%;height:60%;background-color:transparent;border-radius:50%;transition:background-color .3s ease-in-out}.l-radio.is-checked .l-radio__inner{border-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__inner:before{background-color:var(--l-primary-color, #722ed1)}.l-radio.is-checked .l-radio__label{color:var(--l-primary-color, #722ed1)}.l-radio--disabled{cursor:not-allowed}.l-radio--disabledd .l-radio__inner{border-color:var(--l-radio-disabled-color)}.l-radio--disabled .l-radio__label{color:var(--l-radio-disabled-label-color)}.l-radio:not(:first-child){margin-left:var(--l-radio-item-margin)}.l-radio--button .l-radio__label{display:inline-flex;height:var(--l-form-edit-height, 32px);justify-content:center;align-items:center;padding:0 15px;border:1px solid #c0c4cc;border-left-width:0;margin-left:0}.l-radio--button:not(:first-of-type){margin-left:0}.l-radio--button:first-of-type .l-radio__label{border-left-width:1px;border-top-left-radius:3px;border-bottom-left-radius:3px}.l-radio--button:last-of-type .l-radio__label{border-top-right-radius:3px;border-bottom-right-radius:3px}.is-checked.l-radio--button .l-radio__label{background-color:var(--l-radio-checked-color);color:#fff;border-color:var(--l-radio-checked-color)}';
|
|
6
|
+
class T extends y {
|
|
7
|
+
static baseName = "radio";
|
|
8
|
+
type;
|
|
9
|
+
label;
|
|
10
|
+
checked = !1;
|
|
11
|
+
_ignoreInitAttrs = [];
|
|
26
12
|
setItems(e) {
|
|
27
13
|
this._removeEvents(), this.root.innerHTML = this._renderItems(e), this._initEvents();
|
|
28
14
|
}
|
|
15
|
+
constructor() {
|
|
16
|
+
super(!1), $(this);
|
|
17
|
+
}
|
|
29
18
|
connectedCallback() {
|
|
30
|
-
super.connectedCallback(), this.loadStyleText(
|
|
19
|
+
super.connectedCallback(), this.loadStyleText(w), this._initEvents();
|
|
31
20
|
}
|
|
32
21
|
disconnectedCallback() {
|
|
33
22
|
super.disconnectedCallback(), this._removeEvents();
|
|
34
23
|
}
|
|
35
24
|
attributeChange(e, o, t) {
|
|
36
25
|
if (e === "checked") {
|
|
37
|
-
const i =
|
|
26
|
+
const i = x(t, !1, e);
|
|
38
27
|
this.checked = i, this.value = i;
|
|
39
|
-
const r =
|
|
40
|
-
if (r && !
|
|
41
|
-
|
|
42
|
-
const
|
|
43
|
-
|
|
28
|
+
const r = a(".l-radio", this.root);
|
|
29
|
+
if (r && !u(r, "is-checked")) {
|
|
30
|
+
n(r, "is-checked");
|
|
31
|
+
const l = a("input", r);
|
|
32
|
+
l && (l.checked = !0);
|
|
44
33
|
}
|
|
45
34
|
}
|
|
46
35
|
}
|
|
47
36
|
render() {
|
|
48
|
-
this.getName() || (this.name = `la${
|
|
49
|
-
const e = [], o =
|
|
37
|
+
this.getName() || (this.name = `la${p(3)}_${p(6)}`);
|
|
38
|
+
const e = [], o = a('[slot="label"]', this), t = c("[radio-value]", this);
|
|
50
39
|
return o != null || this.label ? (this.value = this._isChecked(), o ? e.push(
|
|
51
40
|
this._renderItem("slot", void 0, this._isChecked(), "label")
|
|
52
41
|
) : e.push(
|
|
@@ -56,10 +45,10 @@ class D extends w {
|
|
|
56
45
|
this._isChecked(),
|
|
57
46
|
"label"
|
|
58
47
|
)
|
|
59
|
-
)) : t.length > 0 && (
|
|
60
|
-
const r = i.cloneNode(!0),
|
|
48
|
+
)) : t.length > 0 && (h(t, (i) => {
|
|
49
|
+
const r = i.cloneNode(!0), l = C(i, "radio-value");
|
|
61
50
|
e.push(
|
|
62
|
-
this._renderItem(r.outerHTML,
|
|
51
|
+
this._renderItem(r.outerHTML, l, this.value === l)
|
|
63
52
|
);
|
|
64
53
|
}), this.pushValueChange()), e.join("");
|
|
65
54
|
}
|
|
@@ -67,12 +56,12 @@ class D extends w {
|
|
|
67
56
|
super.setValue(e);
|
|
68
57
|
let o = "";
|
|
69
58
|
typeof e != "boolean" && (o = `[l-value="${e}"]`);
|
|
70
|
-
const t =
|
|
71
|
-
t &&
|
|
72
|
-
const i =
|
|
59
|
+
const t = a(".is-checked", this.root);
|
|
60
|
+
t && b(t, "is-checked");
|
|
61
|
+
const i = a(`label${o}`, this.root);
|
|
73
62
|
if (i) {
|
|
74
|
-
const r =
|
|
75
|
-
typeof e == "boolean" ? (e ?
|
|
63
|
+
const r = a("input", i);
|
|
64
|
+
typeof e == "boolean" ? (e ? n(i, "is-checked") : b(i, "is-checked"), r.checked = e) : (n(i, "is-checked"), r.checked = !0);
|
|
76
65
|
}
|
|
77
66
|
}
|
|
78
67
|
_renderItems(e) {
|
|
@@ -91,36 +80,43 @@ class D extends w {
|
|
|
91
80
|
return o.join("");
|
|
92
81
|
}
|
|
93
82
|
_renderItem(e, o, t = !1, i = void 0) {
|
|
94
|
-
const r =
|
|
83
|
+
const r = A({
|
|
95
84
|
"l-radio": !0,
|
|
96
85
|
"l-radio--disabled": this.isDisabled(),
|
|
97
86
|
"l-radio--button": this.type === "button",
|
|
98
87
|
"is-checked": t
|
|
99
|
-
}),
|
|
100
|
-
`<label class="${r}"${
|
|
101
|
-
`<input type="radio" class="l-radio__input"${
|
|
88
|
+
}), l = s("disabled", this.isDisabled()), f = s("checked", t), m = s("value", o), _ = `${s("name", this.getName())}${m}${l}${f}`, v = s("part", i), g = s("l-value", o), d = [
|
|
89
|
+
`<label class="${r}"${g}>`,
|
|
90
|
+
`<input type="radio" class="l-radio__input"${_} />`
|
|
102
91
|
];
|
|
103
|
-
this.type !== "button" &&
|
|
104
|
-
let
|
|
105
|
-
return
|
|
106
|
-
`<div class="l-radio__label"${
|
|
107
|
-
),
|
|
92
|
+
this.type !== "button" && d.push('<span class="l-radio__inner"></span>');
|
|
93
|
+
let k = e === "slot" ? '<slot name="label"></slot>' : e;
|
|
94
|
+
return d.push(
|
|
95
|
+
`<div class="l-radio__label"${v}>${k}</div>`
|
|
96
|
+
), d.push("</label>"), d.join("");
|
|
108
97
|
}
|
|
109
98
|
_isChecked() {
|
|
110
99
|
return this.checked;
|
|
111
100
|
}
|
|
112
101
|
_initEvents() {
|
|
113
|
-
|
|
114
|
-
|
|
102
|
+
h(c("input", this.root), (e) => {
|
|
103
|
+
E(e, "change", this._radioChange);
|
|
115
104
|
});
|
|
116
105
|
}
|
|
117
106
|
_removeEvents() {
|
|
118
|
-
|
|
119
|
-
|
|
107
|
+
h(c("input", this.root), (e) => {
|
|
108
|
+
I(e, "change", this._radioChange);
|
|
120
109
|
});
|
|
121
110
|
}
|
|
111
|
+
_radioChange = (e) => {
|
|
112
|
+
const o = e.target;
|
|
113
|
+
let t = o.parentElement;
|
|
114
|
+
for (; t != null && !u(t, "l-radio"); )
|
|
115
|
+
t = t.parentElement;
|
|
116
|
+
const i = a(".is-checked", this.root);
|
|
117
|
+
i && b(i, "is-checked"), this.value = o.value, t && n(t, "is-checked"), this.dispatchEvent(new CustomEvent("change"));
|
|
118
|
+
};
|
|
122
119
|
}
|
|
123
|
-
s(D, "baseName", "radio");
|
|
124
120
|
export {
|
|
125
|
-
|
|
121
|
+
T as default
|
|
126
122
|
};
|