@whitesev/pops 2.3.3 → 2.3.4
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 +257 -122
- package/dist/index.amd.js.map +1 -1
- package/dist/index.cjs.js +257 -122
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +257 -122
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +257 -122
- package/dist/index.iife.js.map +1 -1
- package/dist/index.system.js +257 -122
- package/dist/index.system.js.map +1 -1
- package/dist/index.umd.js +257 -122
- 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
|
}
|
|
@@ -10833,33 +10834,34 @@ System.register('pops', [], (function (exports) {
|
|
|
10833
10834
|
};
|
|
10834
10835
|
|
|
10835
10836
|
const searchSuggestionConfig = () => {
|
|
10837
|
+
const data = [];
|
|
10838
|
+
for (let index = 0; index < 10; index++) {
|
|
10839
|
+
data.push({
|
|
10840
|
+
value: `测试${index}`,
|
|
10841
|
+
text: `测试${index}-html`,
|
|
10842
|
+
});
|
|
10843
|
+
}
|
|
10836
10844
|
return {
|
|
10837
10845
|
// @ts-ignore
|
|
10838
10846
|
target: null,
|
|
10839
10847
|
// @ts-ignore
|
|
10840
10848
|
inputTarget: null,
|
|
10841
10849
|
selfDocument: document,
|
|
10842
|
-
data:
|
|
10843
|
-
{
|
|
10844
|
-
value: "数据1",
|
|
10845
|
-
text: "数据1-html",
|
|
10846
|
-
},
|
|
10847
|
-
{
|
|
10848
|
-
value: "数据2",
|
|
10849
|
-
text: "数据2-html",
|
|
10850
|
-
},
|
|
10851
|
-
],
|
|
10850
|
+
data: data,
|
|
10852
10851
|
deleteIcon: {
|
|
10853
10852
|
enable: true,
|
|
10854
|
-
callback(event, liElement,
|
|
10855
|
-
console.log("删除当前项", [event, liElement,
|
|
10853
|
+
callback(event, liElement, dataItem) {
|
|
10854
|
+
console.log("删除当前项", [event, liElement, dataItem]);
|
|
10855
|
+
data.splice(data.indexOf(dataItem), 1);
|
|
10856
10856
|
liElement.remove();
|
|
10857
10857
|
},
|
|
10858
10858
|
},
|
|
10859
10859
|
useShadowRoot: true,
|
|
10860
10860
|
className: "",
|
|
10861
10861
|
isAbsolute: true,
|
|
10862
|
-
isAnimation:
|
|
10862
|
+
isAnimation: false,
|
|
10863
|
+
useFoldAnimation: true,
|
|
10864
|
+
useArrow: false,
|
|
10863
10865
|
width: "250px",
|
|
10864
10866
|
maxHeight: "300px",
|
|
10865
10867
|
followTargetWidth: true,
|
|
@@ -10874,9 +10876,9 @@ System.register('pops', [], (function (exports) {
|
|
|
10874
10876
|
getItemHTML(item) {
|
|
10875
10877
|
return item.text ?? item;
|
|
10876
10878
|
},
|
|
10877
|
-
async getData(value) {
|
|
10879
|
+
async getData(value, data) {
|
|
10878
10880
|
console.log("当前输入框的值是:", value);
|
|
10879
|
-
return
|
|
10881
|
+
return data.filter((it) => it.value.includes(value));
|
|
10880
10882
|
},
|
|
10881
10883
|
itemClickCallBack(event, liElement, data) {
|
|
10882
10884
|
console.log("item项的点击回调", [event, liElement, data]);
|
|
@@ -10948,74 +10950,168 @@ System.register('pops', [], (function (exports) {
|
|
|
10948
10950
|
/** 是否结果为空 */
|
|
10949
10951
|
isEmpty: true,
|
|
10950
10952
|
},
|
|
10953
|
+
/** 初始化元素变量 */
|
|
10954
|
+
initEl() {
|
|
10955
|
+
this.$el.root = SearchSuggestion.createSearchSelectElement();
|
|
10956
|
+
this.$el.$dynamicCSS = this.$el.root.querySelector("style[data-dynamic]");
|
|
10957
|
+
this.$el.$hintULContainer = SearchSuggestion.$el.root.querySelector("ul");
|
|
10958
|
+
},
|
|
10951
10959
|
/**
|
|
10952
10960
|
* 初始化
|
|
10953
10961
|
*/
|
|
10954
10962
|
init(parentElement = document.body || document.documentElement) {
|
|
10955
10963
|
this.initEl();
|
|
10956
|
-
SearchSuggestion.update(
|
|
10957
|
-
SearchSuggestion.
|
|
10958
|
-
SearchSuggestion.changeHintULElementWidth();
|
|
10959
|
-
SearchSuggestion.changeHintULElementPosition();
|
|
10964
|
+
SearchSuggestion.update(this.getData());
|
|
10965
|
+
SearchSuggestion.updateStyleSheet();
|
|
10960
10966
|
SearchSuggestion.hide();
|
|
10961
|
-
if (config.isAnimation) {
|
|
10962
|
-
SearchSuggestion.$el.root.classList.add(`pops-${popsType}-animation`);
|
|
10963
|
-
}
|
|
10964
10967
|
$shadowRoot.appendChild(SearchSuggestion.$el.root);
|
|
10965
10968
|
parentElement.appendChild($shadowContainer);
|
|
10966
10969
|
},
|
|
10967
|
-
/**
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10970
|
+
/**
|
|
10971
|
+
* 获取数据
|
|
10972
|
+
*/
|
|
10973
|
+
getData() {
|
|
10974
|
+
return typeof config.data === "function" ? config.data() : config.data;
|
|
10972
10975
|
},
|
|
10973
10976
|
/**
|
|
10974
10977
|
* 获取显示出搜索建议框的html
|
|
10975
10978
|
*/
|
|
10976
|
-
|
|
10977
|
-
let
|
|
10979
|
+
createSearchSelectElement() {
|
|
10980
|
+
let $el = popsDOMUtils.createElement("div", {
|
|
10978
10981
|
className: `pops pops-${popsType}-search-suggestion`,
|
|
10979
10982
|
innerHTML: /*html*/ `
|
|
10983
|
+
<style>
|
|
10984
|
+
.pops-${popsType}-animation{
|
|
10985
|
+
-moz-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10986
|
+
-webkit-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10987
|
+
-o-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10988
|
+
-ms-animation: searchSelectFalIn 0.5s 1 linear;
|
|
10989
|
+
}
|
|
10990
|
+
</style>
|
|
10991
|
+
<style>
|
|
10992
|
+
.pops-${popsType}-search-suggestion-arrow{
|
|
10993
|
+
--suggestion-arrow-box-shadow-left-color: rgba(0, 0, 0, 0.24);
|
|
10994
|
+
--suggestion-arrow-box-shadow-right-color: rgba(0, 0, 0, 0.12);
|
|
10995
|
+
--suggestion-arrow--after-color: rgb(78, 78, 78);
|
|
10996
|
+
--suggestion-arrow--after-bg-color: rgb(255, 255, 255, var(--pops-bg-opacity));
|
|
10997
|
+
--suggestion-arrow--after-width: 10px;
|
|
10998
|
+
--suggestion-arrow--after-height: 10px;
|
|
10999
|
+
}
|
|
11000
|
+
.pops-${popsType}-search-suggestion-arrow{
|
|
11001
|
+
position: absolute;
|
|
11002
|
+
top: 100%;
|
|
11003
|
+
left: 50%;
|
|
11004
|
+
overflow: hidden;
|
|
11005
|
+
width: 100%;
|
|
11006
|
+
height: 12.5px;
|
|
11007
|
+
transform: translateX(-50%);
|
|
11008
|
+
}
|
|
11009
|
+
.pops-${popsType}-search-suggestion-arrow::after{
|
|
11010
|
+
position: absolute;
|
|
11011
|
+
top: 0;
|
|
11012
|
+
left: 50%;
|
|
11013
|
+
width: var(--suggestion-arrow--after-width);
|
|
11014
|
+
height: var(--suggestion-arrow--after-height);
|
|
11015
|
+
background: var(--suggestion-arrow--after-bg-color);
|
|
11016
|
+
color: var(--suggestion-arrow--after-color);
|
|
11017
|
+
box-shadow:
|
|
11018
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-left-color),
|
|
11019
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-right-color);
|
|
11020
|
+
content: "";
|
|
11021
|
+
transform: translateX(-50%) translateY(-50%) rotate(45deg);
|
|
11022
|
+
}
|
|
11023
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="top"] .pops-${popsType}-search-suggestion-arrow{
|
|
11024
|
+
position: absolute;
|
|
11025
|
+
top: 100%;
|
|
11026
|
+
left: 50%;
|
|
11027
|
+
overflow: hidden;
|
|
11028
|
+
width: 100%;
|
|
11029
|
+
height: 12.5px;
|
|
11030
|
+
transform: translateX(-50%);
|
|
11031
|
+
}
|
|
11032
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="top"] .pops-${popsType}-search-suggestion-arrow::after{
|
|
11033
|
+
position: absolute;
|
|
11034
|
+
top: 0;
|
|
11035
|
+
left: 50%;
|
|
11036
|
+
width: var(--suggestion-arrow--after-width);
|
|
11037
|
+
height: var(--suggestion-arrow--after-height);
|
|
11038
|
+
background: var(--suggestion-arrow--after-bg-color);
|
|
11039
|
+
box-shadow:
|
|
11040
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-left-color),
|
|
11041
|
+
0 1px 7px var(--suggestion-arrow-box-shadow-right-color);
|
|
11042
|
+
content: "";
|
|
11043
|
+
transform: translateX(-50%) translateY(-50%) rotate(45deg);
|
|
11044
|
+
}
|
|
11045
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="bottom"] .pops-${popsType}-search-suggestion-arrow{
|
|
11046
|
+
top: -12.5px;
|
|
11047
|
+
left: 50%;
|
|
11048
|
+
transform: translateX(-50%);
|
|
11049
|
+
}
|
|
11050
|
+
.pops-${popsType}-search-suggestion[data-popper-placement^="bottom"] .pops-${popsType}-search-suggestion-arrow::after{
|
|
11051
|
+
position: absolute;
|
|
11052
|
+
top: 100%;
|
|
11053
|
+
left: 50%;
|
|
11054
|
+
content: "";
|
|
11055
|
+
}
|
|
11056
|
+
</style>
|
|
10980
11057
|
<style data-dynamic="true">
|
|
10981
11058
|
${this.getDynamicCSS()}
|
|
10982
11059
|
</style>
|
|
10983
|
-
<
|
|
11060
|
+
<style>
|
|
11061
|
+
.el-zoom-in-top-animation{
|
|
11062
|
+
--el-transition-md-fade: transform 0.3s cubic-bezier(0.23, 1, 0.32, 1),
|
|
11063
|
+
opacity 0.3s cubic-bezier(0.23, 1, 0.32, 1);
|
|
11064
|
+
transition: var(--el-transition-md-fade);
|
|
11065
|
+
transform-origin: center top;
|
|
11066
|
+
}
|
|
11067
|
+
.el-zoom-in-top-animation[data-popper-placement^="top"] {
|
|
11068
|
+
transform-origin: center bottom;
|
|
11069
|
+
}
|
|
11070
|
+
.el-zoom-in-top-animation-hide{
|
|
11071
|
+
opacity: 0;
|
|
11072
|
+
transform: scaleY(0);
|
|
11073
|
+
}
|
|
11074
|
+
.el-zoom-in-top-animation-show{
|
|
11075
|
+
opacity: 1;
|
|
11076
|
+
transform: scaleY(1);
|
|
11077
|
+
}
|
|
11078
|
+
</style>
|
|
11079
|
+
<ul class="pops-${popsType}-search-suggestion-hint ${PopsCommonCSSClassName.userSelectNone}">${config.toSearhNotResultHTML}</ul>
|
|
11080
|
+
${config.useArrow ? /*html*/ `<div class="pops-${popsType}-search-suggestion-arrow"></div>` : ""}
|
|
10984
11081
|
`,
|
|
10985
11082
|
}, {
|
|
10986
11083
|
"data-guid": guid,
|
|
10987
11084
|
"type-value": popsType,
|
|
10988
11085
|
});
|
|
10989
11086
|
if (config.className !== "" && config.className != null) {
|
|
10990
|
-
popsDOMUtils.addClassName(
|
|
11087
|
+
popsDOMUtils.addClassName($el, config.className);
|
|
11088
|
+
}
|
|
11089
|
+
if (config.isAnimation) {
|
|
11090
|
+
popsDOMUtils.addClassName($el, `pops-${popsType}-animation`);
|
|
11091
|
+
}
|
|
11092
|
+
if (config.useFoldAnimation) {
|
|
11093
|
+
popsDOMUtils.addClassName($el, "el-zoom-in-top-animation");
|
|
10991
11094
|
}
|
|
10992
|
-
return
|
|
11095
|
+
return $el;
|
|
10993
11096
|
},
|
|
10994
11097
|
/** 动态获取CSS */
|
|
10995
11098
|
getDynamicCSS() {
|
|
10996
11099
|
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
11100
|
.pops-${popsType}-search-suggestion{
|
|
11004
11101
|
--search-suggestion-bg-color: #ffffff;
|
|
11005
11102
|
--search-suggestion-box-shadow-color: rgb(0 0 0 / 20%);
|
|
11006
11103
|
--search-suggestion-item-color: #515a6e;
|
|
11007
11104
|
--search-suggestion-item-none-color: #8e8e8e;
|
|
11008
|
-
--search-suggestion-item-hover-bg-color:
|
|
11105
|
+
--search-suggestion-item-is-hover-bg-color: #f5f7fa;
|
|
11106
|
+
--search-suggestion-item-is-select-bg-color: #409eff;
|
|
11009
11107
|
}
|
|
11010
11108
|
.pops-${popsType}-search-suggestion{
|
|
11011
11109
|
border: initial;
|
|
11012
11110
|
overflow: initial;
|
|
11013
|
-
}
|
|
11014
|
-
ul.pops-${popsType}-search-suggestion-hint{
|
|
11015
11111
|
position: ${config.isAbsolute ? "absolute" : "fixed"};
|
|
11016
11112
|
z-index: ${PopsHandler.handleZIndex(config.zIndex)};
|
|
11017
|
-
|
|
11018
|
-
|
|
11113
|
+
}
|
|
11114
|
+
ul.pops-${popsType}-search-suggestion-hint{
|
|
11019
11115
|
max-height: ${config.maxHeight};
|
|
11020
11116
|
overflow-x: hidden;
|
|
11021
11117
|
overflow-y: auto;
|
|
@@ -11026,11 +11122,11 @@ System.register('pops', [], (function (exports) {
|
|
|
11026
11122
|
box-shadow: 0 1px 6px var(--search-suggestion-box-shadow-color);
|
|
11027
11123
|
}
|
|
11028
11124
|
/* 建议框在上面时 */
|
|
11029
|
-
|
|
11125
|
+
.pops-${popsType}-search-suggestion[data-top-reverse] ul.pops-${popsType}-search-suggestion-hint{
|
|
11030
11126
|
display: flex;
|
|
11031
11127
|
flex-direction: column-reverse;
|
|
11032
11128
|
}
|
|
11033
|
-
|
|
11129
|
+
.pops-${popsType}-search-suggestion[data-top-reverse] ul.pops-${popsType}-search-suggestion-hint li{
|
|
11034
11130
|
flex-shrink: 0;
|
|
11035
11131
|
}
|
|
11036
11132
|
ul.pops-${popsType}-search-suggestion-hint li{
|
|
@@ -11052,14 +11148,13 @@ System.register('pops', [], (function (exports) {
|
|
|
11052
11148
|
color: var(--search-suggestion-item-none-color);
|
|
11053
11149
|
}
|
|
11054
11150
|
ul.pops-${popsType}-search-suggestion-hint li:not([data-none]):hover{
|
|
11055
|
-
background-color: var(--search-suggestion-item-hover-bg-color);
|
|
11151
|
+
background-color: var(--search-suggestion-item-is-hover-bg-color);
|
|
11056
11152
|
}
|
|
11057
|
-
|
|
11058
11153
|
@media (prefers-color-scheme: dark){
|
|
11059
11154
|
.pops-${popsType}-search-suggestion{
|
|
11060
11155
|
--search-suggestion-bg-color: #1d1e1f;
|
|
11061
11156
|
--search-suggestion-item-color: #cfd3d4;
|
|
11062
|
-
--search-suggestion-item-hover-bg-color: rgba(175, 175, 175, .1);
|
|
11157
|
+
--search-suggestion-item-is-hover-bg-color: rgba(175, 175, 175, .1);
|
|
11063
11158
|
}
|
|
11064
11159
|
}
|
|
11065
11160
|
`;
|
|
@@ -11069,7 +11164,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11069
11164
|
* @param data 当前项的值
|
|
11070
11165
|
* @param index 当前项的下标
|
|
11071
11166
|
*/
|
|
11072
|
-
|
|
11167
|
+
createSearchItemLiElement(data, index) {
|
|
11073
11168
|
let $li = popsDOMUtils.createElement("li", {
|
|
11074
11169
|
className: `pops-${popsType}-search-suggestion-hint-item`,
|
|
11075
11170
|
"data-index": index,
|
|
@@ -11089,25 +11184,28 @@ System.register('pops', [], (function (exports) {
|
|
|
11089
11184
|
},
|
|
11090
11185
|
/**
|
|
11091
11186
|
* 设置搜索建议框每一项的点击事件
|
|
11092
|
-
* @param
|
|
11187
|
+
* @param $searchItem
|
|
11093
11188
|
*/
|
|
11094
|
-
setSearchItemClickEvent(
|
|
11095
|
-
popsDOMUtils.on(
|
|
11189
|
+
setSearchItemClickEvent($searchItem) {
|
|
11190
|
+
popsDOMUtils.on($searchItem, "click", (event) => {
|
|
11096
11191
|
popsDOMUtils.preventEvent(event);
|
|
11097
11192
|
let $click = event.target;
|
|
11098
|
-
|
|
11099
|
-
|
|
11193
|
+
let dataValue = Reflect.get($searchItem, "data-value");
|
|
11194
|
+
let isDelete = Boolean($click.closest(`.pops-${popsType}-delete-icon`));
|
|
11195
|
+
if (isDelete) {
|
|
11196
|
+
// 删除
|
|
11100
11197
|
if (typeof config.deleteIcon.callback === "function") {
|
|
11101
|
-
config.deleteIcon.callback(event,
|
|
11198
|
+
config.deleteIcon.callback(event, $searchItem, dataValue);
|
|
11102
11199
|
}
|
|
11103
11200
|
if (!this.$el.$hintULContainer.children.length) {
|
|
11104
11201
|
/* 全删完了 */
|
|
11105
11202
|
this.clear();
|
|
11106
11203
|
}
|
|
11204
|
+
SearchSuggestion.updateStyleSheet();
|
|
11107
11205
|
}
|
|
11108
11206
|
else {
|
|
11109
|
-
|
|
11110
|
-
config.itemClickCallBack(event,
|
|
11207
|
+
// 点击选择项
|
|
11208
|
+
config.itemClickCallBack(event, $searchItem, dataValue);
|
|
11111
11209
|
}
|
|
11112
11210
|
}, {
|
|
11113
11211
|
capture: true,
|
|
@@ -11147,8 +11245,9 @@ System.register('pops', [], (function (exports) {
|
|
|
11147
11245
|
config.inputTarget.setAttribute("autocomplete", "off");
|
|
11148
11246
|
/* 内容改变事件 */
|
|
11149
11247
|
popsDOMUtils.on(config.inputTarget, "input", void 0, async (event) => {
|
|
11150
|
-
let getListResult = await config.getData(
|
|
11248
|
+
let getListResult = await config.getData(config.inputTarget.value, this.getData());
|
|
11151
11249
|
SearchSuggestion.update(getListResult);
|
|
11250
|
+
SearchSuggestion.updateStyleSheet();
|
|
11152
11251
|
}, option);
|
|
11153
11252
|
},
|
|
11154
11253
|
/**
|
|
@@ -11163,12 +11262,10 @@ System.register('pops', [], (function (exports) {
|
|
|
11163
11262
|
* 显示搜索建议框的事件
|
|
11164
11263
|
*/
|
|
11165
11264
|
showEvent() {
|
|
11166
|
-
SearchSuggestion.
|
|
11167
|
-
SearchSuggestion.changeHintULElementWidth();
|
|
11168
|
-
SearchSuggestion.changeHintULElementPosition();
|
|
11265
|
+
SearchSuggestion.updateStyleSheet();
|
|
11169
11266
|
if (config.toHideWithNotResult) {
|
|
11170
11267
|
if (SearchSuggestion.$data.isEmpty) {
|
|
11171
|
-
SearchSuggestion.hide();
|
|
11268
|
+
SearchSuggestion.hide(true);
|
|
11172
11269
|
}
|
|
11173
11270
|
else {
|
|
11174
11271
|
SearchSuggestion.show();
|
|
@@ -11227,7 +11324,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11227
11324
|
/* 点击在目标input内 */
|
|
11228
11325
|
return;
|
|
11229
11326
|
}
|
|
11230
|
-
SearchSuggestion.hide();
|
|
11327
|
+
SearchSuggestion.hide(true);
|
|
11231
11328
|
}
|
|
11232
11329
|
},
|
|
11233
11330
|
/**
|
|
@@ -11352,29 +11449,39 @@ System.register('pops', [], (function (exports) {
|
|
|
11352
11449
|
else {
|
|
11353
11450
|
// 在下面
|
|
11354
11451
|
position = "bottom";
|
|
11355
|
-
SearchSuggestion.$el.$hintULContainer.removeAttribute("data-top");
|
|
11356
11452
|
}
|
|
11357
11453
|
}
|
|
11358
11454
|
if (position === "top") {
|
|
11455
|
+
// 在上面
|
|
11359
11456
|
if (config.positionTopToReverse) {
|
|
11360
|
-
|
|
11457
|
+
// 自动翻转
|
|
11458
|
+
SearchSuggestion.$el.root.setAttribute("data-top-reverse", "true");
|
|
11361
11459
|
}
|
|
11362
|
-
|
|
11363
|
-
|
|
11364
|
-
|
|
11365
|
-
|
|
11460
|
+
if (config.useFoldAnimation) {
|
|
11461
|
+
// 翻转折叠
|
|
11462
|
+
SearchSuggestion.$el.root.setAttribute("data-popper-placement", "top");
|
|
11463
|
+
}
|
|
11464
|
+
let bottom = documentHeight - targetRect.top + config.topDistance;
|
|
11465
|
+
SearchSuggestion.$el.root.style.top = "";
|
|
11466
|
+
SearchSuggestion.$el.root.style.bottom = bottom + "px";
|
|
11366
11467
|
}
|
|
11367
11468
|
else if (position === "bottom") {
|
|
11368
11469
|
// 在下面
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11470
|
+
if (config.useFoldAnimation) {
|
|
11471
|
+
SearchSuggestion.$el.root.setAttribute("data-popper-placement", "bottom-center");
|
|
11472
|
+
}
|
|
11473
|
+
let top = targetRect.height + targetRect.top + config.topDistance;
|
|
11474
|
+
SearchSuggestion.$el.root.removeAttribute("data-top-reverse");
|
|
11475
|
+
SearchSuggestion.$el.root.style.bottom = "";
|
|
11476
|
+
SearchSuggestion.$el.root.style.top = top + "px";
|
|
11373
11477
|
}
|
|
11478
|
+
let left = targetRect.left;
|
|
11374
11479
|
let hintUIWidth = popsDOMUtils.width(SearchSuggestion.$el.$hintULContainer);
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11480
|
+
if (hintUIWidth > documentWidth) {
|
|
11481
|
+
// 超出宽度
|
|
11482
|
+
left = left + documentWidth - hintUIWidth;
|
|
11483
|
+
}
|
|
11484
|
+
SearchSuggestion.$el.root.style.left = left + "px";
|
|
11378
11485
|
},
|
|
11379
11486
|
/**
|
|
11380
11487
|
* 更新搜索建议框的width
|
|
@@ -11396,6 +11503,17 @@ System.register('pops', [], (function (exports) {
|
|
|
11396
11503
|
let cssText = this.getDynamicCSS();
|
|
11397
11504
|
PopsSafeUtils.setSafeHTML(this.$el.$dynamicCSS, cssText);
|
|
11398
11505
|
},
|
|
11506
|
+
/**
|
|
11507
|
+
* 数据项的数量改变时调用
|
|
11508
|
+
*/
|
|
11509
|
+
updateStyleSheet() {
|
|
11510
|
+
// 更新z-index
|
|
11511
|
+
SearchSuggestion.updateDynamicCSS();
|
|
11512
|
+
// 更新宽度
|
|
11513
|
+
SearchSuggestion.changeHintULElementWidth();
|
|
11514
|
+
// 更新位置
|
|
11515
|
+
SearchSuggestion.changeHintULElementPosition();
|
|
11516
|
+
},
|
|
11399
11517
|
/**
|
|
11400
11518
|
* 更新页面显示的搜索结果
|
|
11401
11519
|
* @param data
|
|
@@ -11414,7 +11532,7 @@ System.register('pops', [], (function (exports) {
|
|
|
11414
11532
|
SearchSuggestion.clearAllSearchItemLi();
|
|
11415
11533
|
/* 添加进ul中 */
|
|
11416
11534
|
config.data.forEach((item, index) => {
|
|
11417
|
-
let itemElement = SearchSuggestion.
|
|
11535
|
+
let itemElement = SearchSuggestion.createSearchItemLiElement(item, index);
|
|
11418
11536
|
SearchSuggestion.setSearchItemClickEvent(itemElement);
|
|
11419
11537
|
SearchSuggestion.setSearchItemSelectEvent(itemElement);
|
|
11420
11538
|
SearchSuggestion.$el.$hintULContainer.appendChild(itemElement);
|
|
@@ -11438,15 +11556,32 @@ System.register('pops', [], (function (exports) {
|
|
|
11438
11556
|
},
|
|
11439
11557
|
/**
|
|
11440
11558
|
* 隐藏搜索建议框
|
|
11559
|
+
* @param useAnimationToHide 是否使用动画隐藏
|
|
11441
11560
|
*/
|
|
11442
|
-
hide() {
|
|
11443
|
-
|
|
11561
|
+
hide(useAnimationToHide = false) {
|
|
11562
|
+
if (config.useFoldAnimation) {
|
|
11563
|
+
if (!useAnimationToHide) {
|
|
11564
|
+
// 去掉动画
|
|
11565
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11566
|
+
}
|
|
11567
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11568
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation-hide");
|
|
11569
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation-show");
|
|
11570
|
+
}
|
|
11571
|
+
else {
|
|
11572
|
+
this.$el.root.style.display = "none";
|
|
11573
|
+
}
|
|
11444
11574
|
},
|
|
11445
11575
|
/**
|
|
11446
11576
|
* 显示搜索建议框
|
|
11447
11577
|
*/
|
|
11448
11578
|
show() {
|
|
11449
11579
|
this.$el.root.style.display = "";
|
|
11580
|
+
if (config.useFoldAnimation) {
|
|
11581
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation");
|
|
11582
|
+
popsDOMUtils.removeClassName(this.$el.root, "el-zoom-in-top-animation-hide");
|
|
11583
|
+
popsDOMUtils.addClassName(this.$el.root, "el-zoom-in-top-animation-show");
|
|
11584
|
+
}
|
|
11450
11585
|
},
|
|
11451
11586
|
};
|
|
11452
11587
|
return SearchSuggestion;
|