@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.amd.js
CHANGED
|
@@ -2907,24 +2907,41 @@ define((function () { 'use strict';
|
|
|
2907
2907
|
}
|
|
2908
2908
|
/**
|
|
2909
2909
|
* 用于显示元素并获取它的高度宽度等其它属性
|
|
2910
|
-
* @param
|
|
2910
|
+
* @param $ele
|
|
2911
2911
|
* @param parent 父元素
|
|
2912
2912
|
*/
|
|
2913
|
-
showElement(
|
|
2913
|
+
showElement($ele, ownParent) {
|
|
2914
2914
|
/** 克隆元素 */
|
|
2915
|
-
let cloneNode =
|
|
2916
|
-
cloneNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
|
|
2917
|
-
parent.
|
|
2915
|
+
let $cloneNode = $ele.cloneNode(true);
|
|
2916
|
+
$cloneNode.setAttribute("style", "visibility: hidden !important;display:block !important;");
|
|
2917
|
+
let $parent = PopsCore.document.documentElement;
|
|
2918
|
+
// 这里需要的是先获取元素的父节点,把元素同样添加到父节点中
|
|
2919
|
+
let $root = $ele.getRootNode();
|
|
2920
|
+
if (ownParent == null) {
|
|
2921
|
+
if ($root == $ele) {
|
|
2922
|
+
// 未添加到任意节点中,那么直接添加到页面中去
|
|
2923
|
+
$parent = PopsCore.document.documentElement;
|
|
2924
|
+
}
|
|
2925
|
+
else {
|
|
2926
|
+
// 添加到父节点中
|
|
2927
|
+
$parent = $root;
|
|
2928
|
+
}
|
|
2929
|
+
}
|
|
2930
|
+
else {
|
|
2931
|
+
// 自定义的父节点
|
|
2932
|
+
$parent = ownParent;
|
|
2933
|
+
}
|
|
2934
|
+
$parent.appendChild($cloneNode);
|
|
2918
2935
|
return {
|
|
2919
2936
|
/**
|
|
2920
2937
|
* 强制显示的克隆的元素
|
|
2921
2938
|
*/
|
|
2922
|
-
cloneNode: cloneNode,
|
|
2939
|
+
cloneNode: $cloneNode,
|
|
2923
2940
|
/**
|
|
2924
2941
|
* 恢复修改的style
|
|
2925
2942
|
*/
|
|
2926
2943
|
recovery() {
|
|
2927
|
-
cloneNode.remove();
|
|
2944
|
+
$cloneNode.remove();
|
|
2928
2945
|
},
|
|
2929
2946
|
};
|
|
2930
2947
|
}
|
|
@@ -10059,8 +10076,8 @@ define((function () { 'use strict';
|
|
|
10059
10076
|
* @param y
|
|
10060
10077
|
*/
|
|
10061
10078
|
getOffset(menuElement, x, y) {
|
|
10062
|
-
let menuElementWidth = popsDOMUtils.width(menuElement
|
|
10063
|
-
let menuElementHeight = popsDOMUtils.height(menuElement
|
|
10079
|
+
let menuElementWidth = popsDOMUtils.width(menuElement);
|
|
10080
|
+
let menuElementHeight = popsDOMUtils.height(menuElement);
|
|
10064
10081
|
/* left最大偏移 */
|
|
10065
10082
|
let maxLeftOffset = popsDOMUtils.width(globalThis) - menuElementWidth - 1;
|
|
10066
10083
|
/* top最大偏移 */
|
|
@@ -10538,6 +10555,7 @@ define((function () { 'use strict';
|
|
|
10538
10555
|
setInputChangeEvent(option = {
|
|
10539
10556
|
capture: true,
|
|
10540
10557
|
}) {
|
|
10558
|
+
/* 必须是input或者textarea才有input事件 */
|
|
10541
10559
|
if (!(config.inputTarget instanceof HTMLInputElement ||
|
|
10542
10560
|
config.inputTarget instanceof HTMLTextAreaElement)) {
|
|
10543
10561
|
return;
|
|
@@ -10742,7 +10760,22 @@ define((function () { 'use strict';
|
|
|
10742
10760
|
}
|
|
10743
10761
|
// 文档最大宽度
|
|
10744
10762
|
let documentWidth = popsDOMUtils.width(document);
|
|
10745
|
-
|
|
10763
|
+
let position = config.position;
|
|
10764
|
+
if (config.position === "auto") {
|
|
10765
|
+
// 需目标高度+搜索建议框高度大于文档高度,则显示在上面
|
|
10766
|
+
let targetBottom = targetRect.bottom;
|
|
10767
|
+
let searchSuggestionContainerHeight = popsDOMUtils.height(SearchSuggestion.$el.$hintULContainer);
|
|
10768
|
+
if (targetBottom + searchSuggestionContainerHeight > documentHeight) {
|
|
10769
|
+
// 在上面
|
|
10770
|
+
position = "top";
|
|
10771
|
+
}
|
|
10772
|
+
else {
|
|
10773
|
+
// 在下面
|
|
10774
|
+
position = "bottom";
|
|
10775
|
+
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
10776
|
+
}
|
|
10777
|
+
}
|
|
10778
|
+
if (position === "top") {
|
|
10746
10779
|
if (config.positionTopToReverse) {
|
|
10747
10780
|
SearchSuggestion.$el.$hintULContainer.setAttribute("data-top-reverse", "true");
|
|
10748
10781
|
}
|
|
@@ -10751,36 +10784,13 @@ define((function () { 'use strict';
|
|
|
10751
10784
|
SearchSuggestion.$el.$hintULContainer.style.bottom =
|
|
10752
10785
|
documentHeight - targetRect.top + config.topDistance + "px";
|
|
10753
10786
|
}
|
|
10754
|
-
else if (
|
|
10787
|
+
else if (position === "bottom") {
|
|
10755
10788
|
// 在下面
|
|
10756
10789
|
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top-reverse");
|
|
10757
10790
|
SearchSuggestion.$el.$hintULContainer.style.bottom = "";
|
|
10758
10791
|
SearchSuggestion.$el.$hintULContainer.style.top =
|
|
10759
10792
|
targetRect.height + targetRect.top + config.topDistance + "px";
|
|
10760
10793
|
}
|
|
10761
|
-
else if (config.position === "auto") {
|
|
10762
|
-
// 自动判断
|
|
10763
|
-
if (targetRect.bottom +
|
|
10764
|
-
popsDOMUtils.height(SearchSuggestion.$el.$hintULContainer) >
|
|
10765
|
-
documentHeight) {
|
|
10766
|
-
if (config.positionTopToReverse) {
|
|
10767
|
-
SearchSuggestion.$el.$hintULContainer.setAttribute("data-top-reverse", "true");
|
|
10768
|
-
}
|
|
10769
|
-
// 超出浏览器高度了,自动转换为上面去
|
|
10770
|
-
SearchSuggestion.$el.$hintULContainer.style.top = "";
|
|
10771
|
-
SearchSuggestion.$el.$hintULContainer.style.bottom =
|
|
10772
|
-
documentHeight - targetRect.top + config.topDistance + "px";
|
|
10773
|
-
}
|
|
10774
|
-
else {
|
|
10775
|
-
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
10776
|
-
SearchSuggestion.$el.$hintULContainer.style.bottom = "";
|
|
10777
|
-
SearchSuggestion.$el.$hintULContainer.style.top =
|
|
10778
|
-
targetRect.height + targetRect.top + config.topDistance + "px";
|
|
10779
|
-
}
|
|
10780
|
-
}
|
|
10781
|
-
else {
|
|
10782
|
-
throw new TypeError("未知设置的位置" + config.position);
|
|
10783
|
-
}
|
|
10784
10794
|
let hintUIWidth = popsDOMUtils.width(SearchSuggestion.$el.$hintULContainer);
|
|
10785
10795
|
SearchSuggestion.$el.$hintULContainer.style.left =
|
|
10786
10796
|
(targetRect.left + hintUIWidth > documentWidth
|