@whitesev/pops 2.3.3 → 2.3.5
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 +284 -136
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +284 -136
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +284 -136
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +284 -136
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +284 -136
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +284 -136
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/Pops.d.ts +14 -8
- package/dist/types/src/components/searchSuggestion/index.d.ts +16 -7
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +21 -10
- package/dist/types/src/utils/PopsDOMUtils.d.ts +14 -6
- package/package.json +1 -1
package/dist/index.system.js
CHANGED
|
@@ -1818,11 +1818,11 @@ System.register('pops', [], (function (exports) {
|
|
|
1818
1818
|
}
|
|
1819
1819
|
/**
|
|
1820
1820
|
* 添加className
|
|
1821
|
-
* @param
|
|
1821
|
+
* @param $el 目标元素
|
|
1822
1822
|
* @param className className属性
|
|
1823
1823
|
*/
|
|
1824
|
-
addClassName(
|
|
1825
|
-
if (
|
|
1824
|
+
addClassName($el, className) {
|
|
1825
|
+
if ($el == null) {
|
|
1826
1826
|
return;
|
|
1827
1827
|
}
|
|
1828
1828
|
if (typeof className !== "string") {
|
|
@@ -1831,15 +1831,16 @@ System.register('pops', [], (function (exports) {
|
|
|
1831
1831
|
if (className.trim() === "") {
|
|
1832
1832
|
return;
|
|
1833
1833
|
}
|
|
1834
|
-
|
|
1834
|
+
const classNameList = className.split(" ").filter((item) => item.trim() !== "");
|
|
1835
|
+
$el.classList.add(...classNameList);
|
|
1835
1836
|
}
|
|
1836
1837
|
/**
|
|
1837
1838
|
* 删除className
|
|
1838
|
-
* @param
|
|
1839
|
+
* @param $el 目标元素
|
|
1839
1840
|
* @param className className属性
|
|
1840
1841
|
*/
|
|
1841
|
-
removeClassName(
|
|
1842
|
-
if (
|
|
1842
|
+
removeClassName($el, className) {
|
|
1843
|
+
if ($el == null) {
|
|
1843
1844
|
return;
|
|
1844
1845
|
}
|
|
1845
1846
|
if (typeof className !== "string") {
|
|
@@ -1848,15 +1849,16 @@ System.register('pops', [], (function (exports) {
|
|
|
1848
1849
|
if (className.trim() === "") {
|
|
1849
1850
|
return;
|
|
1850
1851
|
}
|
|
1851
|
-
|
|
1852
|
+
const classNameList = className.split(" ").filter((item) => item.trim() !== "");
|
|
1853
|
+
$el.classList.remove(...classNameList);
|
|
1852
1854
|
}
|
|
1853
1855
|
/**
|
|
1854
1856
|
* 判断元素是否包含某个className
|
|
1855
|
-
* @param
|
|
1857
|
+
* @param $el 目标元素
|
|
1856
1858
|
* @param className className属性
|
|
1857
1859
|
*/
|
|
1858
|
-
containsClassName(
|
|
1859
|
-
if (
|
|
1860
|
+
containsClassName($el, className) {
|
|
1861
|
+
if ($el == null) {
|
|
1860
1862
|
return false;
|
|
1861
1863
|
}
|
|
1862
1864
|
if (typeof className !== "string") {
|
|
@@ -1865,7 +1867,7 @@ System.register('pops', [], (function (exports) {
|
|
|
1865
1867
|
if (className.trim() === "") {
|
|
1866
1868
|
return false;
|
|
1867
1869
|
}
|
|
1868
|
-
return
|
|
1870
|
+
return $el.classList.contains(className);
|
|
1869
1871
|
}
|
|
1870
1872
|
css(element, property, value) {
|
|
1871
1873
|
/**
|
|
@@ -2488,6 +2490,24 @@ System.register('pops', [], (function (exports) {
|
|
|
2488
2490
|
}
|
|
2489
2491
|
return useChangeColor();
|
|
2490
2492
|
}
|
|
2493
|
+
/**
|
|
2494
|
+
* 获取移动元素的transform偏移
|
|
2495
|
+
* @param element 元素
|
|
2496
|
+
*/
|
|
2497
|
+
getTransform(element) {
|
|
2498
|
+
let transform_left = 0;
|
|
2499
|
+
let transform_top = 0;
|
|
2500
|
+
let elementTransform = PopsCore.globalThis.getComputedStyle(element).transform;
|
|
2501
|
+
if (elementTransform !== "none" && elementTransform != null && elementTransform !== "") {
|
|
2502
|
+
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
2503
|
+
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
2504
|
+
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
2505
|
+
}
|
|
2506
|
+
return {
|
|
2507
|
+
transformLeft: transform_left,
|
|
2508
|
+
transformTop: transform_top,
|
|
2509
|
+
};
|
|
2510
|
+
}
|
|
2491
2511
|
}
|
|
2492
2512
|
const popsDOMUtils = new PopsDOMUtils();
|
|
2493
2513
|
|
|
@@ -3287,23 +3307,6 @@ System.register('pops', [], (function (exports) {
|
|
|
3287
3307
|
popsDOMUtils.css(options.dragElement, {
|
|
3288
3308
|
cursor: "move",
|
|
3289
3309
|
});
|
|
3290
|
-
/**
|
|
3291
|
-
* 获取移动元素的transform偏移
|
|
3292
|
-
*/
|
|
3293
|
-
function getTransform(element) {
|
|
3294
|
-
let transform_left = 0;
|
|
3295
|
-
let transform_top = 0;
|
|
3296
|
-
let elementTransform = PopsCore.globalThis.getComputedStyle(element).transform;
|
|
3297
|
-
if (elementTransform !== "none" && elementTransform != null && elementTransform !== "") {
|
|
3298
|
-
let elementTransformSplit = elementTransform.match(/\((.+)\)/)?.[1].split(",");
|
|
3299
|
-
transform_left = Math.abs(parseInt(elementTransformSplit[4]));
|
|
3300
|
-
transform_top = Math.abs(parseInt(elementTransformSplit[5]));
|
|
3301
|
-
}
|
|
3302
|
-
return {
|
|
3303
|
-
transformLeft: transform_left,
|
|
3304
|
-
transformTop: transform_top,
|
|
3305
|
-
};
|
|
3306
|
-
}
|
|
3307
3310
|
/**
|
|
3308
3311
|
* 修改移动的元素的style
|
|
3309
3312
|
*/
|
|
@@ -3345,9 +3348,8 @@ System.register('pops', [], (function (exports) {
|
|
|
3345
3348
|
};
|
|
3346
3349
|
}
|
|
3347
3350
|
}
|
|
3348
|
-
|
|
3349
|
-
let
|
|
3350
|
-
let transformTop = transformInfo.transformTop;
|
|
3351
|
+
// 获取transform偏移
|
|
3352
|
+
let transformInfo = popsDOMUtils.getTransform(moveElement);
|
|
3351
3353
|
let resumeMoveElementStyle = null;
|
|
3352
3354
|
anyTouchElement.on("pan", function (event) {
|
|
3353
3355
|
if (!isMove) {
|
|
@@ -3355,9 +3357,7 @@ System.register('pops', [], (function (exports) {
|
|
|
3355
3357
|
let rect = options.dragElement.getBoundingClientRect();
|
|
3356
3358
|
clickElementLeftOffset = event.x - rect.left;
|
|
3357
3359
|
clickElementTopOffset = event.y - rect.top;
|
|
3358
|
-
transformInfo = getTransform(moveElement);
|
|
3359
|
-
transformLeft = transformInfo.transformLeft;
|
|
3360
|
-
transformTop = transformInfo.transformTop;
|
|
3360
|
+
transformInfo = popsDOMUtils.getTransform(moveElement);
|
|
3361
3361
|
//if (event.nativeEvent.offsetX) {
|
|
3362
3362
|
// clickElementLeftOffset = parseInt(event.nativeEvent.offsetX);
|
|
3363
3363
|
//} else {
|
|
@@ -3371,9 +3371,9 @@ System.register('pops', [], (function (exports) {
|
|
|
3371
3371
|
resumeMoveElementStyle = changeMoveElementStyle(moveElement);
|
|
3372
3372
|
}
|
|
3373
3373
|
/** 当前移动的left偏移 */
|
|
3374
|
-
let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformLeft;
|
|
3374
|
+
let currentMoveLeftOffset = event.x - clickElementLeftOffset + transformInfo.transformLeft;
|
|
3375
3375
|
/** 当前移动的top偏移 */
|
|
3376
|
-
let currentMoveTopOffset = event.y - clickElementTopOffset + transformTop;
|
|
3376
|
+
let currentMoveTopOffset = event.y - clickElementTopOffset + transformInfo.transformTop;
|
|
3377
3377
|
/* 拖拽移动 */
|
|
3378
3378
|
if (event.phase === "move") {
|
|
3379
3379
|
if (options.limit) {
|
|
@@ -3381,12 +3381,12 @@ System.register('pops', [], (function (exports) {
|
|
|
3381
3381
|
/* left偏移最大值 */
|
|
3382
3382
|
let maxLeftOffset = getContainerWidthOrHeight(options.container).width -
|
|
3383
3383
|
popsDOMUtils.width(moveElement) +
|
|
3384
|
-
transformLeft;
|
|
3384
|
+
transformInfo.transformLeft;
|
|
3385
3385
|
let { left: minLeftOffset, top: minTopOffset } = getContainerTopOrLeft(options.container);
|
|
3386
3386
|
/* top偏移的最大值 */
|
|
3387
3387
|
let maxTopOffset = getContainerWidthOrHeight(options.container).height -
|
|
3388
3388
|
popsDOMUtils.height(moveElement) +
|
|
3389
|
-
transformTop;
|
|
3389
|
+
transformInfo.transformTop;
|
|
3390
3390
|
if (currentMoveLeftOffset > maxLeftOffset) {
|
|
3391
3391
|
/* 不允许超过容器的最大宽度 */
|
|
3392
3392
|
currentMoveLeftOffset = maxLeftOffset;
|
|
@@ -3395,9 +3395,10 @@ System.register('pops', [], (function (exports) {
|
|
|
3395
3395
|
/* 不允许超过容器的最大高度 */
|
|
3396
3396
|
currentMoveTopOffset = maxTopOffset;
|
|
3397
3397
|
}
|
|
3398
|
-
if (currentMoveLeftOffset - options.extraDistance * 2 <
|
|
3398
|
+
if (currentMoveLeftOffset - options.extraDistance * 2 <
|
|
3399
|
+
minLeftOffset + transformInfo.transformLeft) {
|
|
3399
3400
|
/* 不允许left偏移小于容器最小值 */
|
|
3400
|
-
currentMoveLeftOffset = minLeftOffset + transformLeft;
|
|
3401
|
+
currentMoveLeftOffset = minLeftOffset + transformInfo.transformLeft;
|
|
3401
3402
|
/* 最左边 +额外距离 */
|
|
3402
3403
|
currentMoveLeftOffset += options.extraDistance;
|
|
3403
3404
|
}
|
|
@@ -3405,9 +3406,9 @@ System.register('pops', [], (function (exports) {
|
|
|
3405
3406
|
/* 最右边 -额外距离 */
|
|
3406
3407
|
currentMoveLeftOffset -= options.extraDistance;
|
|
3407
3408
|
}
|
|
3408
|
-
if (currentMoveTopOffset - options.extraDistance * 2 < minTopOffset + transformTop) {
|
|
3409
|
+
if (currentMoveTopOffset - options.extraDistance * 2 < minTopOffset + transformInfo.transformTop) {
|
|
3409
3410
|
/* 不允许top偏移小于容器最小值 */
|
|
3410
|
-
currentMoveTopOffset = minTopOffset + transformTop;
|
|
3411
|
+
currentMoveTopOffset = minTopOffset + transformInfo.transformTop;
|
|
3411
3412
|
/* 最上面 +额外距离 */
|
|
3412
3413
|
currentMoveTopOffset += options.extraDistance;
|
|
3413
3414
|
}
|
|
@@ -10746,28 +10747,42 @@ System.register('pops', [], (function (exports) {
|
|
|
10746
10747
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
10747
10748
|
}
|
|
10748
10749
|
/* 鼠标|触摸 移入事件 */
|
|
10749
|
-
|
|
10750
|
+
// 在移动端会先触发touchstart再然后mouseenter
|
|
10751
|
+
let isTriggerTouchEvent = false;
|
|
10752
|
+
/**
|
|
10753
|
+
* 鼠标|触摸 移入事件
|
|
10754
|
+
*/
|
|
10755
|
+
function liElementHoverEvent(event) {
|
|
10756
|
+
if (event.type === "touchstart") {
|
|
10757
|
+
isTriggerTouchEvent = true;
|
|
10758
|
+
}
|
|
10759
|
+
if (isTriggerTouchEvent && event.type === "mouseenter") {
|
|
10760
|
+
return;
|
|
10761
|
+
}
|
|
10750
10762
|
Array.from(menuULElement.children).forEach((liElement) => {
|
|
10751
10763
|
popsDOMUtils.removeClassName(liElement, `pops-${popsType}-is-visited`);
|
|
10752
|
-
|
|
10764
|
+
let li_menuData = Reflect.get(liElement, "__menuData__");
|
|
10765
|
+
if (!li_menuData) {
|
|
10753
10766
|
return;
|
|
10754
10767
|
}
|
|
10755
10768
|
function removeElement(element) {
|
|
10756
|
-
element.querySelectorAll("ul li").forEach((ele) => {
|
|
10757
|
-
|
|
10758
|
-
|
|
10769
|
+
element.querySelectorAll("ul li").forEach(($ele) => {
|
|
10770
|
+
let menuData = Reflect.get($ele, "__menuData__");
|
|
10771
|
+
if (menuData?.child) {
|
|
10772
|
+
removeElement(menuData.child);
|
|
10759
10773
|
}
|
|
10760
10774
|
});
|
|
10761
10775
|
element.remove();
|
|
10762
10776
|
}
|
|
10763
10777
|
/* 遍历根元素的上的__menuData__.child,判断 */
|
|
10764
|
-
removeElement(
|
|
10778
|
+
removeElement(li_menuData.child);
|
|
10765
10779
|
});
|
|
10766
10780
|
/* 清理根元素上的children不存在于页面中的元素 */
|
|
10767
|
-
|
|
10768
|
-
|
|
10781
|
+
let root_menuData = Reflect.get(rootElement, "__menuData__");
|
|
10782
|
+
for (let index = 0; index < root_menuData.child.length; index++) {
|
|
10783
|
+
let element = root_menuData.child[index];
|
|
10769
10784
|
if (!$shadowRoot.contains(element)) {
|
|
10770
|
-
|
|
10785
|
+
root_menuData.child.splice(index, 1);
|
|
10771
10786
|
index--;
|
|
10772
10787
|
}
|
|
10773
10788
|
}
|
|
@@ -10780,14 +10795,13 @@ System.register('pops', [], (function (exports) {
|
|
|
10780
10795
|
clientX: rect.left + popsDOMUtils.outerWidth(menuLiElement),
|
|
10781
10796
|
clientY: rect.top,
|
|
10782
10797
|
}, item.item, rootElement, menuLiElement, menuListenerRootNode);
|
|
10783
|
-
menuLiElement
|
|
10798
|
+
Reflect.set(menuLiElement, "__menuData__", {
|
|
10784
10799
|
child: childMenu,
|
|
10785
|
-
};
|
|
10800
|
+
});
|
|
10786
10801
|
}
|
|
10787
10802
|
/**
|
|
10788
10803
|
* 点击事件
|
|
10789
10804
|
* @param clickEvent
|
|
10790
|
-
* @returns
|
|
10791
10805
|
*/
|
|
10792
10806
|
async function liElementClickEvent(clickEvent) {
|
|
10793
10807
|
if (typeof item.callback === "function") {
|
|
@@ -10810,9 +10824,9 @@ System.register('pops', [], (function (exports) {
|
|
|
10810
10824
|
});
|
|
10811
10825
|
PopsContextMenu.closeAllMenu(rootElement);
|
|
10812
10826
|
}
|
|
10813
|
-
popsDOMUtils.on(menuLiElement, "mouseenter touchstart",
|
|
10827
|
+
popsDOMUtils.on(menuLiElement, "mouseenter touchstart", liElementHoverEvent);
|
|
10814
10828
|
/* 项-点击事件 */
|
|
10815
|
-
popsDOMUtils.on(menuLiElement, "click",
|
|
10829
|
+
popsDOMUtils.on(menuLiElement, "click", liElementClickEvent);
|
|
10816
10830
|
menuULElement.appendChild(menuLiElement);
|
|
10817
10831
|
});
|
|
10818
10832
|
},
|
|
@@ -10833,33 +10847,34 @@ System.register('pops', [], (function (exports) {
|
|
|
10833
10847
|
};
|
|
10834
10848
|
|
|
10835
10849
|
const searchSuggestionConfig = () => {
|
|
10850
|
+
const data = [];
|
|
10851
|
+
for (let index = 0; index < 10; index++) {
|
|
10852
|
+
data.push({
|
|
10853
|
+
value: `测试${index}`,
|
|
10854
|
+
text: `测试${index}-html`,
|
|
10855
|
+
});
|
|
10856
|
+
}
|
|
10836
10857
|
return {
|
|
10837
10858
|
// @ts-ignore
|
|
10838
10859
|
target: null,
|
|
10839
10860
|
// @ts-ignore
|
|
10840
10861
|
inputTarget: null,
|
|
10841
10862
|
selfDocument: document,
|
|
10842
|
-
data:
|
|
10843
|
-
{
|
|
10844
|
-
value: "数据1",
|
|
10845
|
-
text: "数据1-html",
|
|
10846
|
-
},
|
|
10847
|
-
{
|
|
10848
|
-
value: "数据2",
|
|
10849
|
-
text: "数据2-html",
|
|
10850
|
-
},
|
|
10851
|
-
],
|
|
10863
|
+
data: data,
|
|
10852
10864
|
deleteIcon: {
|
|
10853
10865
|
enable: true,
|
|
10854
|
-
callback(event, liElement,
|
|
10855
|
-
console.log("删除当前项", [event, liElement,
|
|
10866
|
+
callback(event, liElement, dataItem) {
|
|
10867
|
+
console.log("删除当前项", [event, liElement, dataItem]);
|
|
10868
|
+
data.splice(data.indexOf(dataItem), 1);
|
|
10856
10869
|
liElement.remove();
|
|
10857
10870
|
},
|
|
10858
10871
|
},
|
|
10859
10872
|
useShadowRoot: true,
|
|
10860
10873
|
className: "",
|
|
10861
10874
|
isAbsolute: true,
|
|
10862
|
-
isAnimation:
|
|
10875
|
+
isAnimation: false,
|
|
10876
|
+
useFoldAnimation: true,
|
|
10877
|
+
useArrow: false,
|
|
10863
10878
|
width: "250px",
|
|
10864
10879
|
maxHeight: "300px",
|
|
10865
10880
|
followTargetWidth: true,
|
|
@@ -10874,9 +10889,9 @@ System.register('pops', [], (function (exports) {
|
|
|
10874
10889
|
getItemHTML(item) {
|
|
10875
10890
|
return item.text ?? item;
|
|
10876
10891
|
},
|
|
10877
|
-
async getData(value) {
|
|
10892
|
+
async getData(value, data) {
|
|
10878
10893
|
console.log("当前输入框的值是:", value);
|
|
10879
|
-
return
|
|
10894
|
+
return data.filter((it) => it.value.includes(value));
|
|
10880
10895
|
},
|
|
10881
10896
|
itemClickCallBack(event, liElement, data) {
|
|
10882
10897
|
console.log("item项的点击回调", [event, liElement, data]);
|
|
@@ -10948,74 +10963,168 @@ System.register('pops', [], (function (exports) {
|
|
|
10948
10963
|
/** 是否结果为空 */
|
|
10949
10964
|
isEmpty: true,
|
|
10950
10965
|
},
|
|
10966
|
+
/** 初始化元素变量 */
|
|
10967
|
+
initEl() {
|
|
10968
|
+
this.$el.root = SearchSuggestion.createSearchSelectElement();
|
|
10969
|
+
this.$el.$dynamicCSS = this.$el.root.querySelector("style[data-dynamic]");
|
|
10970
|
+
this.$el.$hintULContainer = SearchSuggestion.$el.root.querySelector("ul");
|
|
10971
|
+
},
|
|
10951
10972
|
/**
|
|
10952
10973
|
* 初始化
|
|
10953
10974
|
*/
|
|
10954
10975
|
init(parentElement = document.body || document.documentElement) {
|
|
10955
10976
|
this.initEl();
|
|
10956
|
-
SearchSuggestion.update(
|
|
10957
|
-
SearchSuggestion.
|
|
10958
|
-
SearchSuggestion.changeHintULElementWidth();
|
|
10959
|
-
SearchSuggestion.changeHintULElementPosition();
|
|
10977
|
+
SearchSuggestion.update(this.getData());
|
|
10978
|
+
SearchSuggestion.updateStyleSheet();
|
|
10960
10979
|
SearchSuggestion.hide();
|
|
10961
|
-
if (config.isAnimation) {
|
|
10962
|
-
SearchSuggestion.$el.root.classList.add(`pops-${popsType}-animation`);
|
|
10963
|
-
}
|
|
10964
10980
|
$shadowRoot.appendChild(SearchSuggestion.$el.root);
|
|
10965
10981
|
parentElement.appendChild($shadowContainer);
|
|
10966
10982
|
},
|
|
10967
|
-
/**
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10983
|
+
/**
|
|
10984
|
+
* 获取数据
|
|
10985
|
+
*/
|
|
10986
|
+
getData() {
|
|
10987
|
+
return typeof config.data === "function" ? config.data() : config.data;
|
|
10972
10988
|
},
|
|
10973
10989
|
/**
|
|
10974
10990
|
* 获取显示出搜索建议框的html
|
|
10975
10991
|
*/
|
|
10976
|
-
|
|
10977
|
-
let
|
|
10992
|
+
createSearchSelectElement() {
|
|
10993
|
+
let $el = popsDOMUtils.createElement("div", {
|
|
10978
10994
|
className: `pops pops-${popsType}-search-suggestion`,
|
|
10979
10995
|
innerHTML: /*html*/ `
|
|
10996
|
+
<style>
|
|
10997
|
+
.pops-${popsType}-animation{
|
|
10998
|
+
-moz-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10999
|
+
-webkit-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11000
|
+
-o-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11001
|
+
-ms-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11002
|
+
}
|
|
11003
|
+
</style>
|
|
11004
|
+
<style>
|
|
11005
|
+
.pops-${popsType}-search-suggestion-arrow{
|
|
11006
|
+
--suggestion-arrow-box-shadow-left-color: rgba(0, 0, 0, 0.24);
|
|
11007
|
+
--suggestion-arrow-box-shadow-right-color: rgba(0, 0, 0, 0.12);
|
|
11008
|
+
--suggestion-arrow--after-color: rgb(78, 78, 78);
|
|
11009
|
+
--suggestion-arrow--after-bg-color: rgb(255, 255, 255, var(--pops-bg-opacity));
|
|
11010
|
+
--suggestion-arrow--after-width: 10px;
|
|
11011
|
+
--suggestion-arrow--after-height: 10px;
|
|
11012
|
+
}
|
|
11013
|
+
.pops-${popsType}-search-suggestion-arrow{
|
|
11014
|
+
position: absolute;
|
|
11015
|
+
top: 100%;
|
|
11016
|
+
left: 50%;
|
|
11017
|
+
overflow: hidden;
|
|
11018
|
+
width: 100%;
|
|
11019
|
+
height: 12.5px;
|
|
11020
|
+
transform: translateX(-50%);
|
|
11021
|
+
}
|
|
11022
|
+
.pops-${popsType}-search-suggestion-arrow::after{
|
|
11023
|
+
position: absolute;
|
|
11024
|
+
top: 0;
|
|
11025
|
+
left: 50%;
|
|
11026
|
+
width: var(--suggestion-arrow--after-width);
|
|
11027
|
+
height: var(--suggestion-arrow--after-height);
|
|
11028
|
+
background: var(--suggestion-arrow--after-bg-color);
|
|
11029
|
+
color: var(--suggestion-arrow--after-color);
|
|
11030
|
+
box-shadow:
|
|
11031
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-left-color),
|
|
11032
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-right-color);
|
|
11033
|
+
content: "";
|
|
11034
|
+
transform: translateX(-50%) translateY(-50%) rotate(45deg);
|
|
11035
|
+
}
|
|
11036
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="top"] .pops-${popsType}-search-suggestion-arrow{
|
|
11037
|
+
position: absolute;
|
|
11038
|
+
top: 100%;
|
|
11039
|
+
left: 50%;
|
|
11040
|
+
overflow: hidden;
|
|
11041
|
+
width: 100%;
|
|
11042
|
+
height: 12.5px;
|
|
11043
|
+
transform: translateX(-50%);
|
|
11044
|
+
}
|
|
11045
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="top"] .pops-${popsType}-search-suggestion-arrow::after{
|
|
11046
|
+
position: absolute;
|
|
11047
|
+
top: 0;
|
|
11048
|
+
left: 50%;
|
|
11049
|
+
width: var(--suggestion-arrow--after-width);
|
|
11050
|
+
height: var(--suggestion-arrow--after-height);
|
|
11051
|
+
background: var(--suggestion-arrow--after-bg-color);
|
|
11052
|
+
box-shadow:
|
|
11053
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-left-color),
|
|
11054
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-right-color);
|
|
11055
|
+
content: "";
|
|
11056
|
+
transform: translateX(-50%) translateY(-50%) rotate(45deg);
|
|
11057
|
+
}
|
|
11058
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="bottom"] .pops-${popsType}-search-suggestion-arrow{
|
|
11059
|
+
top: -12.5px;
|
|
11060
|
+
left: 50%;
|
|
11061
|
+
transform: translateX(-50%);
|
|
11062
|
+
}
|
|
11063
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="bottom"] .pops-${popsType}-search-suggestion-arrow::after{
|
|
11064
|
+
position: absolute;
|
|
11065
|
+
top: 100%;
|
|
11066
|
+
left: 50%;
|
|
11067
|
+
content: "";
|
|
11068
|
+
}
|
|
11069
|
+
</style>
|
|
10980
11070
|
<style data-dynamic="true">
|
|
10981
11071
|
${this.getDynamicCSS()}
|
|
10982
11072
|
</style>
|
|
10983
|
-
<
|
|
11073
|
+
<style>
|
|
11074
|
+
.el-zoom-in-top-animation{
|
|
11075
|
+
--el-transition-md-fade: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1),
|
|
11076
|
+
opacity 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
11077
|
+
transition: var(--el-transition-md-fade);
|
|
11078
|
+
transform-origin: center top;
|
|
11079
|
+
}
|
|
11080
|
+
.el-zoom-in-top-animation[data-popper-placement^="top"] {
|
|
11081
|
+
transform-origin: center bottom;
|
|
11082
|
+
}
|
|
11083
|
+
.el-zoom-in-top-animation-hide{
|
|
11084
|
+
opacity: 0;
|
|
11085
|
+
transform: scaleY(0);
|
|
11086
|
+
}
|
|
11087
|
+
.el-zoom-in-top-animation-show{
|
|
11088
|
+
opacity: 1;
|
|
11089
|
+
transform: scaleY(1);
|
|
11090
|
+
}
|
|
11091
|
+
</style>
|
|
11092
|
+
<ul class="pops-${popsType}-search-suggestion-hint ${PopsCommonCSSClassName.userSelectNone}">${config.toSearhNotResultHTML}</ul>
|
|
11093
|
+
${config.useArrow ? /*html*/ `<div class="pops-${popsType}-search-suggestion-arrow"></div>` : ""}
|
|
10984
11094
|
`,
|
|
10985
11095
|
}, {
|
|
10986
11096
|
"data-guid": guid,
|
|
10987
11097
|
"type-value": popsType,
|
|
10988
11098
|
});
|
|
10989
11099
|
if (config.className !== "" && config.className != null) {
|
|
10990
|
-
popsDOMUtils.addClassName(
|
|
11100
|
+
popsDOMUtils.addClassName($el, config.className);
|
|
11101
|
+
}
|
|
11102
|
+
if (config.isAnimation) {
|
|
11103
|
+
popsDOMUtils.addClassName($el, `pops-${popsType}-animation`);
|
|
11104
|
+
}
|
|
11105
|
+
if (config.useFoldAnimation) {
|
|
11106
|
+
popsDOMUtils.addClassName($el, "el-zoom-in-top-animation");
|
|
10991
11107
|
}
|
|
10992
|
-
return
|
|
11108
|
+
return $el;
|
|
10993
11109
|
},
|
|
10994
11110
|
/** 动态获取CSS */
|
|
10995
11111
|
getDynamicCSS() {
|
|
10996
11112
|
return /*css*/ `
|
|
10997
|
-
.pops-${popsType}-animation{
|
|
10998
|
-
-moz-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10999
|
-
-webkit-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11000
|
-
-o-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11001
|
-
-ms-animation: searchSelectFalIn 0.5s 1 linear;
|
|
11002
|
-
}
|
|
11003
11113
|
.pops-${popsType}-search-suggestion{
|
|
11004
11114
|
--search-suggestion-bg-color: #ffffff;
|
|
11005
11115
|
--search-suggestion-box-shadow-color: rgb(0 0 0 / 20%);
|
|
11006
11116
|
--search-suggestion-item-color: #515a6e;
|
|
11007
11117
|
--search-suggestion-item-none-color: #8e8e8e;
|
|
11008
|
-
--search-suggestion-item-hover-bg-color:
|
|
11118
|
+
--search-suggestion-item-is-hover-bg-color: #f5f7fa;
|
|
11119
|
+
--search-suggestion-item-is-select-bg-color: #409eff;
|
|
11009
11120
|
}
|
|
11010
11121
|
.pops-${popsType}-search-suggestion{
|
|
11011
11122
|
border: initial;
|
|
11012
11123
|
overflow: initial;
|
|
11013
|
-
}
|
|
11014
|
-
ul.pops-${popsType}-search-suggestion-hint{
|
|
11015
11124
|
position: ${config.isAbsolute ? "absolute" : "fixed"};
|
|
11016
11125
|
z-index: ${PopsHandler.handleZIndex(config.zIndex)};
|
|
11017
|
-
|
|
11018
|
-
|
|
11126
|
+
}
|
|
11127
|
+
ul.pops-${popsType}-search-suggestion-hint{
|
|
11019
11128
|
max-height: ${config.maxHeight};
|
|
11020
11129
|
overflow-x: hidden;
|
|
11021
11130
|
overflow-y: auto;
|
|
@@ -11026,11 +11135,11 @@ System.register('pops', [], (function (exports) {
|
|
|
11026
11135
|
box-shadow: 0 1px 6px var(--search-suggestion-box-shadow-color);
|
|
11027
11136
|
}
|
|
11028
11137
|
/* 建议框在上面时 */
|
|
11029
|
-
|
|
11138
|
+
.pops-${popsType}-search-suggestion[data-top-reverse] ul.pops-${popsType}-search-suggestion-hint{
|
|
11030
11139
|
display: flex;
|
|
11031
11140
|
flex-direction: column-reverse;
|
|
11032
11141
|
}
|
|
11033
|
-
|
|
11142
|
+
.pops-${popsType}-search-suggestion[data-top-reverse] ul.pops-${popsType}-search-suggestion-hint li{
|
|
11034
11143
|
flex-shrink: 0;
|
|
11035
11144
|
}
|
|
11036
11145
|
ul.pops-${popsType}-search-suggestion-hint li{
|
|
@@ -11052,14 +11161,13 @@ System.register('pops', [], (function (exports) {
|
|
|
11052
11161
|
color: var(--search-suggestion-item-none-color);
|
|
11053
11162
|
}
|
|
11054
11163
|
ul.pops-${popsType}-search-suggestion-hint li:not([data-none]):hover{
|
|
11055
|
-
background-color: var(--search-suggestion-item-hover-bg-color);
|
|
11164
|
+
background-color: var(--search-suggestion-item-is-hover-bg-color);
|
|
11056
11165
|
}
|
|
11057
|
-
|
|
11058
11166
|
@media (prefers-color-scheme: dark){
|
|
11059
11167
|
.pops-${popsType}-search-suggestion{
|
|
11060
11168
|
--search-suggestion-bg-color: #1d1e1f;
|
|
11061
11169
|
--search-suggestion-item-color: #cfd3d4;
|
|
11062
|
-
--search-suggestion-item-hover-bg-color: rgba(175, 175, 175, .1);
|
|
11170
|
+
--search-suggestion-item-is-hover-bg-color: rgba(175, 175, 175, .1);
|
|
11063
11171
|
}
|
|
11064
11172
|
}
|
|
11065
11173
|
`;
|
|
@@ -11069,7 +11177,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11069
11177
|
* @param data 当前项的值
|
|
11070
11178
|
* @param index 当前项的下标
|
|
11071
11179
|
*/
|
|
11072
|
-
|
|
11180
|
+
createSearchItemLiElement(data, index) {
|
|
11073
11181
|
let $li = popsDOMUtils.createElement("li", {
|
|
11074
11182
|
className: `pops-${popsType}-search-suggestion-hint-item`,
|
|
11075
11183
|
"data-index": index,
|
|
@@ -11089,25 +11197,28 @@ System.register('pops', [], (function (exports) {
|
|
|
11089
11197
|
},
|
|
11090
11198
|
/**
|
|
11091
11199
|
* 设置搜索建议框每一项的点击事件
|
|
11092
|
-
* @param
|
|
11200
|
+
* @param $searchItem
|
|
11093
11201
|
*/
|
|
11094
|
-
setSearchItemClickEvent(
|
|
11095
|
-
popsDOMUtils.on(
|
|
11202
|
+
setSearchItemClickEvent($searchItem) {
|
|
11203
|
+
popsDOMUtils.on($searchItem, "click", (event) => {
|
|
11096
11204
|
popsDOMUtils.preventEvent(event);
|
|
11097
11205
|
let $click = event.target;
|
|
11098
|
-
|
|
11099
|
-
|
|
11206
|
+
let dataValue = Reflect.get($searchItem, "data-value");
|
|
11207
|
+
let isDelete = Boolean($click.closest(`.pops-${popsType}-delete-icon`));
|
|
11208
|
+
if (isDelete) {
|
|
11209
|
+
// 删除
|
|
11100
11210
|
if (typeof config.deleteIcon.callback === "function") {
|
|
11101
|
-
config.deleteIcon.callback(event,
|
|
11211
|
+
config.deleteIcon.callback(event, $searchItem, dataValue);
|
|
11102
11212
|
}
|
|
11103
11213
|
if (!this.$el.$hintULContainer.children.length) {
|
|
11104
11214
|
/* 全删完了 */
|
|
11105
11215
|
this.clear();
|
|
11106
11216
|
}
|
|
11217
|
+
SearchSuggestion.updateStyleSheet();
|
|
11107
11218
|
}
|
|
11108
11219
|
else {
|
|
11109
|
-
|
|
11110
|
-
config.itemClickCallBack(event,
|
|
11220
|
+
// 点击选择项
|
|
11221
|
+
config.itemClickCallBack(event, $searchItem, dataValue);
|
|
11111
11222
|
}
|
|
11112
11223
|
}, {
|
|
11113
11224
|
capture: true,
|
|
@@ -11147,8 +11258,9 @@ System.register('pops', [], (function (exports) {
|
|
|
11147
11258
|
config.inputTarget.setAttribute("autocomplete", "off");
|
|
11148
11259
|
/* 内容改变事件 */
|
|
11149
11260
|
popsDOMUtils.on(config.inputTarget, "input", void 0, async (event) => {
|
|
11150
|
-
let getListResult = await config.getData(
|
|
11261
|
+
let getListResult = await config.getData(config.inputTarget.value, this.getData());
|
|
11151
11262
|
SearchSuggestion.update(getListResult);
|
|
11263
|
+
SearchSuggestion.updateStyleSheet();
|
|
11152
11264
|
}, option);
|
|
11153
11265
|
},
|
|
11154
11266
|
/**
|
|
@@ -11163,12 +11275,10 @@ System.register('pops', [], (function (exports) {
|
|
|
11163
11275
|
* 显示搜索建议框的事件
|
|
11164
11276
|
*/
|
|
11165
11277
|
showEvent() {
|
|
11166
|
-
SearchSuggestion.
|
|
11167
|
-
SearchSuggestion.changeHintULElementWidth();
|
|
11168
|
-
SearchSuggestion.changeHintULElementPosition();
|
|
11278
|
+
SearchSuggestion.updateStyleSheet();
|
|
11169
11279
|
if (config.toHideWithNotResult) {
|
|
11170
11280
|
if (SearchSuggestion.$data.isEmpty) {
|
|
11171
|
-
SearchSuggestion.hide();
|
|
11281
|
+
SearchSuggestion.hide(true);
|
|
11172
11282
|
}
|
|
11173
11283
|
else {
|
|
11174
11284
|
SearchSuggestion.show();
|
|
@@ -11227,7 +11337,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11227
11337
|
/* 点击在目标input内 */
|
|
11228
11338
|
return;
|
|
11229
11339
|
}
|
|
11230
|
-
SearchSuggestion.hide();
|
|
11340
|
+
SearchSuggestion.hide(true);
|
|
11231
11341
|
}
|
|
11232
11342
|
},
|
|
11233
11343
|
/**
|
|
@@ -11352,29 +11462,39 @@ System.register('pops', [], (function (exports) {
|
|
|
11352
11462
|
else {
|
|
11353
11463
|
// 在下面
|
|
11354
11464
|
position = "bottom";
|
|
11355
|
-
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
11356
11465
|
}
|
|
11357
11466
|
}
|
|
11358
11467
|
if (position === "top") {
|
|
11468
|
+
// 在上面
|
|
11359
11469
|
if (config.positionTopToReverse) {
|
|
11360
|
-
|
|
11470
|
+
// 自动翻转
|
|
11471
|
+
SearchSuggestion.$el.root.setAttribute("data-top-reverse", "true");
|
|
11361
11472
|
}
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11473
|
+
if (config.useFoldAnimation) {
|
|
11474
|
+
// 翻转折叠
|
|
11475
|
+
SearchSuggestion.$el.root.setAttribute("data-popper-placement", "top");
|
|
11476
|
+
}
|
|
11477
|
+
let bottom = documentHeight - targetRect.top + config.topDistance;
|
|
11478
|
+
SearchSuggestion.$el.root.style.top = "";
|
|
11479
|
+
SearchSuggestion.$el.root.style.bottom = bottom + "px";
|
|
11366
11480
|
}
|
|
11367
11481
|
else if (position === "bottom") {
|
|
11368
11482
|
// 在下面
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11483
|
+
if (config.useFoldAnimation) {
|
|
11484
|
+
SearchSuggestion.$el.root.setAttribute("data-popper-placement", "bottom-center");
|
|
11485
|
+
}
|
|
11486
|
+
let top = targetRect.height + targetRect.top + config.topDistance;
|
|
11487
|
+
SearchSuggestion.$el.root.removeAttribute("data-top-reverse");
|
|
11488
|
+
SearchSuggestion.$el.root.style.bottom = "";
|
|
11489
|
+
SearchSuggestion.$el.root.style.top = top + "px";
|
|
11373
11490
|
}
|
|
11491
|
+
let left = targetRect.left;
|
|
11374
11492
|
let hintUIWidth = popsDOMUtils.width(SearchSuggestion.$el.$hintULContainer);
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11493
|
+
if (hintUIWidth > documentWidth) {
|
|
11494
|
+
// 超出宽度
|
|
11495
|
+
left = left + documentWidth - hintUIWidth;
|
|
11496
|
+
}
|
|
11497
|
+
SearchSuggestion.$el.root.style.left = left + "px";
|
|
11378
11498
|
},
|
|
11379
11499
|
/**
|
|
11380
11500
|
* 更新搜索建议框的width
|
|
@@ -11396,6 +11516,17 @@ System.register('pops', [], (function (exports) {
|
|
|
11396
11516
|
let cssText = this.getDynamicCSS();
|
|
11397
11517
|
PopsSafeUtils.setSafeHTML(this.$el.$dynamicCSS, cssText);
|
|
11398
11518
|
},
|
|
11519
|
+
/**
|
|
11520
|
+
* 数据项的数量改变时调用
|
|
11521
|
+
*/
|
|
11522
|
+
updateStyleSheet() {
|
|
11523
|
+
// 更新z-index
|
|
11524
|
+
SearchSuggestion.updateDynamicCSS();
|
|
11525
|
+
// 更新宽度
|
|
11526
|
+
SearchSuggestion.changeHintULElementWidth();
|
|
11527
|
+
// 更新位置
|
|
11528
|
+
SearchSuggestion.changeHintULElementPosition();
|
|
11529
|
+
},
|
|
11399
11530
|
/**
|
|
11400
11531
|
* 更新页面显示的搜索结果
|
|
11401
11532
|
* @param data
|
|
@@ -11414,7 +11545,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11414
11545
|
SearchSuggestion.clearAllSearchItemLi();
|
|
11415
11546
|
/* 添加进ul中 */
|
|
11416
11547
|
config.data.forEach((item, index) => {
|
|
11417
|
-
let itemElement = SearchSuggestion.
|
|
11548
|
+
let itemElement = SearchSuggestion.createSearchItemLiElement(item, index);
|
|
11418
11549
|
SearchSuggestion.setSearchItemClickEvent(itemElement);
|
|
11419
11550
|
SearchSuggestion.setSearchItemSelectEvent(itemElement);
|
|
11420
11551
|
SearchSuggestion.$el.$hintULContainer.appendChild(itemElement);
|
|
@@ -11438,15 +11569,32 @@ System.register('pops', [], (function (exports) {
|
|
|
11438
11569
|
},
|
|
11439
11570
|
/**
|
|
11440
11571
|
* 隐藏搜索建议框
|
|
11572
|
+
* @param useAnimationToHide 是否使用动画隐藏
|
|
11441
11573
|
*/
|
|
11442
|
-
hide() {
|
|
11443
|
-
|
|
11574
|
+
hide(useAnimationToHide = false) {
|
|
11575
|
+
if (config.useFoldAnimation) {
|
|
11576
|
+
if (!useAnimationToHide) {
|
|
11577
|
+
// 去掉动画
|
|
11578
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11579
|
+
}
|
|
11580
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11581
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation-hide");
|
|
11582
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation-show");
|
|
11583
|
+
}
|
|
11584
|
+
else {
|
|
11585
|
+
this.$el.root.style.display = "none";
|
|
11586
|
+
}
|
|
11444
11587
|
},
|
|
11445
11588
|
/**
|
|
11446
11589
|
* 显示搜索建议框
|
|
11447
11590
|
*/
|
|
11448
11591
|
show() {
|
|
11449
11592
|
this.$el.root.style.display = "";
|
|
11593
|
+
if (config.useFoldAnimation) {
|
|
11594
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11595
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation-hide");
|
|
11596
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation-show");
|
|
11597
|
+
}
|
|
11450
11598
|
},
|
|
11451
11599
|
};
|
|
11452
11600
|
return SearchSuggestion;
|