litos-ui 0.15.6 → 0.15.8
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/button/index.d.ts +4 -0
- package/lib/button/index.js +88 -61
- package/lib/check/check.js +6 -7
- package/lib/check/checkbox.js +1 -1
- package/lib/check/radio.js +10 -6
- package/lib/{check-BlDsQQo0.js → check-A86JxUfd.js} +1 -1
- package/lib/collapse/index.d.ts +19 -0
- package/lib/collapse/index.js +88 -0
- package/lib/collapse/item.d.ts +15 -0
- package/lib/collapse/item.js +115 -0
- package/lib/color_picker/index.js +1 -1
- package/lib/date_picker/index.js +1 -1
- package/lib/description_panel/index.d.ts +4 -4
- package/lib/description_panel/index.js +59 -11
- package/lib/dialog/dialog_container.js +1 -1
- package/lib/form/form_inner.d.ts +5 -1
- package/lib/form/form_inner.js +33 -27
- package/lib/form/form_item.js +9 -9
- package/lib/icon/d_arrow_left.d.ts +6 -0
- package/lib/icon/d_arrow_left.js +13 -0
- package/lib/icon/d_arrow_right.d.ts +6 -0
- package/lib/icon/d_arrow_right.js +13 -0
- package/lib/icon/more.d.ts +6 -0
- package/lib/icon/more.js +13 -0
- package/lib/icon/select.d.ts +6 -0
- package/lib/icon/select.js +13 -0
- package/lib/icon/zoom_in.d.ts +6 -0
- package/lib/icon/zoom_in.js +13 -0
- package/lib/icon/zoom_out.d.ts +6 -0
- package/lib/icon/zoom_out.js +13 -0
- package/lib/image/image_preview.d.ts +24 -0
- package/lib/image/image_preview.js +104 -0
- package/lib/image/index.d.ts +50 -0
- package/lib/image/index.js +176 -0
- package/lib/index-D4II9KsF.js +4 -0
- package/lib/index.d.ts +36 -4
- package/lib/index.js +157 -120
- package/lib/input/index.d.ts +5 -0
- package/lib/input/index.js +93 -71
- package/lib/litos-ui.css +1 -1
- package/lib/mask/index.d.ts +23 -0
- package/lib/mask/index.js +110 -0
- package/lib/md_input/index.js +11 -11
- package/lib/message/index.js +2 -2
- package/lib/modal/index.d.ts +1 -1
- package/lib/modal/index.js +7 -7
- package/lib/modal/modal_box.js +10 -10
- package/lib/page_header/index.d.ts +20 -0
- package/lib/page_header/index.js +109 -0
- package/lib/pagination/index.d.ts +27 -0
- package/lib/pagination/index.js +248 -0
- package/lib/qrcode/index.js +4 -4
- package/lib/select/index.d.ts +79 -0
- package/lib/select/index.js +406 -0
- package/lib/select_ori/index.js +1 -1
- package/lib/switch/index.js +4 -4
- package/lib/tabbar/index.d.ts +3 -1
- package/lib/tabbar/index.js +14 -8
- package/lib/tabbar/item.js +1 -1
- package/lib/table/index.d.ts +63 -0
- package/lib/table/index.js +260 -0
- package/lib/table/types.d.ts +36 -0
- package/lib/tabs/index.d.ts +7 -0
- package/lib/tabs/index.js +43 -0
- package/lib/tag/index.d.ts +16 -0
- package/lib/tag/index.js +80 -0
- package/lib/theme/index.js +6 -6
- package/lib/utils/index.d.ts +6 -28
- package/lib/utils/index.js +61 -86
- package/lib/utils/popover.d.ts +137 -0
- package/lib/utils/popover.js +354 -0
- package/lib/utils/transition.js +26 -50
- package/package.json +71 -71
- package/styles/popover.css +66 -0
- package/styles/reset.css +1 -1
- package/styles/select.css +37 -0
- package/styles/tabs.css +13 -0
- package/styles/vars.css +2 -1
- package/lib/index-dwS1N2uN.js +0 -4
- package/lib/popconfirm/index.d.ts +0 -7
- package/lib/popconfirm/index.js +0 -30
- package/lib/popover/index.d.ts +0 -34
- package/lib/popover/index.js +0 -150
- /package/lib/{menu/base.js → table/types.js} +0 -0
package/lib/utils/transition.js
CHANGED
|
@@ -1,56 +1,32 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
/** 应用过滤动画的属性值, 例如: opacity: 0; transform: xx; */
|
|
15
|
-
sheetRec;
|
|
16
|
-
duration = "0.3s";
|
|
17
|
-
static get observedAttributes() {
|
|
18
|
-
return ["sheets"];
|
|
19
|
-
}
|
|
20
|
-
constructor() {
|
|
21
|
-
super(), h(this), this.sheetRec = this._parseSheets(this.getAttr("sheets", "opacity: 0"));
|
|
22
|
-
}
|
|
23
|
-
connectedCallback() {
|
|
24
|
-
super.connectedCallback(), this.show();
|
|
25
|
-
}
|
|
26
|
-
render() {
|
|
27
|
-
this.shadow.innerHTML = "<slot></slot>";
|
|
28
|
-
}
|
|
29
|
-
attributeChangedCallback(t, e, s) {
|
|
30
|
-
t === "sheets" && (this.sheetRec = this._parseSheets(s));
|
|
31
|
-
}
|
|
32
|
-
show() {
|
|
33
|
-
const t = this._getSlotFirstChild();
|
|
34
|
-
t && i(t, this.sheetRec, "enter");
|
|
35
|
-
}
|
|
36
|
-
hide(t) {
|
|
37
|
-
const e = this._getSlotFirstChild();
|
|
38
|
-
e && i(e, this.sheetRec, "leave", t);
|
|
39
|
-
}
|
|
40
|
-
_parseSheets(t) {
|
|
41
|
-
const e = t.split(";"), s = [];
|
|
42
|
-
return e.forEach((r) => {
|
|
43
|
-
if (r) {
|
|
44
|
-
const [o, n] = r.split(":");
|
|
45
|
-
s.push([o.trim(), n.trim(), this.duration]);
|
|
1
|
+
import { $ as d, iterate as m, transition as r } from "ph-utils/dom";
|
|
2
|
+
function g() {
|
|
3
|
+
let n;
|
|
4
|
+
const s = {
|
|
5
|
+
attributes: !0,
|
|
6
|
+
attributeFilter: ["l-transition-emit"]
|
|
7
|
+
}, u = (e) => {
|
|
8
|
+
for (let i of e)
|
|
9
|
+
if (i.type === "attributes" && i.attributeName) {
|
|
10
|
+
const t = i.target, b = t.getAttribute(i.attributeName) || "show", a = t.getAttribute("l-transition") || "l", c = t.getAttribute("l-transition-method") || "hide";
|
|
11
|
+
b === "show" ? (t.style.removeProperty("display"), r(t, a, "enter")) : r(t, a, "leave", () => {
|
|
12
|
+
c === "remove" ? t.remove() : t.style.display = "none";
|
|
13
|
+
});
|
|
46
14
|
}
|
|
47
|
-
|
|
15
|
+
};
|
|
16
|
+
function o(e) {
|
|
17
|
+
e && e.length > 0 && (n == null && (n = new MutationObserver(u)), m(e, (i) => {
|
|
18
|
+
const t = i.getAttribute("l-transition");
|
|
19
|
+
t && (r(i, t, "enter"), n.observe(i, s));
|
|
20
|
+
}));
|
|
21
|
+
}
|
|
22
|
+
function f(e) {
|
|
23
|
+
e == null && (e = d("[l-transition]"), o(e));
|
|
48
24
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
return t != null && t.assignedNodes().length > 0 ? t.assignedNodes()[0] : null;
|
|
25
|
+
function l() {
|
|
26
|
+
n && (n.disconnect(), n = void 0);
|
|
52
27
|
}
|
|
28
|
+
return { destroy: l, add: o, init: f };
|
|
53
29
|
}
|
|
54
30
|
export {
|
|
55
|
-
|
|
31
|
+
g as createTransition
|
|
56
32
|
};
|
package/package.json
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "litos-ui",
|
|
3
|
-
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
-
"version": "0.15.
|
|
5
|
-
"type": "module",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
|
|
60
|
-
"
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "litos-ui",
|
|
3
|
+
"description": "基于 Web Component 的 UI 组件库",
|
|
4
|
+
"version": "0.15.8",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite dev",
|
|
8
|
+
"build": "vite build",
|
|
9
|
+
"docs:dev": "vitepress dev docs --force --host 0.0.0.0",
|
|
10
|
+
"docs:build": "vitepress build docs",
|
|
11
|
+
"docs:preview": "vitepress preview docs",
|
|
12
|
+
"inspect:eslint": "eslint --inspect-config",
|
|
13
|
+
"create": "node scripts/index.js create",
|
|
14
|
+
"dts:build": "tsc -p tsconfig.build.json && node scripts/dts.js",
|
|
15
|
+
"lib:build": "pnpm build && pnpm dts:build"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@eslint/js": "^9.34.0",
|
|
19
|
+
"@eslint/markdown": "^7.2.0",
|
|
20
|
+
"@types/node": "^24.3.0",
|
|
21
|
+
"eslint": "^9.34.0",
|
|
22
|
+
"globals": "^16.3.0",
|
|
23
|
+
"less": "^4.4.1",
|
|
24
|
+
"lightningcss": "^1.30.1",
|
|
25
|
+
"prettier": "^3.6.2",
|
|
26
|
+
"typescript": "^5.9.2",
|
|
27
|
+
"typescript-eslint": "^8.41.0",
|
|
28
|
+
"vite": "^7.1.3",
|
|
29
|
+
"vite-plugin-dts": "^4.5.4",
|
|
30
|
+
"vitepress": "^1.6.4"
|
|
31
|
+
},
|
|
32
|
+
"files": [
|
|
33
|
+
"lib",
|
|
34
|
+
"styles"
|
|
35
|
+
],
|
|
36
|
+
"main": "./lib/index.js",
|
|
37
|
+
"module": "./lib/index.js",
|
|
38
|
+
"types": "./lib/index.d.ts",
|
|
39
|
+
"jsdelivr": "./lib/litos-ui.min.js",
|
|
40
|
+
"unpkg": "./lib/litos-ui.min.js",
|
|
41
|
+
"exports": {
|
|
42
|
+
"./styles/*": "./styles/*",
|
|
43
|
+
"./lib/*": "./lib/*",
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./lib/index.js",
|
|
46
|
+
"types": "./lib/index.d.ts",
|
|
47
|
+
"require": "./lib/index.js"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"repository": {
|
|
51
|
+
"type": "git",
|
|
52
|
+
"url": "git+https://github.com/DvShu/litos-ui.git"
|
|
53
|
+
},
|
|
54
|
+
"keywords": [
|
|
55
|
+
"litos-ui",
|
|
56
|
+
"web component",
|
|
57
|
+
"ui framework",
|
|
58
|
+
"component library"
|
|
59
|
+
],
|
|
60
|
+
"homepage": "https://dvshu.github.io/litos-ui/",
|
|
61
|
+
"bugs": {
|
|
62
|
+
"url": "https://github.com/DvShu/litos-ui/issues"
|
|
63
|
+
},
|
|
64
|
+
"license": "MIT",
|
|
65
|
+
"dependencies": {
|
|
66
|
+
"iconify-icon": "^3.0.0",
|
|
67
|
+
"ph-utils": "^0.16.2",
|
|
68
|
+
"qrcode-generator-es": "^1.1.4",
|
|
69
|
+
"shiki": "^3.12.0"
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.l-popover {
|
|
2
|
+
--l-popover-background: #ffffff;
|
|
3
|
+
--l-popover-border-color: #e4e4e4;
|
|
4
|
+
--l-popover-color: #666666;
|
|
5
|
+
--l-popover-box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
|
|
6
|
+
width: max-content;
|
|
7
|
+
position: absolute;
|
|
8
|
+
top: 0;
|
|
9
|
+
left: 0;
|
|
10
|
+
background: var(--l-popover-background);
|
|
11
|
+
box-shadow: var(--l-popover-box-shadow);
|
|
12
|
+
border: 1px solid var(--l-popover-border-color);
|
|
13
|
+
color: var(--l-popover-color);
|
|
14
|
+
border-radius: 4px;
|
|
15
|
+
font-size: 90%;
|
|
16
|
+
box-sizing: border-box;
|
|
17
|
+
display: none;
|
|
18
|
+
z-index: 300;
|
|
19
|
+
line-height: 1;
|
|
20
|
+
padding: 10px;
|
|
21
|
+
}
|
|
22
|
+
.l-popover-arrow {
|
|
23
|
+
position: absolute;
|
|
24
|
+
background: var(--l-popover-background);
|
|
25
|
+
width: var(--l-popover-arrow-size, 8px);
|
|
26
|
+
height: var(--l-popover-arrow-size, 8px);
|
|
27
|
+
transform: rotate(45deg);
|
|
28
|
+
box-sizing: border-box;
|
|
29
|
+
}
|
|
30
|
+
/* tooltip */
|
|
31
|
+
.l-popover.l-popover--tooltip {
|
|
32
|
+
--l-popover-color: #fff;
|
|
33
|
+
--l-popover-box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.3);
|
|
34
|
+
--l-popover-background: #383838;
|
|
35
|
+
--l-popover-border-color: #383838;
|
|
36
|
+
font-size: 12px;
|
|
37
|
+
padding: 8px;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/* popconfirm */
|
|
41
|
+
.l-popover--popconfirm {
|
|
42
|
+
min-width: 150px;
|
|
43
|
+
}
|
|
44
|
+
.l-popover--popconfirm .l-popconfirm-container {
|
|
45
|
+
display: flex;
|
|
46
|
+
align-items: center;
|
|
47
|
+
}
|
|
48
|
+
.l-popover--popconfirm .l-popconfirm-icon-wrapper {
|
|
49
|
+
margin-right: 10px;
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
color: var(--l-warn-color, #f90);
|
|
52
|
+
}
|
|
53
|
+
.l-popover--popconfirm .l-popconfirm-footer {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: flex-end;
|
|
57
|
+
margin-top: 7px;
|
|
58
|
+
gap: 7px;
|
|
59
|
+
}
|
|
60
|
+
.l-popover--popconfirm .l-popconfirm-btn {
|
|
61
|
+
height: 24px;
|
|
62
|
+
}
|
|
63
|
+
.l-popover--popconfirm .l-popconfirm-btn::part(default) {
|
|
64
|
+
padding: 0 6px;
|
|
65
|
+
font-size: 13px;
|
|
66
|
+
}
|
package/styles/reset.css
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
.l-popover--select {
|
|
2
|
+
--l-select-option-hover-background: var(--l-primary-color-light4, #722ed1);
|
|
3
|
+
max-height: 200px;
|
|
4
|
+
overflow: auto;
|
|
5
|
+
padding: 0;
|
|
6
|
+
box-sizing: border-box;
|
|
7
|
+
}
|
|
8
|
+
.l-select-option {
|
|
9
|
+
padding: 10px;
|
|
10
|
+
cursor: pointer;
|
|
11
|
+
transition: background-color 0.3s;
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: center;
|
|
14
|
+
justify-content: space-between;
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
line-height: 1;
|
|
17
|
+
font-size: 14px;
|
|
18
|
+
}
|
|
19
|
+
.l-select-option-content {
|
|
20
|
+
display: inline-block;
|
|
21
|
+
max-width: 100%;
|
|
22
|
+
white-space: nowrap;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
text-overflow: ellipsis;
|
|
25
|
+
}
|
|
26
|
+
.l-select-option:hover {
|
|
27
|
+
background-color: var(--l-select-option-hover-background);
|
|
28
|
+
}
|
|
29
|
+
.l-select-option--empty {
|
|
30
|
+
--l-select-option-hover-background: transparent;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
cursor: default;
|
|
33
|
+
color: var(--l-info-color, #999);
|
|
34
|
+
}
|
|
35
|
+
.l-select-option--selected {
|
|
36
|
+
color: var(--l-primary-color-light1, #9254de);
|
|
37
|
+
}
|
package/styles/tabs.css
ADDED
package/styles/vars.css
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
:root {
|
|
2
2
|
/* button、input 元素高度 */
|
|
3
|
-
--l-form-
|
|
3
|
+
--l-form-control-height: 32px;
|
|
4
4
|
/** 禁用状态颜色 */
|
|
5
5
|
--l-disabled-color: #e6e6e6;
|
|
6
6
|
/* 主题(primary)颜色 */
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
--l-info-color-light9: #f5f5f5;
|
|
32
32
|
/* 边框颜色 */
|
|
33
33
|
--l-border-color: #dedede;
|
|
34
|
+
--l-border-radius: 3px;
|
|
34
35
|
}
|
|
35
36
|
html.dark {
|
|
36
37
|
--l-disabled-color: #262727;
|
package/lib/index-dwS1N2uN.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
const r = ":host{--l-input-border-color: var(--l-border-color, #dedede);display:inline-flex;width:var(--l-input-width, 170px);height:var(--l-form-edit-height, 32px);align-items:center;padding:0 7px;border:1px solid var(--l-input-border-color, #dedede);transition:border-color .3s;border-radius:4px;vertical-align:middle}:host(:focus){--l-input-border-color: var(--l-primary-color, #722ed1)}:host(.is-disabled){background-color:var(--l-disabled-color, #f5f7fa)}:host(.is-error){--l-input-border-color: #ed3f13}.l-input__prefix,.l-input__suffix{color:#a8abb2;font-size:14px;display:inline-flex;flex-shrink:0}.l-input__prefix{margin-right:5px}.l-input__suffix{margin-left:5px}.l-clearable{cursor:pointer}.l-clearable:hover{color:#999}.l-input__inner{outline:none;border:none;box-sizing:border-box;width:100%;max-width:100%;height:100%;flex-grow:1;text-align:inherit}.l-input__inner:disabled{background-color:transparent}";
|
|
2
|
-
export {
|
|
3
|
-
r as i
|
|
4
|
-
};
|
package/lib/popconfirm/index.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
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";
|
|
6
|
-
constructor() {
|
|
7
|
-
super();
|
|
8
|
-
}
|
|
9
|
-
connectedCallback() {
|
|
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);
|
|
12
|
-
o && (this.dispatchEvent(
|
|
13
|
-
new CustomEvent(n, {
|
|
14
|
-
detail: {
|
|
15
|
-
action: n
|
|
16
|
-
}
|
|
17
|
-
})
|
|
18
|
-
), this.hide());
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
contentHTML() {
|
|
22
|
-
const t = c('[slot="icon"]', this), o = [];
|
|
23
|
-
return o.push('<div class="l-popconfirm-container">'), o.push('<div class="l-popconfirm-icon-wrapper">'), o.push(
|
|
24
|
-
t ? '<slot name="icon"></slot>' : "<l-warn-icon></l-warn-icon>"
|
|
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("");
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export {
|
|
29
|
-
f as default
|
|
30
|
-
};
|
package/lib/popover/index.d.ts
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import BaseComponent from "../base";
|
|
2
|
-
type PlacementProp = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
|
|
3
|
-
type TriggerProp = "hover" | "click" | "focus";
|
|
4
|
-
export default class Popover extends BaseComponent {
|
|
5
|
-
#private;
|
|
6
|
-
static baseName: string;
|
|
7
|
-
placement: PlacementProp;
|
|
8
|
-
content?: string;
|
|
9
|
-
showArrow: boolean;
|
|
10
|
-
trigger: TriggerProp;
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
isShow: boolean;
|
|
13
|
-
/** 宽度, 'trigger' 表示 popover 的宽度会和它的触发元素一致 */
|
|
14
|
-
width?: string | number;
|
|
15
|
-
/** 隐藏时销毁 DOM 结构 */
|
|
16
|
-
destroyOnHide: boolean;
|
|
17
|
-
/** 浮层偏移量 */
|
|
18
|
-
offset?: number;
|
|
19
|
-
/** 浮层定位方式 */
|
|
20
|
-
position: "absolute" | "fixed";
|
|
21
|
-
theme: "default" | "tooltip" | "popconfirm";
|
|
22
|
-
inline: boolean;
|
|
23
|
-
private _t?;
|
|
24
|
-
connectedCallback(): void;
|
|
25
|
-
disconnectedCallback(): void;
|
|
26
|
-
render(): HTMLSlotElement;
|
|
27
|
-
renderContent(): void;
|
|
28
|
-
protected contentHTML(): string;
|
|
29
|
-
hideContent(): void;
|
|
30
|
-
show($referece?: HTMLElement): void;
|
|
31
|
-
hide(): void;
|
|
32
|
-
toggle($referece?: HTMLElement): void;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
package/lib/popover/index.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
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 P } from "../utils/clickoutside.js";
|
|
4
|
-
import { $one as p, $$ as g, on as s, off as i } from "ph-utils/dom";
|
|
5
|
-
const A = ':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
|
-
inline = !1;
|
|
24
|
-
_t;
|
|
25
|
-
connectedCallback() {
|
|
26
|
-
k(this), this.loadStyleText(A), this.#t(), super.connectedCallback(), this.renderContent(), this.#p();
|
|
27
|
-
}
|
|
28
|
-
disconnectedCallback() {
|
|
29
|
-
super.disconnectedCallback(), this.#l();
|
|
30
|
-
}
|
|
31
|
-
render() {
|
|
32
|
-
const o = document.createElement("slot");
|
|
33
|
-
return o.setAttribute("name", "trigger"), o;
|
|
34
|
-
}
|
|
35
|
-
renderContent() {
|
|
36
|
-
if (!this.isShow) return;
|
|
37
|
-
let o = p(".l-popover--content", this.root);
|
|
38
|
-
if (o) {
|
|
39
|
-
o.style.removeProperty("display");
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (o = g("div", {
|
|
43
|
-
class: [
|
|
44
|
-
"l-popover--content",
|
|
45
|
-
`l-popover-${this.placement}`,
|
|
46
|
-
this.theme === "default" ? void 0 : `l-popover-${this.theme}`
|
|
47
|
-
]
|
|
48
|
-
}), this.offset && (o.style.cssText = "--l-popover-offset: ${this.offset}px;"), o.part = "content", o.innerHTML = this.contentHTML(), this.showArrow) {
|
|
49
|
-
const r = g("div", {
|
|
50
|
-
class: "l-popover--arrow"
|
|
51
|
-
});
|
|
52
|
-
o.appendChild(r);
|
|
53
|
-
}
|
|
54
|
-
this.trigger === "hover" && (s(o, "mouseenter", this.#o), s(o, "mouseleave", this.#r)), this.root.appendChild(o);
|
|
55
|
-
}
|
|
56
|
-
contentHTML() {
|
|
57
|
-
return this.content ? `<span>${this.content}</span>` : "<slot></slot>";
|
|
58
|
-
}
|
|
59
|
-
#t() {
|
|
60
|
-
this.style.display = this.inline ? "inline-block" : "block", this.id || (this.id = `${$()}-popover`);
|
|
61
|
-
}
|
|
62
|
-
hideContent() {
|
|
63
|
-
const o = p(".l-popover--content", this.root);
|
|
64
|
-
o && (this.destroyOnHide ? (this.trigger === "hover" && (i(o, "mouseenter", this.#o), i(o, "mouseleave", this.#r)), this.root.removeChild(o)) : o.style.display = "none");
|
|
65
|
-
}
|
|
66
|
-
#p() {
|
|
67
|
-
const o = p('[slot="trigger"]', this);
|
|
68
|
-
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)));
|
|
69
|
-
}
|
|
70
|
-
#l() {
|
|
71
|
-
const o = p('[slot="trigger"]', this);
|
|
72
|
-
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), P(o)));
|
|
73
|
-
}
|
|
74
|
-
#s = (o) => {
|
|
75
|
-
o.target.id !== this.id && this.hide();
|
|
76
|
-
};
|
|
77
|
-
#o = (o) => {
|
|
78
|
-
this.show(o.target);
|
|
79
|
-
};
|
|
80
|
-
#r = () => {
|
|
81
|
-
this.hide();
|
|
82
|
-
};
|
|
83
|
-
#e = (o) => {
|
|
84
|
-
this.trigger === "click" ? this.toggle(o.target) : this.trigger === "focus" && this.show(o.target);
|
|
85
|
-
};
|
|
86
|
-
show(o) {
|
|
87
|
-
if (!this.disabled) {
|
|
88
|
-
if (this.isShow) {
|
|
89
|
-
this.#i();
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
this.isShow = !0, this.renderContent(), this.#a(o);
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
hide() {
|
|
96
|
-
this._t = setTimeout(() => {
|
|
97
|
-
this.isShow = !1, this.hideContent();
|
|
98
|
-
}, 50);
|
|
99
|
-
}
|
|
100
|
-
toggle(o) {
|
|
101
|
-
this.isShow ? this.hide() : this.show(o);
|
|
102
|
-
}
|
|
103
|
-
#i() {
|
|
104
|
-
this._t && (clearTimeout(this._t), this._t = void 0);
|
|
105
|
-
}
|
|
106
|
-
#a(o) {
|
|
107
|
-
let r = "bottom", e = "";
|
|
108
|
-
const v = this.placement.split("-");
|
|
109
|
-
v != null && (r = v[0], e = v[1] || "");
|
|
110
|
-
let t;
|
|
111
|
-
o == null && (o = p('[slot="trigger"]', this));
|
|
112
|
-
const l = p(".l-popover--content", this.root);
|
|
113
|
-
if (l) {
|
|
114
|
-
let a = l.getBoundingClientRect();
|
|
115
|
-
const n = o.getBoundingClientRect();
|
|
116
|
-
let d = document.documentElement;
|
|
117
|
-
const b = d.scrollLeft, w = d.scrollTop;
|
|
118
|
-
this.width != null && (this.width === "trigger" ? t = n.width : t = this.width), t != null && (a.width = t);
|
|
119
|
-
const m = C(
|
|
120
|
-
n,
|
|
121
|
-
a,
|
|
122
|
-
r,
|
|
123
|
-
e,
|
|
124
|
-
this.offset
|
|
125
|
-
), u = y(
|
|
126
|
-
n,
|
|
127
|
-
a,
|
|
128
|
-
r,
|
|
129
|
-
e,
|
|
130
|
-
this.offset
|
|
131
|
-
), c = z(
|
|
132
|
-
n,
|
|
133
|
-
a,
|
|
134
|
-
r,
|
|
135
|
-
e,
|
|
136
|
-
b,
|
|
137
|
-
w,
|
|
138
|
-
u,
|
|
139
|
-
m,
|
|
140
|
-
this.offset
|
|
141
|
-
);
|
|
142
|
-
r = c.mainAlign, e = c.crossAlign, t != null && l.style.setProperty("width", `${t}px`);
|
|
143
|
-
const f = `l-popover-${r}${e === "" ? "" : "-" + e}`, h = l.className.split(" ");
|
|
144
|
-
h[1] !== f && (h[1] = `${f}`, l.className = h.join(" "));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
export {
|
|
149
|
-
M as default
|
|
150
|
-
};
|
|
File without changes
|