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/index.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import { isBlank as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function j(t, r) {
|
|
1
|
+
import { isBlank as $ } from "ph-utils";
|
|
2
|
+
let x = -1;
|
|
3
|
+
function O(t, r) {
|
|
5
4
|
const e = Array.isArray(t) ? t : [t];
|
|
6
|
-
for (const
|
|
7
|
-
const
|
|
8
|
-
customElements.get(
|
|
5
|
+
for (const s of e) {
|
|
6
|
+
const i = r || `l-${s.baseName}`;
|
|
7
|
+
customElements.get(i) || customElements.define(i, s);
|
|
9
8
|
}
|
|
10
9
|
}
|
|
11
|
-
function
|
|
12
|
-
return `l-${++
|
|
10
|
+
function _() {
|
|
11
|
+
return `l-${++x}`;
|
|
13
12
|
}
|
|
14
|
-
function
|
|
13
|
+
function m(t, r, e) {
|
|
15
14
|
if (t == null) return r;
|
|
16
15
|
switch (typeof r) {
|
|
17
16
|
case "boolean":
|
|
@@ -22,111 +21,87 @@ function I(t, r, e) {
|
|
|
22
21
|
return t;
|
|
23
22
|
}
|
|
24
23
|
}
|
|
25
|
-
function
|
|
24
|
+
function j(t) {
|
|
26
25
|
const r = t.attributes;
|
|
27
26
|
for (const e of r) {
|
|
28
|
-
const { name:
|
|
29
|
-
if (
|
|
27
|
+
const { name: s, value: i } = e;
|
|
28
|
+
if (s.startsWith("data-") || s.startsWith("aria-") || s.startsWith("_") || s.startsWith("$") || ["id", "class", "style"].includes(s))
|
|
30
29
|
continue;
|
|
31
|
-
const
|
|
32
|
-
(t._ignoreInitAttrs || []).includes(
|
|
30
|
+
const u = s.split("-").map((o, w) => w === 0 ? o : o[0].toUpperCase() + o.slice(1)).join(""), h = m(i, t[u], s), f = Object.getOwnPropertyNames(t);
|
|
31
|
+
(t._ignoreInitAttrs || []).includes(u) || (s === "value" ? (t[u] = h, t._resetValue = h) : (f.includes(u) || f.includes(`_${u}`)) && (t[u] = h));
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
function
|
|
36
|
-
let e = "
|
|
37
|
-
return r === !0 ? e = ` ${t}` : typeof r == "string" &&
|
|
34
|
+
function E(t, r) {
|
|
35
|
+
let e = "";
|
|
36
|
+
return r === !0 ? e = ` ${t}` : typeof r == "string" && !$(r) && (e = ` ${t}="${r}"`), e;
|
|
38
37
|
}
|
|
39
|
-
function
|
|
40
|
-
|
|
38
|
+
function k(t) {
|
|
39
|
+
const r = t.map((e) => E(e[0], e[1]));
|
|
40
|
+
return r.length > 0 ? ` ${r.join("")}` : "";
|
|
41
41
|
}
|
|
42
42
|
function C(t, r) {
|
|
43
43
|
for (const e of r) {
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
function V() {
|
|
49
|
-
let t;
|
|
50
|
-
const r = {
|
|
51
|
-
attributes: !0,
|
|
52
|
-
attributeFilter: ["l-transition-emit"]
|
|
53
|
-
}, e = (n) => {
|
|
54
|
-
for (let f of n)
|
|
55
|
-
if (f.type === "attributes" && f.attributeName) {
|
|
56
|
-
const u = f.target, c = u.getAttribute(f.attributeName) || "show", d = u.getAttribute("l-transition") || "l", h = u.getAttribute("l-transition-method") || "hide";
|
|
57
|
-
c === "show" ? (u.style.removeProperty("display"), y(u, d, "enter")) : y(u, d, "leave", () => {
|
|
58
|
-
h === "remove" ? u.remove() : u.style.display = "none";
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
function i(n) {
|
|
63
|
-
n && n.length > 0 && (t == null && (t = new MutationObserver(e)), x(n, (f) => {
|
|
64
|
-
const u = f.getAttribute("l-transition");
|
|
65
|
-
u && (y(f, u, "enter"), t.observe(f, r));
|
|
66
|
-
}));
|
|
67
|
-
}
|
|
68
|
-
function s(n) {
|
|
69
|
-
n == null && (n = $("[l-transition]"), i(n));
|
|
44
|
+
const s = e[1], i = e[0];
|
|
45
|
+
s === !0 ? t.setAttribute(i, "") : typeof s == "string" && !$(s) && t.setAttribute(i, s);
|
|
70
46
|
}
|
|
71
|
-
function o() {
|
|
72
|
-
t && (t.disconnect(), t = void 0);
|
|
73
|
-
}
|
|
74
|
-
return { destroy: o, add: i, init: s };
|
|
75
47
|
}
|
|
76
|
-
function
|
|
77
|
-
let
|
|
78
|
-
return e === "top" ?
|
|
48
|
+
function c(t, r, e, s, i = 10) {
|
|
49
|
+
let n = 0;
|
|
50
|
+
return e === "top" ? n = r.height + i : e === "bottom" ? n = -(t.height + i) : (e === "left" || e === "right") && (s === "" ? n = r.height / 2 - t.height / 2 : s === "end" && (n = r.height - t.height)), n;
|
|
79
51
|
}
|
|
80
|
-
function
|
|
81
|
-
let
|
|
82
|
-
return e === "left" ?
|
|
52
|
+
function a(t, r, e, s, i = 10) {
|
|
53
|
+
let n = 0;
|
|
54
|
+
return e === "left" ? n = r.width + i : e === "right" ? n = -(t.width + i) : (e === "top" || e === "bottom") && (s === "" ? n = r.width / 2 - t.width / 2 : s === "end" && (n = r.width - t.width)), n;
|
|
83
55
|
}
|
|
84
|
-
function
|
|
85
|
-
const
|
|
86
|
-
let
|
|
87
|
-
|
|
56
|
+
function P(t, r, e, s, i, n, u, h, f = 10, y = "absolute") {
|
|
57
|
+
const o = window.innerHeight + n - 10, w = window.innerWidth + i - 10;
|
|
58
|
+
let d = t.top + n - h;
|
|
59
|
+
d + r.height > o && (e === "left" || e === "right" ? s = "end" : e = "top", h = c(
|
|
88
60
|
t,
|
|
89
61
|
r,
|
|
90
62
|
e,
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
),
|
|
94
|
-
let b = t.left +
|
|
95
|
-
return b + r.width >
|
|
63
|
+
s,
|
|
64
|
+
f
|
|
65
|
+
), d = t.top + n - h), d < n && (e === "left" || e === "right" ? s = "start" : e = "bottom");
|
|
66
|
+
let b = t.left + i - u;
|
|
67
|
+
return b + r.width > w && (e === "top" || e === "bottom" ? s = "end" : e = "left", u = a(
|
|
96
68
|
t,
|
|
97
69
|
r,
|
|
98
70
|
e,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
), b = t.left +
|
|
71
|
+
s,
|
|
72
|
+
f
|
|
73
|
+
), b = t.left + i - u), b < i && (e === "top" || e === "bottom" ? s = "start" : e = "right"), y === "fixed" && (h = c(
|
|
102
74
|
t,
|
|
103
75
|
r,
|
|
104
76
|
e,
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
),
|
|
77
|
+
s,
|
|
78
|
+
f
|
|
79
|
+
), u = a(
|
|
108
80
|
t,
|
|
109
81
|
r,
|
|
110
82
|
e,
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
), b = t.left +
|
|
83
|
+
s,
|
|
84
|
+
f
|
|
85
|
+
), b = t.left + i - u, d = t.top + n - h), {
|
|
114
86
|
x: b,
|
|
115
|
-
y:
|
|
87
|
+
y: d,
|
|
116
88
|
mainAlign: e,
|
|
117
|
-
crossAlign:
|
|
89
|
+
crossAlign: s
|
|
118
90
|
};
|
|
119
91
|
}
|
|
92
|
+
function p(t) {
|
|
93
|
+
return t.replace(/-(\w)/g, (r, e) => e.toUpperCase());
|
|
94
|
+
}
|
|
120
95
|
export {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
96
|
+
a as getPopoverOffsetX,
|
|
97
|
+
c as getPopoverOffsetY,
|
|
98
|
+
P as impactDetect,
|
|
99
|
+
j as initAttr,
|
|
100
|
+
p as kebabToCamel,
|
|
101
|
+
m as parseAttrValue,
|
|
102
|
+
O as regist,
|
|
128
103
|
C as setAttrs,
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
104
|
+
E as tagAttr,
|
|
105
|
+
k as tagAttrs,
|
|
106
|
+
_ as useId
|
|
132
107
|
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 获取给定元素的所有可滚动祖先元素
|
|
3
|
+
*
|
|
4
|
+
* @param element 给定的HTML元素
|
|
5
|
+
* @returns 返回包含所有可滚动祖先元素的数组
|
|
6
|
+
*/
|
|
7
|
+
export declare function getOverflowAncestors(element: HTMLElement): HTMLElement[];
|
|
8
|
+
type PopoverPlacement = "top-start" | "top" | "top-end" | "bottom-start" | "bottom" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end";
|
|
9
|
+
type UpdatePositionProps = {
|
|
10
|
+
/** 浮动元素宽度 */
|
|
11
|
+
popoverWidth?: number | "trigger";
|
|
12
|
+
/** 弹出位置, 默认: top */
|
|
13
|
+
placement?: PopoverPlacement;
|
|
14
|
+
/** 偏移量, 默认: 10 */
|
|
15
|
+
offset?: number;
|
|
16
|
+
/** 指示箭头大小 */
|
|
17
|
+
arrowSize?: number;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* 更新浮动元素的位置
|
|
21
|
+
*
|
|
22
|
+
* @param reference 参照元素
|
|
23
|
+
* @param floating 浮动元素
|
|
24
|
+
* @param options 配置项,默认值为 { placement: "top" }
|
|
25
|
+
*
|
|
26
|
+
* options 参数:
|
|
27
|
+
* - placement: 浮动元素的定位方式,可选值包括 top, right, bottom, left,支持带横轴对齐方式(如 "top-start", "right-end" 等)
|
|
28
|
+
* - popoverWidth: 浮动元素的宽度,可选值为具体数值或 "trigger"(表示与参照元素同宽)
|
|
29
|
+
*/
|
|
30
|
+
export declare function updatePosition(reference: HTMLElement, floating: HTMLElement, options?: UpdatePositionProps): void;
|
|
31
|
+
export declare function autoUpdate(reference: HTMLElement, floating: HTMLElement, options: UpdatePositionProps): {
|
|
32
|
+
destroy: () => void;
|
|
33
|
+
};
|
|
34
|
+
type PopoverInitProps = {
|
|
35
|
+
/** 触发元素, 如果不传, 则默认查询所有的 .l-popover-reference 类节点 */
|
|
36
|
+
reference?: HTMLElement | HTMLElement[] | string;
|
|
37
|
+
/** Popover节点, 如果不传则会自动创建 */
|
|
38
|
+
popover?: HTMLElement;
|
|
39
|
+
popoverClass?: string;
|
|
40
|
+
/** Popover 内容渲染 */
|
|
41
|
+
contentRender?: () => HTMLElement | string | DocumentFragment;
|
|
42
|
+
/**
|
|
43
|
+
* Popover显示内容修改函数
|
|
44
|
+
* @param popoverElement Popover节点
|
|
45
|
+
* @param datas referecnce 节点上的 data 属性集
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
updateContent?: (popoverElement: HTMLElement, datas?: Record<string, any>) => void;
|
|
49
|
+
/** 触发方式, 默认: hover */
|
|
50
|
+
trigger?: "click" | "hover" | "focus" | "manual";
|
|
51
|
+
/** 主题, default - 白底, tooltip - 黑底 */
|
|
52
|
+
theme?: "default" | "tooltip" | string;
|
|
53
|
+
/** 浮动元素宽度 */
|
|
54
|
+
popoverWidth?: number | "trigger";
|
|
55
|
+
/** 弹出位置, 默认: top */
|
|
56
|
+
placement?: PopoverPlacement;
|
|
57
|
+
/** 是否显示指示箭头 */
|
|
58
|
+
arrow?: boolean;
|
|
59
|
+
/** 指示箭头大小 */
|
|
60
|
+
arrowSize?: number;
|
|
61
|
+
/** 偏移量, 默认: 10 */
|
|
62
|
+
offset?: number;
|
|
63
|
+
/** 点击 Popover 内具有 data-action 的元素时触发 */
|
|
64
|
+
onPopoverAction?: (action: string, target: HTMLElement) => void;
|
|
65
|
+
onOpenChange?: (isOpen: boolean) => void;
|
|
66
|
+
disabled?: boolean;
|
|
67
|
+
};
|
|
68
|
+
export declare class Popover {
|
|
69
|
+
options: PopoverInitProps;
|
|
70
|
+
private $refs;
|
|
71
|
+
/** 激活的触发节点 */
|
|
72
|
+
private $reference?;
|
|
73
|
+
popoverElement?: HTMLElement;
|
|
74
|
+
private updater?;
|
|
75
|
+
private _hideTimer?;
|
|
76
|
+
constructor(props?: PopoverInitProps);
|
|
77
|
+
/**
|
|
78
|
+
* 向实例中添加一个引用元素
|
|
79
|
+
*
|
|
80
|
+
* @param reference 需要添加的引用元素
|
|
81
|
+
*/
|
|
82
|
+
addReference(reference: HTMLElement): void;
|
|
83
|
+
/**
|
|
84
|
+
* 从引用列表中移除指定的引用
|
|
85
|
+
*
|
|
86
|
+
* @param referecnce 要移除的引用元素
|
|
87
|
+
*/
|
|
88
|
+
removeReference(referecnce: HTMLElement): void;
|
|
89
|
+
_init(): void;
|
|
90
|
+
_bindReferenceEvents(ref: HTMLElement): void;
|
|
91
|
+
_removeReferenceEvents(ref: HTMLElement): void;
|
|
92
|
+
_bindPopoverEvents(): void;
|
|
93
|
+
_onPopoverEnter: () => void;
|
|
94
|
+
_clearHideTimer(): void;
|
|
95
|
+
_onMouseEnter: (e: Event) => void;
|
|
96
|
+
_onMouseLeave: () => void;
|
|
97
|
+
_onRefTap: (e: Event) => void;
|
|
98
|
+
/**
|
|
99
|
+
* 显示浮层。
|
|
100
|
+
*
|
|
101
|
+
* @param reference 浮层所对齐的 HTML 元素。
|
|
102
|
+
*/
|
|
103
|
+
show(reference: HTMLElement): void;
|
|
104
|
+
isShow(): boolean;
|
|
105
|
+
/**
|
|
106
|
+
* 隐藏 Popover
|
|
107
|
+
*/
|
|
108
|
+
hide(): void;
|
|
109
|
+
/** 重新设置选项 */
|
|
110
|
+
setOption(key: string, value: any): void;
|
|
111
|
+
updatePopoverContent(): void;
|
|
112
|
+
_onOuterTap: (e: Event) => void;
|
|
113
|
+
_renderPopover(): void;
|
|
114
|
+
_destroyUpdater(): void;
|
|
115
|
+
/**
|
|
116
|
+
* 销毁组件
|
|
117
|
+
*
|
|
118
|
+
* 销毁组件并移除相关事件监听器和 DOM 元素。
|
|
119
|
+
*/
|
|
120
|
+
destroy(): void;
|
|
121
|
+
}
|
|
122
|
+
type PopconfirmInitProps = PopoverInitProps;
|
|
123
|
+
export declare const popconfirmProps: PopconfirmInitProps;
|
|
124
|
+
/**
|
|
125
|
+
* 创建 Popover 观察者
|
|
126
|
+
*
|
|
127
|
+
* 当指定元素的子节点发生变化时,会自动添加或移除 Popover 实例的引用元素。
|
|
128
|
+
*
|
|
129
|
+
* 通常用于列表子元素的 Popover, 列表又能增加和删除, 比如: List、Table
|
|
130
|
+
*
|
|
131
|
+
* @param observeElement - 要观察的元素
|
|
132
|
+
* @param refereceClass - 引用元素的类名
|
|
133
|
+
* @param popover - Popover 实例
|
|
134
|
+
* @returns 一个对象,包含一个 `disconnect` 方法,用于断开观察
|
|
135
|
+
*/
|
|
136
|
+
export declare function createPopoverObserver(observeElement: HTMLElement, refereceClass: string, popover: Popover): MutationObserver;
|
|
137
|
+
export {};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { $one as T, $ as y, iterate as $, on as d, off as a, shouldEventNext as g, $$ as w } from "ph-utils/dom";
|
|
2
|
+
function E(s, t, e, o, n = 10, r = "x") {
|
|
3
|
+
const i = r === "x" ? "width" : "height";
|
|
4
|
+
let p = ["left", "right", "top", "bottom"];
|
|
5
|
+
r === "y" && (p = ["top", "bottom", "left", "right"]);
|
|
6
|
+
let h = 0;
|
|
7
|
+
return e === p[0] ? h = t[i] + n : e === p[1] ? h = -(s[i] + n) : (e === p[2] || e === p[3]) && (o === "" ? h = t[i] / 2 - s[i] / 2 : o === "end" && (h = t[i] - s[i])), h;
|
|
8
|
+
}
|
|
9
|
+
function C(s) {
|
|
10
|
+
const t = [];
|
|
11
|
+
let e = s;
|
|
12
|
+
for (; e && e !== document.body && e !== document.documentElement; ) {
|
|
13
|
+
const o = window.getComputedStyle(e), n = o.overflow + o.overflowX + o.overflowY;
|
|
14
|
+
/(scroll|auto)/i.test(n) && t.push(e), e = e.parentElement;
|
|
15
|
+
}
|
|
16
|
+
return t;
|
|
17
|
+
}
|
|
18
|
+
function O(s, t, e, o, n = 10) {
|
|
19
|
+
let r = document.documentElement;
|
|
20
|
+
const i = r.scrollLeft, p = r.scrollTop, h = window.innerHeight + p - 10, l = window.innerWidth + i - 10;
|
|
21
|
+
let c = E(
|
|
22
|
+
s,
|
|
23
|
+
t,
|
|
24
|
+
e,
|
|
25
|
+
o,
|
|
26
|
+
n,
|
|
27
|
+
"y"
|
|
28
|
+
), f = s.top + p - c;
|
|
29
|
+
f + t.height > h && (e === "left" || e === "right" ? o = "end" : e = "top"), f < p && (e === "left" || e === "right" ? o = "start" : e = "bottom");
|
|
30
|
+
let u = E(
|
|
31
|
+
s,
|
|
32
|
+
t,
|
|
33
|
+
e,
|
|
34
|
+
o,
|
|
35
|
+
n,
|
|
36
|
+
"x"
|
|
37
|
+
), m = s.left + i - u;
|
|
38
|
+
m + t.width > l && (e === "top" || e === "bottom" ? o = "end" : e = "left"), m < i && (e === "top" || e === "bottom" ? o = "start" : e = "right"), c = E(
|
|
39
|
+
s,
|
|
40
|
+
t,
|
|
41
|
+
e,
|
|
42
|
+
o,
|
|
43
|
+
n,
|
|
44
|
+
"y"
|
|
45
|
+
), u = E(
|
|
46
|
+
s,
|
|
47
|
+
t,
|
|
48
|
+
e,
|
|
49
|
+
o,
|
|
50
|
+
n,
|
|
51
|
+
"x"
|
|
52
|
+
), m = s.left + i - u, f = s.top + p - c;
|
|
53
|
+
const P = `${e}${o === "" ? "" : "-" + o}`;
|
|
54
|
+
return {
|
|
55
|
+
x: m,
|
|
56
|
+
y: f,
|
|
57
|
+
mainAlign: e,
|
|
58
|
+
crossAlign: o,
|
|
59
|
+
placement: P
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
function M(s, t, e, o) {
|
|
63
|
+
const n = s.getBoundingClientRect(), r = t.getBoundingClientRect();
|
|
64
|
+
let i = "height";
|
|
65
|
+
(e === "top" || e === "bottom") && (i = "width");
|
|
66
|
+
const p = Math.min(n[i], r[i]);
|
|
67
|
+
let h = 0;
|
|
68
|
+
return o === "start" ? h = p / 2 - 4 : o === "end" ? h = r[i] - p / 2 - 4 : h = r[i] / 2 - 4, {
|
|
69
|
+
x: i === "width" ? h : void 0,
|
|
70
|
+
y: i === "height" ? h : void 0
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function b(s, t, e = { placement: "top", offset: 10, arrowSize: 8 }) {
|
|
74
|
+
let o = "bottom", n = "";
|
|
75
|
+
const r = (e.placement || "top").split("-");
|
|
76
|
+
r != null && (o = r[0], n = r[1] || "");
|
|
77
|
+
let i, p = t.getBoundingClientRect();
|
|
78
|
+
const h = s.getBoundingClientRect();
|
|
79
|
+
e.popoverWidth && (e.popoverWidth === "trigger" ? i = h.width : i = e.popoverWidth), i != null && (p.width = i, t.style.width = `${i}px`);
|
|
80
|
+
const l = O(
|
|
81
|
+
h,
|
|
82
|
+
p,
|
|
83
|
+
o,
|
|
84
|
+
n,
|
|
85
|
+
e.offset || 10
|
|
86
|
+
);
|
|
87
|
+
t.style.setProperty("left", `${l.x}px`), t.style.setProperty("top", `${l.y}px`);
|
|
88
|
+
let c = T(".l-popover-arrow", t);
|
|
89
|
+
if (c) {
|
|
90
|
+
const f = M(
|
|
91
|
+
s,
|
|
92
|
+
t,
|
|
93
|
+
l.mainAlign,
|
|
94
|
+
l.crossAlign
|
|
95
|
+
);
|
|
96
|
+
let v = "";
|
|
97
|
+
e.arrowSize !== 8 && (v += `--l-popover-arrow-size: ${e.arrowSize}px;`), f.x && (v += `left: ${f.x}px;`), f.y && (v += `top: ${f.y}px;`);
|
|
98
|
+
const u = {
|
|
99
|
+
top: "bottom",
|
|
100
|
+
right: "left",
|
|
101
|
+
bottom: "top",
|
|
102
|
+
left: "right"
|
|
103
|
+
}[l.mainAlign], m = {
|
|
104
|
+
top: "right",
|
|
105
|
+
bottom: "left",
|
|
106
|
+
left: "top",
|
|
107
|
+
right: "bottom"
|
|
108
|
+
}[l.mainAlign], _ = Math.ceil((e.arrowSize || 8) / 2);
|
|
109
|
+
v += `${u}: -${_}px;border-${u}: 1px solid var(--l-popover-border-color);border-${m}:1px solid var(--l-popover-border-color);`, c.style.cssText = v;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function L(s, t, e) {
|
|
113
|
+
let o = s, n = t, r = e;
|
|
114
|
+
b(o, n, r);
|
|
115
|
+
function i() {
|
|
116
|
+
b(o, n, r);
|
|
117
|
+
}
|
|
118
|
+
let p = C(o);
|
|
119
|
+
p.forEach((f) => {
|
|
120
|
+
d(f, "scroll", i);
|
|
121
|
+
});
|
|
122
|
+
function h() {
|
|
123
|
+
b(o, n, r);
|
|
124
|
+
}
|
|
125
|
+
let l = new ResizeObserver(h);
|
|
126
|
+
l.observe(o), l.observe(window.document.body);
|
|
127
|
+
function c() {
|
|
128
|
+
p.forEach((f) => {
|
|
129
|
+
a(f, "scroll", i);
|
|
130
|
+
}), p = void 0, o = void 0, n = void 0, r = void 0, l.disconnect(), l = void 0;
|
|
131
|
+
}
|
|
132
|
+
return { destroy: c };
|
|
133
|
+
}
|
|
134
|
+
class z {
|
|
135
|
+
options;
|
|
136
|
+
$refs = [];
|
|
137
|
+
/** 激活的触发节点 */
|
|
138
|
+
$reference;
|
|
139
|
+
popoverElement;
|
|
140
|
+
updater;
|
|
141
|
+
_hideTimer;
|
|
142
|
+
constructor(t) {
|
|
143
|
+
this.options = {
|
|
144
|
+
trigger: "hover",
|
|
145
|
+
arrow: !0,
|
|
146
|
+
offset: 10,
|
|
147
|
+
arrowSize: 8,
|
|
148
|
+
disabled: !1,
|
|
149
|
+
updateContent: (o, n) => {
|
|
150
|
+
if (n && n.title) {
|
|
151
|
+
const r = T(".l-popover-content", o);
|
|
152
|
+
r && (r.textContent = n.title);
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
...t
|
|
156
|
+
};
|
|
157
|
+
let e = [];
|
|
158
|
+
this.options.reference ? typeof this.options.reference == "string" ? e = [...y(this.options.reference)] : Array.isArray(this.options.reference) ? e.push(...this.options.reference) : e.push(this.options.reference) : e = [...y(".l-popover-reference")], this.$refs = e, this.popoverElement = this.options.popover, this._bindPopoverEvents(), this._init();
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* 向实例中添加一个引用元素
|
|
162
|
+
*
|
|
163
|
+
* @param reference 需要添加的引用元素
|
|
164
|
+
*/
|
|
165
|
+
addReference(t) {
|
|
166
|
+
this.$refs && (this._bindReferenceEvents(t), this.$refs.push(t));
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 从引用列表中移除指定的引用
|
|
170
|
+
*
|
|
171
|
+
* @param referecnce 要移除的引用元素
|
|
172
|
+
*/
|
|
173
|
+
removeReference(t) {
|
|
174
|
+
if (this.$refs) {
|
|
175
|
+
let e = this.$refs.indexOf(t);
|
|
176
|
+
e !== -1 && (t == this.$reference && this.hide(), this._removeReferenceEvents(t), this.$refs.splice(e, 1));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
_init() {
|
|
180
|
+
this.options.trigger && this.$refs && $(this.$refs, (t) => {
|
|
181
|
+
this._bindReferenceEvents(t);
|
|
182
|
+
}), d(document, "click", this._onOuterTap, { capture: !0 });
|
|
183
|
+
}
|
|
184
|
+
_bindReferenceEvents(t) {
|
|
185
|
+
const e = this.options.trigger;
|
|
186
|
+
["click", "focus"].includes(e) ? d(t, "click", this._onRefTap) : e === "hover" && (d(t, "mouseenter", this._onMouseEnter), d(t, "mouseleave", this._onMouseLeave));
|
|
187
|
+
}
|
|
188
|
+
_removeReferenceEvents(t) {
|
|
189
|
+
a(t, "click", this._onRefTap), a(t, "mouseenter", this._onMouseEnter), a(t, "mouseleave", this._onMouseLeave);
|
|
190
|
+
}
|
|
191
|
+
_bindPopoverEvents() {
|
|
192
|
+
this.popoverElement && this.options.trigger === "hover" && (d(this.popoverElement, "mouseenter", this._onPopoverEnter), d(this.popoverElement, "mouseleave", this._onMouseLeave));
|
|
193
|
+
}
|
|
194
|
+
_onPopoverEnter = () => {
|
|
195
|
+
this._clearHideTimer();
|
|
196
|
+
};
|
|
197
|
+
_clearHideTimer() {
|
|
198
|
+
this._hideTimer && (clearTimeout(this._hideTimer), this._hideTimer = void 0);
|
|
199
|
+
}
|
|
200
|
+
_onMouseEnter = (t) => {
|
|
201
|
+
const e = t.target;
|
|
202
|
+
this._clearHideTimer(), this.$reference != e && this.show(e);
|
|
203
|
+
};
|
|
204
|
+
_onMouseLeave = () => {
|
|
205
|
+
this._clearHideTimer(), this._hideTimer = setTimeout(() => {
|
|
206
|
+
this.hide();
|
|
207
|
+
}, 50);
|
|
208
|
+
};
|
|
209
|
+
_onRefTap = (t) => {
|
|
210
|
+
this._destroyUpdater();
|
|
211
|
+
const e = t.target;
|
|
212
|
+
if (this.$reference) {
|
|
213
|
+
if (this.options.trigger === "focus") return;
|
|
214
|
+
this.hide();
|
|
215
|
+
return;
|
|
216
|
+
}
|
|
217
|
+
this.show(e);
|
|
218
|
+
};
|
|
219
|
+
/**
|
|
220
|
+
* 显示浮层。
|
|
221
|
+
*
|
|
222
|
+
* @param reference 浮层所对齐的 HTML 元素。
|
|
223
|
+
*/
|
|
224
|
+
show(t) {
|
|
225
|
+
const e = t.dataset;
|
|
226
|
+
let o = e.disabled;
|
|
227
|
+
if (o == null && (o = this.options.disabled), !o && !this.$reference && (this.$reference = t, this.popoverElement || (this._renderPopover(), this._bindPopoverEvents()), this.popoverElement)) {
|
|
228
|
+
this.options.updateContent && this.options.updateContent(this.popoverElement, e), this._destroyUpdater();
|
|
229
|
+
const n = e.placement || this.options.placement || "top", r = Number(e.offset || this.options.offset || 10), i = e.popoverWidth || this.options.popoverWidth;
|
|
230
|
+
this.popoverElement.style.display = "block";
|
|
231
|
+
let p;
|
|
232
|
+
i && (i !== "trigger" ? p = Number(i) : p = i), this.updater = L(this.$reference, this.popoverElement, {
|
|
233
|
+
placement: n,
|
|
234
|
+
popoverWidth: p,
|
|
235
|
+
offset: r,
|
|
236
|
+
arrowSize: this.options.arrowSize
|
|
237
|
+
}), this.options.onOpenChange && this.options.onOpenChange(!0);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
isShow() {
|
|
241
|
+
return this.$reference != null;
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* 隐藏 Popover
|
|
245
|
+
*/
|
|
246
|
+
hide() {
|
|
247
|
+
this._destroyUpdater(), this.popoverElement && (this.popoverElement.style.display = "none"), this.$reference = void 0, this.options.onOpenChange && this.options.onOpenChange(!1);
|
|
248
|
+
}
|
|
249
|
+
/** 重新设置选项 */
|
|
250
|
+
setOption(t, e) {
|
|
251
|
+
this.options[t] = e;
|
|
252
|
+
}
|
|
253
|
+
updatePopoverContent() {
|
|
254
|
+
this.popoverElement && this.options.updateContent && this.options.updateContent(this.popoverElement, {});
|
|
255
|
+
}
|
|
256
|
+
_onOuterTap = (t) => {
|
|
257
|
+
const e = t.target;
|
|
258
|
+
if (this.$reference && !this.$reference.contains(e) && this.$reference != e) {
|
|
259
|
+
if (this.options.trigger === "focus") {
|
|
260
|
+
this.hide();
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
if (this.popoverElement && (this.popoverElement.contains(e) || this.popoverElement == e)) {
|
|
264
|
+
const [o, n, r] = g(
|
|
265
|
+
t,
|
|
266
|
+
"data-action",
|
|
267
|
+
this.popoverElement
|
|
268
|
+
);
|
|
269
|
+
if (o) {
|
|
270
|
+
let i = "";
|
|
271
|
+
n === "popconfirm-cancel" ? i = "cancel" : n === "popconfirm-ok" && (i = "ok"), i && this.hide(), this.options.onPopoverAction && this.options.onPopoverAction(i || n, r);
|
|
272
|
+
}
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
this.hide();
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
_renderPopover() {
|
|
279
|
+
let e = `l-popover l-popover--${this.options.theme || "default"}`;
|
|
280
|
+
this.options.popoverClass && (e += ` ${this.options.popoverClass}`);
|
|
281
|
+
const o = w("div", {
|
|
282
|
+
class: e
|
|
283
|
+
}), n = this.options.contentRender;
|
|
284
|
+
if (n) {
|
|
285
|
+
const r = n();
|
|
286
|
+
typeof r == "string" ? o.innerHTML = r : o.appendChild(r);
|
|
287
|
+
} else {
|
|
288
|
+
const r = w("div", { class: "l-popover-content" });
|
|
289
|
+
o.appendChild(r);
|
|
290
|
+
}
|
|
291
|
+
this.options.arrow && o.appendChild(w("div", { class: "l-popover-arrow" })), document.body.appendChild(o), this.popoverElement = o;
|
|
292
|
+
}
|
|
293
|
+
_destroyUpdater() {
|
|
294
|
+
this.updater && (this.updater.destroy(), this.updater = void 0);
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* 销毁组件
|
|
298
|
+
*
|
|
299
|
+
* 销毁组件并移除相关事件监听器和 DOM 元素。
|
|
300
|
+
*/
|
|
301
|
+
destroy() {
|
|
302
|
+
this.hide(), this.$refs && $(this.$refs, (t) => {
|
|
303
|
+
this._removeReferenceEvents(t);
|
|
304
|
+
}), a(document, "click", this._onOuterTap, { capture: !0 }), this.options = void 0, this.$refs = void 0, this._clearHideTimer(), this.popoverElement && (a(this.popoverElement, "mouseenter", this._onPopoverEnter), a(this.popoverElement, "mouseleave", this._onMouseLeave), this.popoverElement.remove()), this.popoverElement = void 0;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
const S = {
|
|
308
|
+
theme: "popconfirm",
|
|
309
|
+
trigger: "click",
|
|
310
|
+
contentRender: () => {
|
|
311
|
+
const s = [];
|
|
312
|
+
return s.push('<div class="l-popconfirm-container">'), s.push('<div class="l-popconfirm-icon-wrapper">'), s.push("<l-warn-icon></l-warn-icon>"), s.push('</div><div class="l-popconfirm-content"></div></div>'), s.push('<div class="l-popconfirm-footer">'), s.push(
|
|
313
|
+
'<l-button class="l-popconfirm-btn" data-action="popconfirm-cancel">取消</l-button>'
|
|
314
|
+
), s.push(
|
|
315
|
+
'<l-button class="l-popconfirm-btn" type="primary" data-action="popconfirm-ok">确定</l-button>'
|
|
316
|
+
), s.push("</div>"), s.join("");
|
|
317
|
+
},
|
|
318
|
+
updateContent: (s, t) => {
|
|
319
|
+
const e = s.querySelector(".l-popconfirm-content");
|
|
320
|
+
e && t && (e.innerHTML = t.content || "");
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
function x(s, t) {
|
|
324
|
+
return s.classList.contains(t) ? s : y(`.${t}`, s);
|
|
325
|
+
}
|
|
326
|
+
function H(s, t, e) {
|
|
327
|
+
let o = new MutationObserver((n) => {
|
|
328
|
+
n.forEach((r) => {
|
|
329
|
+
r.type === "childList" && ($(r.addedNodes, (i) => {
|
|
330
|
+
let p = x(i, t);
|
|
331
|
+
p && (p instanceof HTMLElement ? e.addReference(p) : $(p, (h) => {
|
|
332
|
+
e.addReference(h);
|
|
333
|
+
}));
|
|
334
|
+
}), $(r.removedNodes, (i) => {
|
|
335
|
+
let p = x(i, t);
|
|
336
|
+
p && (p instanceof HTMLElement ? e.removeReference(p) : $(p, (h) => {
|
|
337
|
+
e.removeReference(h);
|
|
338
|
+
}));
|
|
339
|
+
}));
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
return o.observe(s, {
|
|
343
|
+
childList: !0,
|
|
344
|
+
subtree: !0
|
|
345
|
+
}), o;
|
|
346
|
+
}
|
|
347
|
+
export {
|
|
348
|
+
z as Popover,
|
|
349
|
+
L as autoUpdate,
|
|
350
|
+
H as createPopoverObserver,
|
|
351
|
+
C as getOverflowAncestors,
|
|
352
|
+
S as popconfirmProps,
|
|
353
|
+
b as updatePosition
|
|
354
|
+
};
|