@whitesev/pops 1.6.6 → 1.7.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 +44 -34
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +44 -34
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +44 -34
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +44 -34
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +44 -34
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +44 -34
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +1 -1
- package/dist/types/src/utils/PopsDOMUtils.d.ts +2 -2
- package/package.json +1 -1
- package/src/components/rightClickMenu/index.ts +2 -10
- package/src/components/searchSuggestion/index.ts +20 -27
- package/src/utils/PopsDOMUtils.ts +22 -10
package/dist/index.umd.js
CHANGED
|
@@ -2911,24 +2911,41 @@
|
|
|
2911
2911
|
}
|
|
2912
2912
|
/**
|
|
2913
2913
|
* 用于显示元素并获取它的高度宽度等其它属性
|
|
2914
|
-
* @param
|
|
2914
|
+
* @param $ele
|
|
2915
2915
|
* @param parent 父元素
|
|
2916
2916
|
*/
|
|
2917
|
-
showElement(
|
|
2917
|
+
showElement($ele, ownParent) {
|
|
2918
2918
|
/** 克隆元素 */
|
|
2919
|
-
let cloneNode =
|
|
2920
|
-
cloneNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
|
|
2921
|
-
parent.
|
|
2919
|
+
let $cloneNode = $ele.cloneNode(true);
|
|
2920
|
+
$cloneNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
|
|
2921
|
+
let $parent = PopsCore.document.documentElement;
|
|
2922
|
+
// 这里需要的是先获取元素的父节点,把元素同样添加到父节点中
|
|
2923
|
+
let $root = $ele.getRootNode();
|
|
2924
|
+
if (ownParent == null) {
|
|
2925
|
+
if ($root == $ele) {
|
|
2926
|
+
// 未添加到任意节点中,那么直接添加到页面中去
|
|
2927
|
+
$parent = PopsCore.document.documentElement;
|
|
2928
|
+
}
|
|
2929
|
+
else {
|
|
2930
|
+
// 添加到父节点中
|
|
2931
|
+
$parent = $root;
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
else {
|
|
2935
|
+
// 自定义的父节点
|
|
2936
|
+
$parent = ownParent;
|
|
2937
|
+
}
|
|
2938
|
+
$parent.appendChild($cloneNode);
|
|
2922
2939
|
return {
|
|
2923
2940
|
/**
|
|
2924
2941
|
* 强制显示的克隆的元素
|
|
2925
2942
|
*/
|
|
2926
|
-
cloneNode: cloneNode,
|
|
2943
|
+
cloneNode: $cloneNode,
|
|
2927
2944
|
/**
|
|
2928
2945
|
* 恢复修改的style
|
|
2929
2946
|
*/
|
|
2930
2947
|
recovery() {
|
|
2931
|
-
cloneNode.remove();
|
|
2948
|
+
$cloneNode.remove();
|
|
2932
2949
|
},
|
|
2933
2950
|
};
|
|
2934
2951
|
}
|
|
@@ -10063,8 +10080,8 @@
|
|
|
10063
10080
|
* @param y
|
|
10064
10081
|
*/
|
|
10065
10082
|
getOffset(menuElement, x, y) {
|
|
10066
|
-
let menuElementWidth = popsDOMUtils.width(menuElement
|
|
10067
|
-
let menuElementHeight = popsDOMUtils.height(menuElement
|
|
10083
|
+
let menuElementWidth = popsDOMUtils.width(menuElement);
|
|
10084
|
+
let menuElementHeight = popsDOMUtils.height(menuElement);
|
|
10068
10085
|
/* left最大偏移 */
|
|
10069
10086
|
let maxLeftOffset = popsDOMUtils.width(globalThis) - menuElementWidth - 1;
|
|
10070
10087
|
/* top最大偏移 */
|
|
@@ -10542,6 +10559,7 @@
|
|
|
10542
10559
|
setInputChangeEvent(option = {
|
|
10543
10560
|
capture: true,
|
|
10544
10561
|
}) {
|
|
10562
|
+
/* 必须是input或者textarea才有input事件 */
|
|
10545
10563
|
if (!(config.inputTarget instanceof HTMLInputElement ||
|
|
10546
10564
|
config.inputTarget instanceof HTMLTextAreaElement)) {
|
|
10547
10565
|
return;
|
|
@@ -10746,7 +10764,22 @@
|
|
|
10746
10764
|
}
|
|
10747
10765
|
// 文档最大宽度
|
|
10748
10766
|
let documentWidth = popsDOMUtils.width(document);
|
|
10749
|
-
|
|
10767
|
+
let position = config.position;
|
|
10768
|
+
if (config.position === "auto") {
|
|
10769
|
+
// 需目标高度+搜索建议框高度大于文档高度,则显示在上面
|
|
10770
|
+
let targetBottom = targetRect.bottom;
|
|
10771
|
+
let searchSuggestionContainerHeight = popsDOMUtils.height(SearchSuggestion.$el.$hintULContainer);
|
|
10772
|
+
if (targetBottom + searchSuggestionContainerHeight > documentHeight) {
|
|
10773
|
+
// 在上面
|
|
10774
|
+
position = "top";
|
|
10775
|
+
}
|
|
10776
|
+
else {
|
|
10777
|
+
// 在下面
|
|
10778
|
+
position = "bottom";
|
|
10779
|
+
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
10780
|
+
}
|
|
10781
|
+
}
|
|
10782
|
+
if (position === "top") {
|
|
10750
10783
|
if (config.positionTopToReverse) {
|
|
10751
10784
|
SearchSuggestion.$el.$hintULContainer.setAttribute("data-top-reverse", "true");
|
|
10752
10785
|
}
|
|
@@ -10755,36 +10788,13 @@
|
|
|
10755
10788
|
SearchSuggestion.$el.$hintULContainer.style.bottom =
|
|
10756
10789
|
documentHeight - targetRect.top + config.topDistance + "px";
|
|
10757
10790
|
}
|
|
10758
|
-
else if (
|
|
10791
|
+
else if (position === "bottom") {
|
|
10759
10792
|
// 在下面
|
|
10760
10793
|
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top-reverse");
|
|
10761
10794
|
SearchSuggestion.$el.$hintULContainer.style.bottom = "";
|
|
10762
10795
|
SearchSuggestion.$el.$hintULContainer.style.top =
|
|
10763
10796
|
targetRect.height + targetRect.top + config.topDistance + "px";
|
|
10764
10797
|
}
|
|
10765
|
-
else if (config.position === "auto") {
|
|
10766
|
-
// 自动判断
|
|
10767
|
-
if (targetRect.bottom +
|
|
10768
|
-
popsDOMUtils.height(SearchSuggestion.$el.$hintULContainer) >
|
|
10769
|
-
documentHeight) {
|
|
10770
|
-
if (config.positionTopToReverse) {
|
|
10771
|
-
SearchSuggestion.$el.$hintULContainer.setAttribute("data-top-reverse", "true");
|
|
10772
|
-
}
|
|
10773
|
-
// 超出浏览器高度了,自动转换为上面去
|
|
10774
|
-
SearchSuggestion.$el.$hintULContainer.style.top = "";
|
|
10775
|
-
SearchSuggestion.$el.$hintULContainer.style.bottom =
|
|
10776
|
-
documentHeight - targetRect.top + config.topDistance + "px";
|
|
10777
|
-
}
|
|
10778
|
-
else {
|
|
10779
|
-
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
10780
|
-
SearchSuggestion.$el.$hintULContainer.style.bottom = "";
|
|
10781
|
-
SearchSuggestion.$el.$hintULContainer.style.top =
|
|
10782
|
-
targetRect.height + targetRect.top + config.topDistance + "px";
|
|
10783
|
-
}
|
|
10784
|
-
}
|
|
10785
|
-
else {
|
|
10786
|
-
throw new TypeError("未知设置的位置" + config.position);
|
|
10787
|
-
}
|
|
10788
10798
|
let hintUIWidth = popsDOMUtils.width(SearchSuggestion.$el.$hintULContainer);
|
|
10789
10799
|
SearchSuggestion.$el.$hintULContainer.style.left =
|
|
10790
10800
|
(targetRect.left + hintUIWidth > documentWidth
|