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