@whitesev/pops 3.1.2 → 3.2.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/dist/index.amd.js +337 -250
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +337 -250
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +337 -250
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +337 -250
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +337 -250
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +337 -250
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +10 -10
- package/dist/types/src/components/panel/index.d.ts +2 -2
- package/dist/types/src/components/rightClickMenu/index.d.ts +1 -1
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +8 -1
- package/dist/types/src/components/tooltip/index.d.ts +5 -5
- package/dist/types/src/components/tooltip/types/index.d.ts +15 -14
- package/dist/types/src/handler/PopsHandler.d.ts +4 -4
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +39 -0
- package/dist/types/src/types/components.d.ts +2 -1
- package/dist/types/src/types/event.d.ts +13 -3
- package/dist/types/src/types/inst.d.ts +4 -0
- package/dist/types/src/utils/PopsDOMUtils.d.ts +10 -12
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +2 -2
- package/package.json +9 -9
- package/src/components/alert/index.ts +3 -1
- package/src/components/confirm/index.ts +3 -1
- package/src/components/drawer/index.ts +3 -1
- package/src/components/folder/index.ts +3 -1
- package/src/components/iframe/index.ts +6 -4
- package/src/components/panel/handlerComponents.ts +26 -26
- package/src/components/panel/index.ts +3 -1
- package/src/components/prompt/index.ts +3 -1
- package/src/components/rightClickMenu/defaultConfig.ts +1 -0
- package/src/components/rightClickMenu/index.ts +18 -7
- package/src/components/rightClickMenu/types/index.ts +8 -1
- package/src/components/searchSuggestion/index.ts +7 -19
- package/src/components/tooltip/defaultConfig.ts +1 -1
- package/src/components/tooltip/index.ts +38 -23
- package/src/components/tooltip/types/index.ts +15 -14
- package/src/handler/PopsHandler.ts +22 -19
- package/src/types/PopsDOMUtilsEventType.d.ts +39 -0
- package/src/types/components.d.ts +2 -1
- package/src/types/event.d.ts +13 -3
- package/src/types/inst.d.ts +4 -0
- package/src/utils/PopsDOMUtils.ts +71 -40
- package/src/utils/PopsInstanceUtils.ts +62 -30
- package/src/utils/PopsUtils.ts +1 -1
|
@@ -1284,7 +1284,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1284
1284
|
* 监听输入框内容改变
|
|
1285
1285
|
*/
|
|
1286
1286
|
onValueChange() {
|
|
1287
|
-
popsDOMUtils.on<InputEvent>(this.$el.input, ["input", "propertychange"],
|
|
1287
|
+
popsDOMUtils.on<InputEvent>(this.$el.input, ["input", "propertychange"], (event) => {
|
|
1288
1288
|
this.$data.value = this.$el.input.value;
|
|
1289
1289
|
if (inputType !== "password") {
|
|
1290
1290
|
// 不是密码框
|
|
@@ -1673,7 +1673,7 @@ export const PanelHandlerComponents = () => {
|
|
|
1673
1673
|
* 监听点击事件
|
|
1674
1674
|
*/
|
|
1675
1675
|
onClick() {
|
|
1676
|
-
popsDOMUtils.on(this.$el.$select, "click",
|
|
1676
|
+
popsDOMUtils.on(this.$el.$select, "click", (event) => {
|
|
1677
1677
|
this.setSelectOptionsDisableStatus();
|
|
1678
1678
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
1679
1679
|
const $isSelectedElement = this.$el.$select[this.$el.$select.selectedIndex] as HTMLOptionElement;
|
|
@@ -3461,7 +3461,7 @@ export const PanelHandlerComponents = () => {
|
|
|
3461
3461
|
* 设置按钮的点击事件
|
|
3462
3462
|
*/
|
|
3463
3463
|
onButtonClick() {
|
|
3464
|
-
popsDOMUtils.on(this.$ele.button, "click",
|
|
3464
|
+
popsDOMUtils.on(this.$ele.button, "click", (event) => {
|
|
3465
3465
|
if (typeof viewConfig.callback === "function") {
|
|
3466
3466
|
viewConfig.callback(event);
|
|
3467
3467
|
}
|
|
@@ -3533,13 +3533,13 @@ export const PanelHandlerComponents = () => {
|
|
|
3533
3533
|
initContainerItem($container: HTMLElement, formItemConfig: PopsPanelViewConfig | PopsPanelContainerConfig) {
|
|
3534
3534
|
const containerViewConfig = formItemConfig as PopsPanelContainerConfig;
|
|
3535
3535
|
if (containerViewConfig.type === "container") {
|
|
3536
|
-
const
|
|
3536
|
+
const childViewConfig = containerViewConfig["views"];
|
|
3537
3537
|
// 每一项<li>元素
|
|
3538
|
-
const
|
|
3538
|
+
const $itemLi = popsDOMUtils.createElement("li");
|
|
3539
3539
|
// 每一项<li>内的子<ul>元素
|
|
3540
|
-
const
|
|
3541
|
-
|
|
3542
|
-
|
|
3540
|
+
const $itemUL = popsDOMUtils.createElement("ul");
|
|
3541
|
+
$itemUL.classList.add("pops-panel-forms-container-item-formlist");
|
|
3542
|
+
$itemLi.classList.add("pops-panel-forms-container-item");
|
|
3543
3543
|
// 区域头部的文字
|
|
3544
3544
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
3545
3545
|
className: "pops-panel-forms-container-item-header-text",
|
|
@@ -3562,41 +3562,41 @@ export const PanelHandlerComponents = () => {
|
|
|
3562
3562
|
);
|
|
3563
3563
|
// 添加点击事件
|
|
3564
3564
|
popsDOMUtils.on(formHeaderDivElement, "click", () => {
|
|
3565
|
-
if (
|
|
3566
|
-
|
|
3565
|
+
if ($itemLi.hasAttribute("data-fold-enable")) {
|
|
3566
|
+
$itemLi.removeAttribute("data-fold-enable");
|
|
3567
3567
|
} else {
|
|
3568
|
-
|
|
3568
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
3569
3569
|
}
|
|
3570
3570
|
});
|
|
3571
3571
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold-container");
|
|
3572
3572
|
popsDOMUtils.addClassName(formHeaderDivElement, PopsCommonCSSClassName.userSelectNone);
|
|
3573
|
-
|
|
3573
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
3574
3574
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
3575
|
-
|
|
3575
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
3576
3576
|
} else {
|
|
3577
3577
|
// 加进容器内
|
|
3578
|
-
|
|
3578
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
3579
3579
|
}
|
|
3580
3580
|
|
|
3581
|
-
that.setElementClassName(
|
|
3582
|
-
that.setElementAttributes(
|
|
3583
|
-
that.setElementProps(
|
|
3584
|
-
|
|
3581
|
+
that.setElementClassName($itemLi, formItemConfig.className);
|
|
3582
|
+
that.setElementAttributes($itemLi, formItemConfig.attributes);
|
|
3583
|
+
that.setElementProps($itemLi, formItemConfig.props);
|
|
3584
|
+
$itemLi.appendChild($itemUL);
|
|
3585
|
+
$container.appendChild($itemLi);
|
|
3586
|
+
childViewConfig.forEach((childViewConfig) => {
|
|
3585
3587
|
that.uListContainerAddItem(childViewConfig, {
|
|
3586
|
-
ulElement:
|
|
3588
|
+
ulElement: $itemUL,
|
|
3587
3589
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
3588
|
-
formContainerListElement:
|
|
3590
|
+
formContainerListElement: $itemLi,
|
|
3589
3591
|
formHeaderDivElement: formHeaderDivElement,
|
|
3590
3592
|
});
|
|
3591
3593
|
});
|
|
3592
|
-
formContainerListElement.appendChild(formContainerULElement);
|
|
3593
|
-
$container.appendChild(formContainerListElement);
|
|
3594
3594
|
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
3595
3595
|
containerViewConfig.afterAddToUListCallBack(viewConfig as any as PopsPanelContainerConfig, {
|
|
3596
|
-
target:
|
|
3597
|
-
ulElement:
|
|
3596
|
+
target: $itemLi,
|
|
3597
|
+
ulElement: $itemUL,
|
|
3598
3598
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
3599
|
-
formContainerListElement:
|
|
3599
|
+
formContainerListElement: $itemLi,
|
|
3600
3600
|
formHeaderDivElement: formHeaderDivElement,
|
|
3601
3601
|
});
|
|
3602
3602
|
}
|
|
@@ -3747,7 +3747,7 @@ export const PanelHandlerComponents = () => {
|
|
|
3747
3747
|
},
|
|
3748
3748
|
/** 设置项的点击事件 */
|
|
3749
3749
|
onLiClick() {
|
|
3750
|
-
popsDOMUtils.on($li, "click",
|
|
3750
|
+
popsDOMUtils.on($li, "click", async (event) => {
|
|
3751
3751
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
3752
3752
|
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
3753
3753
|
if (result) {
|
|
@@ -146,6 +146,7 @@ export const PopsPanel = {
|
|
|
146
146
|
$pops,
|
|
147
147
|
$mask
|
|
148
148
|
);
|
|
149
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
149
150
|
// 为顶部右边的关闭按钮添加点击事件
|
|
150
151
|
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
151
152
|
|
|
@@ -185,6 +186,8 @@ export const PopsPanel = {
|
|
|
185
186
|
$mask: $mask!,
|
|
186
187
|
$shadowContainer: $shadowContainer,
|
|
187
188
|
$shadowRoot: $shadowRoot,
|
|
189
|
+
config: config,
|
|
190
|
+
destory: result.close,
|
|
188
191
|
});
|
|
189
192
|
// 拖拽
|
|
190
193
|
if (config.drag) {
|
|
@@ -196,7 +199,6 @@ export const PopsPanel = {
|
|
|
196
199
|
endCallBack: config.dragEndCallBack,
|
|
197
200
|
});
|
|
198
201
|
}
|
|
199
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
200
202
|
|
|
201
203
|
return {
|
|
202
204
|
...result,
|
|
@@ -133,6 +133,7 @@ export const PopsPrompt = {
|
|
|
133
133
|
$pops,
|
|
134
134
|
$mask
|
|
135
135
|
);
|
|
136
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
136
137
|
// 输入框赋值初始值
|
|
137
138
|
|
|
138
139
|
$input.value = config.content.text;
|
|
@@ -188,6 +189,8 @@ export const PopsPrompt = {
|
|
|
188
189
|
$mask: $mask!,
|
|
189
190
|
$shadowContainer: $shadowContainer,
|
|
190
191
|
$shadowRoot: $shadowRoot,
|
|
192
|
+
config: config,
|
|
193
|
+
destory: result.close,
|
|
191
194
|
});
|
|
192
195
|
// 拖拽
|
|
193
196
|
if (config.drag) {
|
|
@@ -207,7 +210,6 @@ export const PopsPrompt = {
|
|
|
207
210
|
if (config.content.select) {
|
|
208
211
|
$input.select();
|
|
209
212
|
}
|
|
210
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
211
213
|
return result;
|
|
212
214
|
},
|
|
213
215
|
};
|
|
@@ -80,6 +80,8 @@ export const PopsRightClickMenu = {
|
|
|
80
80
|
return;
|
|
81
81
|
}
|
|
82
82
|
if ($click.className && $click.className === "pops-shadow-container" && $click.shadowRoot != null) {
|
|
83
|
+
// pops的shadow-container
|
|
84
|
+
PopsContextMenu.shadowRootCheckClickEvent(event);
|
|
83
85
|
return;
|
|
84
86
|
}
|
|
85
87
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
@@ -92,7 +94,7 @@ export const PopsRightClickMenu = {
|
|
|
92
94
|
if (!PopsContextMenu.$el.$root) {
|
|
93
95
|
return;
|
|
94
96
|
}
|
|
95
|
-
const $click = event.
|
|
97
|
+
const $click = event.composedPath()[0] as HTMLElement;
|
|
96
98
|
if ($click.closest(`.pops-${popsType}`)) {
|
|
97
99
|
return;
|
|
98
100
|
}
|
|
@@ -102,13 +104,13 @@ export const PopsRightClickMenu = {
|
|
|
102
104
|
* 添加全局点击检测事件
|
|
103
105
|
*/
|
|
104
106
|
addWindowCheckClickListener() {
|
|
105
|
-
popsDOMUtils.on(globalThis, "click touchstart",
|
|
107
|
+
popsDOMUtils.on(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
106
108
|
capture: true,
|
|
107
109
|
});
|
|
108
110
|
if (config.$target instanceof Node) {
|
|
109
111
|
const $shadowRoot = config.$target.getRootNode();
|
|
110
112
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
111
|
-
popsDOMUtils.on($shadowRoot, "click touchstart",
|
|
113
|
+
popsDOMUtils.on($shadowRoot, "click touchstart", PopsContextMenu.shadowRootCheckClickEvent, {
|
|
112
114
|
capture: true,
|
|
113
115
|
});
|
|
114
116
|
}
|
|
@@ -118,13 +120,13 @@ export const PopsRightClickMenu = {
|
|
|
118
120
|
* 移除全局点击检测事件
|
|
119
121
|
*/
|
|
120
122
|
removeWindowCheckClickListener() {
|
|
121
|
-
popsDOMUtils.off(globalThis, "click touchstart",
|
|
123
|
+
popsDOMUtils.off(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
122
124
|
capture: true,
|
|
123
125
|
});
|
|
124
126
|
if (config.$target instanceof Node) {
|
|
125
127
|
const $shadowRoot = config.$target.getRootNode();
|
|
126
128
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
127
|
-
popsDOMUtils.off($shadowRoot, "click touchstart",
|
|
129
|
+
popsDOMUtils.off($shadowRoot, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
128
130
|
capture: true,
|
|
129
131
|
});
|
|
130
132
|
}
|
|
@@ -135,7 +137,7 @@ export const PopsRightClickMenu = {
|
|
|
135
137
|
* @param event
|
|
136
138
|
* @param selectorTarget
|
|
137
139
|
*/
|
|
138
|
-
contextMenuEvent(event: PointerEvent, selectorTarget: NonNullable<PopsRightClickMenuConfig["$target"]>) {
|
|
140
|
+
async contextMenuEvent(event: PointerEvent, selectorTarget: NonNullable<PopsRightClickMenuConfig["$target"]>) {
|
|
139
141
|
if (config.preventDefault) {
|
|
140
142
|
popsDOMUtils.preventEvent(event);
|
|
141
143
|
}
|
|
@@ -144,6 +146,10 @@ export const PopsRightClickMenu = {
|
|
|
144
146
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
145
147
|
}
|
|
146
148
|
selectorTarget = selectorTarget ?? config.$target;
|
|
149
|
+
const beforeShowCallBackResult = await config?.beforeShowCallBack(event);
|
|
150
|
+
if (typeof beforeShowCallBackResult === "boolean" && !beforeShowCallBackResult) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
147
153
|
const rootElement = PopsContextMenu.showMenu(event, config.data, selectorTarget);
|
|
148
154
|
PopsContextMenu.$el.$root = rootElement;
|
|
149
155
|
if (config.only) {
|
|
@@ -156,6 +162,10 @@ export const PopsRightClickMenu = {
|
|
|
156
162
|
beforeRemoveCallBack(instCommonConfig) {
|
|
157
163
|
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
158
164
|
},
|
|
165
|
+
config: config,
|
|
166
|
+
destory: () => {
|
|
167
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
168
|
+
},
|
|
159
169
|
});
|
|
160
170
|
}
|
|
161
171
|
},
|
|
@@ -506,7 +516,8 @@ export const PopsRightClickMenu = {
|
|
|
506
516
|
menuLiElement.appendChild(iconElement);
|
|
507
517
|
}
|
|
508
518
|
// 插入文字
|
|
509
|
-
|
|
519
|
+
const text = typeof item.text === "function" ? item.text() : item.text;
|
|
520
|
+
menuLiElement.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(`<span>${text}</span>`));
|
|
510
521
|
// 如果存在子数据,显示
|
|
511
522
|
if (item.item && Array.isArray(item.item)) {
|
|
512
523
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
@@ -41,7 +41,7 @@ export interface PopsRightClickMenuDataConfig {
|
|
|
41
41
|
/**
|
|
42
42
|
* 文字
|
|
43
43
|
*/
|
|
44
|
-
text: string
|
|
44
|
+
text: IFunction<string>;
|
|
45
45
|
/**
|
|
46
46
|
* 点击的回调函数
|
|
47
47
|
* @param clickEvent 点击菜单的click事件
|
|
@@ -133,4 +133,11 @@ export interface PopsRightClickMenuConfig
|
|
|
133
133
|
* @default true
|
|
134
134
|
*/
|
|
135
135
|
limitPositionYInView?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* 菜单显示前的回调
|
|
138
|
+
* @returns
|
|
139
|
+
*
|
|
140
|
+
* + `false`:阻止默认行为(显示菜单)
|
|
141
|
+
*/
|
|
142
|
+
beforeShowCallBack?(event: PointerEvent): IPromise<false | void>;
|
|
136
143
|
}
|
|
@@ -488,9 +488,9 @@ export const PopsSearchSuggestion = {
|
|
|
488
488
|
setShowEvent(option: AddEventListenerOptions = defaultListenerOption) {
|
|
489
489
|
/* 焦点|点击事件*/
|
|
490
490
|
if (config.followPosition === "target") {
|
|
491
|
-
popsDOMUtils.on([config.$target], ["focus", "click"],
|
|
491
|
+
popsDOMUtils.on([config.$target], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
492
492
|
} else if (config.followPosition === "input") {
|
|
493
|
-
popsDOMUtils.on([config.$inputTarget], ["focus", "click"],
|
|
493
|
+
popsDOMUtils.on([config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
494
494
|
} else if (config.followPosition === "inputCursor") {
|
|
495
495
|
popsDOMUtils.on([config.$inputTarget], ["focus", "click", "input"], SearchSuggestion.showEvent, option);
|
|
496
496
|
} else {
|
|
@@ -502,15 +502,9 @@ export const PopsSearchSuggestion = {
|
|
|
502
502
|
*/
|
|
503
503
|
removeShowEvent(option: AddEventListenerOptions = defaultListenerOption) {
|
|
504
504
|
/* 焦点|点击事件*/
|
|
505
|
-
popsDOMUtils.off(
|
|
506
|
-
[config.$target, config.$inputTarget],
|
|
507
|
-
["focus", "click"],
|
|
508
|
-
void 0,
|
|
509
|
-
SearchSuggestion.showEvent,
|
|
510
|
-
option
|
|
511
|
-
);
|
|
505
|
+
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
512
506
|
// 内容改变事件
|
|
513
|
-
popsDOMUtils.off([config.$inputTarget], ["input"],
|
|
507
|
+
popsDOMUtils.off([config.$inputTarget], ["input"], SearchSuggestion.showEvent, option);
|
|
514
508
|
},
|
|
515
509
|
/**
|
|
516
510
|
* 隐藏搜索建议框的事件
|
|
@@ -541,7 +535,7 @@ export const PopsSearchSuggestion = {
|
|
|
541
535
|
// 全局触摸屏点击事件
|
|
542
536
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
543
537
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
544
|
-
popsDOMUtils.on($checkParent, ["click", "touchstart"],
|
|
538
|
+
popsDOMUtils.on($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
545
539
|
});
|
|
546
540
|
} else {
|
|
547
541
|
popsDOMUtils.on(SearchSuggestion.selfDocument, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
@@ -553,16 +547,10 @@ export const PopsSearchSuggestion = {
|
|
|
553
547
|
removeHideEvent(option: AddEventListenerOptions = defaultListenerOption) {
|
|
554
548
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
555
549
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
556
|
-
popsDOMUtils.off($checkParent, ["click", "touchstart"],
|
|
550
|
+
popsDOMUtils.off($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
557
551
|
});
|
|
558
552
|
} else {
|
|
559
|
-
popsDOMUtils.off(
|
|
560
|
-
SearchSuggestion.selfDocument,
|
|
561
|
-
["click", "touchstart"],
|
|
562
|
-
void 0,
|
|
563
|
-
SearchSuggestion.hideEvent,
|
|
564
|
-
option
|
|
565
|
-
);
|
|
553
|
+
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
566
554
|
}
|
|
567
555
|
},
|
|
568
556
|
/**
|
|
@@ -11,7 +11,7 @@ export const PopsTooltipDefaultConfig = (): DeepRequired<PopsToolTipConfig> => {
|
|
|
11
11
|
isFixed: false,
|
|
12
12
|
alwaysShow: false,
|
|
13
13
|
onShowEventName: "mouseenter touchstart",
|
|
14
|
-
onCloseEventName: "mouseleave touchend",
|
|
14
|
+
onCloseEventName: "mouseleave touchend touchcancel",
|
|
15
15
|
zIndex: 10000,
|
|
16
16
|
only: false,
|
|
17
17
|
eventOption: {
|
|
@@ -240,14 +240,14 @@ export class ToolTip {
|
|
|
240
240
|
this.$data.config.otherDistance,
|
|
241
241
|
event
|
|
242
242
|
);
|
|
243
|
-
const positionKey = this.$data.config.position.toUpperCase() as
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
this.$el.$toolTip.style.left =
|
|
247
|
-
this.$el.$toolTip.style.top =
|
|
248
|
-
this.$el.$toolTip.setAttribute("data-motion",
|
|
243
|
+
const positionKey = this.$data.config.position.toUpperCase() as keyof typeof positionInfo;
|
|
244
|
+
const position = positionInfo[positionKey];
|
|
245
|
+
if (position) {
|
|
246
|
+
this.$el.$toolTip.style.left = position.left + "px";
|
|
247
|
+
this.$el.$toolTip.style.top = position.top + "px";
|
|
248
|
+
this.$el.$toolTip.setAttribute("data-motion", position.motion);
|
|
249
249
|
|
|
250
|
-
this.$el.$arrow.setAttribute("data-position",
|
|
250
|
+
this.$el.$arrow.setAttribute("data-position", position.arrow);
|
|
251
251
|
} else {
|
|
252
252
|
console.error("不存在该位置", this.$data.config.position);
|
|
253
253
|
}
|
|
@@ -358,9 +358,12 @@ export class ToolTip {
|
|
|
358
358
|
* 取消绑定 显示事件
|
|
359
359
|
*/
|
|
360
360
|
offShowEvent() {
|
|
361
|
-
popsDOMUtils.off(
|
|
362
|
-
|
|
363
|
-
|
|
361
|
+
popsDOMUtils.off(
|
|
362
|
+
this.$data.config.$target,
|
|
363
|
+
this.$data.config.onShowEventName,
|
|
364
|
+
this.show,
|
|
365
|
+
this.$data.config.eventOption
|
|
366
|
+
);
|
|
364
367
|
}
|
|
365
368
|
/**
|
|
366
369
|
* 关闭提示框
|
|
@@ -428,22 +431,25 @@ export class ToolTip {
|
|
|
428
431
|
* 取消绑定 关闭事件
|
|
429
432
|
*/
|
|
430
433
|
offCloseEvent() {
|
|
431
|
-
popsDOMUtils.off(
|
|
432
|
-
|
|
433
|
-
|
|
434
|
+
popsDOMUtils.off(
|
|
435
|
+
this.$data.config.$target,
|
|
436
|
+
this.$data.config.onCloseEventName,
|
|
437
|
+
this.close,
|
|
438
|
+
this.$data.config.eventOption
|
|
439
|
+
);
|
|
434
440
|
}
|
|
435
441
|
/**
|
|
436
442
|
* 销毁元素
|
|
437
443
|
*/
|
|
438
444
|
destory() {
|
|
439
445
|
if (this.$el.$toolTip) {
|
|
440
|
-
this.$el.$
|
|
446
|
+
this.$el.$toolTip.remove();
|
|
441
447
|
}
|
|
442
|
-
// @ts-
|
|
448
|
+
// @ts-expect-error
|
|
443
449
|
this.$el.$toolTip = null;
|
|
444
|
-
// @ts-
|
|
450
|
+
// @ts-expect-error
|
|
445
451
|
this.$el.$arrow = null;
|
|
446
|
-
// @ts-
|
|
452
|
+
// @ts-expect-error
|
|
447
453
|
this.$el.$content = null;
|
|
448
454
|
}
|
|
449
455
|
/**
|
|
@@ -496,7 +502,7 @@ export class ToolTip {
|
|
|
496
502
|
);
|
|
497
503
|
}
|
|
498
504
|
/**
|
|
499
|
-
*
|
|
505
|
+
* 取消监听事件 - 鼠标|触摸
|
|
500
506
|
*/
|
|
501
507
|
offToolTipMouseEnterEvent() {
|
|
502
508
|
popsDOMUtils.off(
|
|
@@ -507,30 +513,30 @@ export class ToolTip {
|
|
|
507
513
|
);
|
|
508
514
|
}
|
|
509
515
|
/**
|
|
510
|
-
*
|
|
516
|
+
* 离开事件 - 鼠标|触摸
|
|
511
517
|
*/
|
|
512
518
|
toolTipMouseLeaveEvent(event: MouseEvent | PointerEvent) {
|
|
513
519
|
this.close(event);
|
|
514
520
|
// this.$el.$toolTip.style.animationPlayState = "running";
|
|
515
521
|
}
|
|
516
522
|
/**
|
|
517
|
-
*
|
|
523
|
+
* 监听离开事件 - 鼠标|触摸
|
|
518
524
|
*/
|
|
519
525
|
onToolTipMouseLeaveEvent() {
|
|
520
526
|
popsDOMUtils.on(
|
|
521
527
|
this.$el.$toolTip,
|
|
522
|
-
"mouseleave touchend",
|
|
528
|
+
"mouseleave touchend touchcancel",
|
|
523
529
|
this.toolTipMouseLeaveEvent,
|
|
524
530
|
this.$data.config.eventOption
|
|
525
531
|
);
|
|
526
532
|
}
|
|
527
533
|
/**
|
|
528
|
-
*
|
|
534
|
+
* 取消监听离开事件 - 鼠标|触摸
|
|
529
535
|
*/
|
|
530
536
|
offToolTipMouseLeaveEvent() {
|
|
531
537
|
popsDOMUtils.off(
|
|
532
538
|
this.$el.$toolTip,
|
|
533
|
-
"mouseleave touchend",
|
|
539
|
+
"mouseleave touchend touchcancel",
|
|
534
540
|
this.toolTipMouseLeaveEvent,
|
|
535
541
|
this.$data.config.eventOption
|
|
536
542
|
);
|
|
@@ -559,6 +565,15 @@ export const PopsTooltip = {
|
|
|
559
565
|
}
|
|
560
566
|
config = PopsHandler.handleOnly(popsType, config);
|
|
561
567
|
|
|
568
|
+
if (config.position === "follow") {
|
|
569
|
+
config.onShowEventName = config.onShowEventName.trim();
|
|
570
|
+
const showEventNameSplit = config.onShowEventName.split(" ");
|
|
571
|
+
["mousemove", "touchmove"].forEach((it) => {
|
|
572
|
+
if (showEventNameSplit.includes(it)) return;
|
|
573
|
+
config.onShowEventName += ` ${it}`;
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
|
|
562
577
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
563
578
|
PopsHandler.handleInit($shadowRoot, [
|
|
564
579
|
{
|
|
@@ -18,35 +18,34 @@ export interface PopsToolTipConfig
|
|
|
18
18
|
*/
|
|
19
19
|
content: string | (() => string);
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* 是否比较获取到的`content`的内容是否改变
|
|
22
22
|
*
|
|
23
|
-
*
|
|
23
|
+
* 如果未改变,则在触发`.show`时不修改内容
|
|
24
24
|
* @default false
|
|
25
25
|
*/
|
|
26
26
|
isDiffContent?: boolean;
|
|
27
27
|
/**
|
|
28
28
|
* 位置
|
|
29
|
-
* + `follow`
|
|
29
|
+
* + `follow` 跟随(鼠标|触摸)的位置而移动
|
|
30
30
|
* @default "top"
|
|
31
31
|
*/
|
|
32
32
|
position?: PopsTooltipPosition;
|
|
33
33
|
/**
|
|
34
34
|
* 自定义className
|
|
35
35
|
*
|
|
36
|
-
* + `github-tooltip
|
|
36
|
+
* + `github-tooltip`:github的样式
|
|
37
37
|
* @default ""
|
|
38
38
|
*/
|
|
39
39
|
className?: PopsPanelGeneralConfig<any>["className"];
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
41
|
+
* 是否使用`fixed`定位,`false`则是`absolute`定位
|
|
43
42
|
* @default false
|
|
44
43
|
*/
|
|
45
44
|
isFixed?: boolean;
|
|
46
45
|
/**
|
|
47
46
|
* 是否总是显示,默认为false
|
|
48
|
-
* + true
|
|
49
|
-
*
|
|
47
|
+
* + true 设置的`onShowEventName`、`onCloseEventName`将无效
|
|
48
|
+
* 返回提供`show`和`close`函数,取消`on`和`off`
|
|
50
49
|
* + false 事件触发才显示
|
|
51
50
|
*/
|
|
52
51
|
alwaysShow?: boolean;
|
|
@@ -56,13 +55,15 @@ export interface PopsToolTipConfig
|
|
|
56
55
|
*/
|
|
57
56
|
delayCloseTime?: number;
|
|
58
57
|
/**
|
|
59
|
-
*
|
|
58
|
+
* 触发显示事件的名称,默认`mouseenter`、`touchstart`,如果是多个事件,按空格分割
|
|
59
|
+
*
|
|
60
|
+
* 如果`position`为`follow`,则添加`mousemove`、`touchmove`事件监听
|
|
60
61
|
* @default "mouseenter touchstart"
|
|
61
62
|
*/
|
|
62
63
|
onShowEventName?: string;
|
|
63
64
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @default "mouseleave touchend"
|
|
65
|
+
* 触发关闭事件的名称,默认`mouseleave`、`touchend`、`touchcancel`,如果是多个事件,按空格分割
|
|
66
|
+
* @default "mouseleave touchend touchcancel"
|
|
66
67
|
*/
|
|
67
68
|
onCloseEventName?: string;
|
|
68
69
|
/**
|
|
@@ -111,9 +112,9 @@ export interface PopsToolTipConfig
|
|
|
111
112
|
arrowDistance?: number;
|
|
112
113
|
/**
|
|
113
114
|
* 其它的距离(px)
|
|
114
|
-
* +
|
|
115
|
-
* +
|
|
116
|
-
* +
|
|
115
|
+
* + 当`position`为`left`或者`right`,这个距离是上、下距离
|
|
116
|
+
* + 当`position`为`top`或者`bottom`,这个距离是左、右距离
|
|
117
|
+
* + 当`position`为`follow`,这个距离是上、左距离
|
|
117
118
|
* @default 0
|
|
118
119
|
*/
|
|
119
120
|
otherDistance?: number;
|